| 1 | /* |
| 2 | * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. |
| 13 | * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of |
| 14 | * its contributors may be used to endorse or promote products derived |
| 15 | * from this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 20 | * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
| 28 | |
| 29 | #include "config.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/config.h`/ |
| 30 | #include "JSActivation.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSActivation.h`/ |
| 31 | |
| 32 | #include "Arguments.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Arguments.h`/ |
| 33 | #include "Interpreter.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.h`/ |
| 34 | #include "JSFunction.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSFunction.h`/ |
| 35 | |
| 36 | namespace JSCcxx . . $ `<built-in>:463:9`! { |
| 37 | |
| 38 | ASSERT_CLASS_FITS_IN_CELLcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h:42:9`!(JSActivation); |
| 39 | |
| 40 | const ClassInfocxx . . $ QTJSC/ClassInfo# JSActivationcxx . . $ QTJSC/JSActivation#::infocxx . . $ QTJSC/JSActivation#info. = { "JSActivation", 0, 0, 0 }; |
| 41 | |
| 42 | JSActivationcxx . . $ QTJSC/JSActivation#::JSActivationcxx . . $ QTJSC/JSActivation#JSActivation(63e8c35d4c2dafcb).(CallFramecxx . . $ QTJSC/CallFrame#* callFrame, NonNullPassRefPtrcxx . . $ NonNullPassRefPtr#<FunctionExecutablecxx . . $ QTJSC/FunctionExecutable#> functionExecutable) |
| 43 | : Basecxx . . $ QTJSC/JSActivation#Base#(callFrame->globalDatacxx . . $ QTJSC/ExecState#globalData(ae00a65ac2fd4a61).().activationStructure, new JSActivationDatacxx . . $ QTJSC/JSActivation#JSActivationData#(functionExecutable, callFrame->registerscxx . . $ QTJSC/ExecState#registers(b2e4df52de7a0262).())) |
| 44 | { |
| 45 | } |
| 46 | |
| 47 | JSActivationcxx . . $ QTJSC/JSActivation#::~cxx . . $ QTJSC/JSActivation#`~JSActivation`(49f6e7a06ebc5aa8).JSActivationcxx . . $ QTJSC/JSActivation#() |
| 48 | { |
| 49 | delete dcxx . . $ QTJSC/JSActivation#d(b05c7bd1e432b963).(); |
| 50 | } |
| 51 | |
| 52 | void JSActivationcxx . . $ QTJSC/JSActivation#::markChildrencxx . . $ QTJSC/JSActivation#markChildren(bd9cae851d80a865).(MarkStackcxx . . $ QTJSC/MarkStack#& markStack) |
| 53 | { |
| 54 | Basecxx . . $ QTJSC/JSActivation#Base#::markChildrencxx . . $ QTJSC/JSObject#markChildren(bd9cae851d80a865).(markStack); |
| 55 | |
| 56 | Registercxx . . $ QTJSC/Register#* registerArray = dcxx . . $ QTJSC/JSActivation#d(b05c7bd1e432b963).()->registerArray.get(); |
| 57 | if (!registerArray) |
| 58 | return; |
| 59 | |
| 60 | size_t numParametersMinusThis = dcxx . . $ QTJSC/JSActivation#d(b05c7bd1e432b963).()->functionExecutable->parameterCount(); |
| 61 | |
| 62 | size_t count = numParametersMinusThis; |
| 63 | markStack.appendValuescxx . . $ QTJSC/MarkStack#appendValues(43883644a1fa3f52).(registerArray, count); |
| 64 | |
| 65 | size_t numVars = dcxx . . $ QTJSC/JSActivation#d(b05c7bd1e432b963).()->functionExecutable->variableCount(); |
| 66 | |
| 67 | // Skip the call frame, which sits between the parameters and vars. |
| 68 | markStack.appendValuescxx . . $ QTJSC/MarkStack#appendValues(43883644a1fa3f52).(registerArray + count + RegisterFilecxx . . $ QTJSC/RegisterFile#::CallFrameHeaderSizecxx . . $ QTJSC/RegisterFile#CallFrameHeaderSize., numVars, MayContainNullValuescxx . . $ QTJSC/MayContainNullValues.); |
| 69 | } |
| 70 | |
| 71 | bool JSActivationcxx . . $ QTJSC/JSActivation#::getOwnPropertySlotcxx . . $ QTJSC/JSActivation#getOwnPropertySlot(6f4ef3dbfe7d5ab9).(ExecStatecxx . . $ QTJSC/ExecState#* exec, const Identifiercxx . . $ QTJSC/Identifier#& propertyName, PropertySlotcxx . . $ QTJSC/PropertySlot#& slot) |
| 72 | { |
| 73 | if (symbolTableGetcxx . . $ QTJSC/JSVariableObject#symbolTableGet(731403b11dc42711).(propertyName, slot)) |
| 74 | return true; |
| 75 | |
| 76 | if (JSValuecxx . . $ QTJSC/JSValue#* location = getDirectLocationcxx . . $ QTJSC/JSObject#getDirectLocation(d045793fede5b5cb).(propertyName)) { |
| 77 | slot.setValueSlotcxx . . $ QTJSC/PropertySlot#setValueSlot(1b789a609c0b4a9).(location); |
| 78 | return true; |
| 79 | } |
| 80 | |
| 81 | // Only return the built-in arguments object if it wasn't overridden above. |
| 82 | if (propertyName ==cxx . . $ QTJSC/`operator==`(8208a731c2dadbc2). exec->propertyNamescxx . . $ QTJSC/ExecState#propertyNames(16296db726e31f87).().arguments) { |
| 83 | slot.setCustomcxx . . $ QTJSC/PropertySlot#setCustom(201c6ee79e352ec7).(this, getArgumentsGettercxx . . $ QTJSC/JSActivation#getArgumentsGetter(99fb93595b3575cf).()); |
| 84 | return true; |
| 85 | } |
| 86 | |
| 87 | // We don't call through to JSObject because there's no way to give an |
| 88 | // activation object getter properties or a prototype. |
| 89 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!hasGetterSetterProperties()); |
| 90 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(prototype().isNull()); |
| 91 | return false; |
| 92 | } |
| 93 | |
| 94 | void JSActivationcxx . . $ QTJSC/JSActivation#::putcxx . . $ QTJSC/JSActivation#put(dfb3133dafbe9ff4).(ExecStatecxx . . $ QTJSC/ExecState#*, const Identifiercxx . . $ QTJSC/Identifier#& propertyName, JSValuecxx . . $ QTJSC/JSValue# value, PutPropertySlotcxx . . $ QTJSC/PutPropertySlot#& slot) |
| 95 | { |
| 96 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); |
| 97 | |
| 98 | if (symbolTablePutcxx . . $ QTJSC/JSVariableObject#symbolTablePut(fed57b58e1b3b689).(propertyName, value)) |
| 99 | return; |
| 100 | |
| 101 | // We don't call through to JSObject because __proto__ and getter/setter |
| 102 | // properties are non-standard extensions that other implementations do not |
| 103 | // expose in the activation object. |
| 104 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!hasGetterSetterProperties()); |
| 105 | putDirectcxx . . $ QTJSC/JSObject#putDirect(10adf5710ac333de).(propertyName, value, 0, true, slot); |
| 106 | } |
| 107 | |
| 108 | // FIXME: Make this function honor ReadOnly (const) and DontEnum |
| 109 | void JSActivationcxx . . $ QTJSC/JSActivation#::putWithAttributescxx . . $ QTJSC/JSActivation#putWithAttributes(3dd2e6313723688d).(ExecStatecxx . . $ QTJSC/ExecState#* exec, const Identifiercxx . . $ QTJSC/Identifier#& propertyName, JSValuecxx . . $ QTJSC/JSValue# value, unsigned attributes) |
| 110 | { |
| 111 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); |
| 112 | |
| 113 | if (symbolTablePutWithAttributescxx . . $ QTJSC/JSVariableObject#symbolTablePutWithAttributes(689229d65cb128e1).(propertyName, value, attributes)) |
| 114 | return; |
| 115 | |
| 116 | // We don't call through to JSObject because __proto__ and getter/setter |
| 117 | // properties are non-standard extensions that other implementations do not |
| 118 | // expose in the activation object. |
| 119 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!hasGetterSetterProperties()); |
| 120 | PutPropertySlotcxx . . $ QTJSC/PutPropertySlot# slotcxx . . $ QTJSC/PutPropertySlot#PutPropertySlot(49f6e7a06ebc5aa8).; |
| 121 | JSObjectcxx . . $ QTJSC/JSObject#::putWithAttributescxx . . $ QTJSC/JSActivation#putWithAttributes(3dd2e6313723688d).(exec, propertyName, value, attributes, true, slot); |
| 122 | } |
| 123 | |
| 124 | bool JSActivationcxx . . $ QTJSC/JSActivation#::deletePropertycxx . . $ QTJSC/JSActivation#deleteProperty(13154ef9bddc9416).(ExecStatecxx . . $ QTJSC/ExecState#* exec, const Identifiercxx . . $ QTJSC/Identifier#& propertyName) |
| 125 | { |
| 126 | if (propertyName ==cxx . . $ QTJSC/`operator==`(8208a731c2dadbc2). exec->propertyNamescxx . . $ QTJSC/ExecState#propertyNames(16296db726e31f87).().arguments) |
| 127 | return false; |
| 128 | |
| 129 | return Basecxx . . $ QTJSC/JSActivation#Base#::deletePropertycxx . . $ QTJSC/JSVariableObject#deleteProperty(13154ef9bddc9416).(exec, propertyName); |
| 130 | } |
| 131 | |
| 132 | JSObjectcxx . . $ QTJSC/JSObject#* JSActivationcxx . . $ QTJSC/JSActivation#::toThisObjectcxx . . $ QTJSC/JSActivation#toThisObject(8709ed4849a165ab).(ExecStatecxx . . $ QTJSC/ExecState#* exec) const |
| 133 | { |
| 134 | return exec->globalThisValuecxx . . $ QTJSC/ExecState#globalThisValue(8ac23ea934d7a115).(); |
| 135 | } |
| 136 | |
| 137 | bool JSActivationcxx . . $ QTJSC/JSActivation#::isDynamicScopecxx . . $ QTJSC/JSActivation#isDynamicScope(50ce9a9e25b4a850).() const |
| 138 | { |
| 139 | return dcxx . . $ QTJSC/JSActivation#d(b05c7bd1e432b963).()->functionExecutable->usesEval(); |
| 140 | } |
| 141 | |
| 142 | JSValuecxx . . $ QTJSC/JSValue# JSActivationcxx . . $ QTJSC/JSActivation#::argumentsGettercxx . . $ QTJSC/JSActivation#argumentsGetter(2d50ae1b8ebdc06b).(ExecStatecxx . . $ QTJSC/ExecState#* exec, const Identifiercxx . . $ QTJSC/Identifier#&, const PropertySlotcxx . . $ QTJSC/PropertySlot#& slot) |
| 143 | { |
| 144 | JSActivationcxx . . $ QTJSC/JSActivation#* activation = asActivationcxx . . $ QTJSC/asActivation(fda623bd7e3aaba4).(slot.slotBasecxx . . $ QTJSC/PropertySlot#slotBase(888c053acf364da1).()); |
| 145 | |
| 146 | if (activation->dcxx . . $ QTJSC/JSActivation#d(b05c7bd1e432b963).()->functionExecutable->usesArguments()) { |
| 147 | PropertySlotcxx . . $ QTJSC/PropertySlot# slotcxx . . $ QTJSC/PropertySlot#PropertySlot(49f6e7a06ebc5aa8).; |
| 148 | activation->symbolTableGetcxx . . $ QTJSC/JSVariableObject#symbolTableGet(731403b11dc42711).(exec->propertyNamescxx . . $ QTJSC/ExecState#propertyNames(16296db726e31f87).().arguments, slot); |
| 149 | return slot.getValuecxx . . $ QTJSC/PropertySlot#getValue(ccadc8db5e9d2977).(exec, exec->propertyNamescxx . . $ QTJSC/ExecState#propertyNames(16296db726e31f87).().arguments); |
| 150 | } |
| 151 | |
| 152 | CallFramecxx . . $ QTJSC/CallFrame#* callFrame = CallFramecxx . . $ QTJSC/CallFrame#::createcxx . . $ QTJSC/ExecState#create(38d04c2988512828).(activation->dcxx . . $ QTJSC/JSActivation#d(b05c7bd1e432b963).()->registers); |
| 153 | Argumentscxx . . $ QTJSC/Arguments#* arguments = callFrame->optionalCalleeArgumentscxx . . $ QTJSC/ExecState#optionalCalleeArguments(66a58788709e4d3d).(); |
| 154 | if (!arguments) { |
| 155 | arguments = new (callFrame) Argumentscxx . . $ QTJSC/Arguments#Arguments(d2cb180e190a9680).(callFrame); |
| 156 | arguments->copyRegisterscxx . . $ QTJSC/Arguments#copyRegisters(49f6e7a06ebc5aa8).(); |
| 157 | callFrame->setCalleeArgumentscxx . . $ QTJSC/ExecState#setCalleeArguments(5c2ac18db087b3e6).(arguments); |
| 158 | } |
| 159 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(arguments->inherits(&Arguments::info)); |
| 160 | |
| 161 | return arguments; |
| 162 | } |
| 163 | |
| 164 | // These two functions serve the purpose of isolating the common case from a |
| 165 | // PIC branch. |
| 166 | |
| 167 | PropertySlotcxx . . $ QTJSC/PropertySlot#::GetValueFunccxx . . $ QTJSC/PropertySlot#GetValueFunc# JSActivationcxx . . $ QTJSC/JSActivation#::getArgumentsGettercxx . . $ QTJSC/JSActivation#getArgumentsGetter(99fb93595b3575cf).() |
| 168 | { |
| 169 | return argumentsGettercxx . . $ QTJSC/JSActivation#argumentsGetter(2d50ae1b8ebdc06b).; |
| 170 | } |
| 171 | |
| 172 | } // namespace JSC |