Changeset 29710 in webkit for trunk/JavaScriptCore/kjs/ExecState.cpp
- Timestamp:
- Jan 21, 2008, 10:18:10 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/ExecState.cpp
r29542 r29710 42 42 // ECMA 10.2 43 43 44 // The constructor for the globalExec pseudo-ExecState 45 ExecState::ExecState(JSGlobalObject* globalObject) 46 : m_globalObject(globalObject) 47 , m_exception(0) 48 , m_propertyNames(CommonIdentifiers::shared()) 49 , m_emptyList(globalEmptyList()) 50 , m_callingExec(0) 51 , m_scopeNode(0) 52 , m_function(0) 53 , m_arguments(0) 54 , m_activation(0) 55 , m_localStorage(&globalObject->localStorage()) 56 , m_variableObject(globalObject) 57 , m_thisVal(globalObject) 58 , m_iterationDepth(0) 59 , m_switchDepth(0) 60 , m_codeType(GlobalCode) 61 { 62 m_scopeChain.push(globalObject); 63 } 64 44 65 ExecState::ExecState(JSGlobalObject* globalObject, JSObject* /*thisObject*/, ProgramNode* programNode) 45 66 : m_globalObject(globalObject) … … 48 69 , m_emptyList(globalEmptyList()) 49 70 , m_callingExec(0) 50 , m_savedExec(0)51 71 , m_scopeNode(programNode) 52 72 , m_function(0) … … 63 83 // a script with a this object that's not the same as the global object is broken, and probably 64 84 // has been for some time. 85 ASSERT(m_scopeNode); 86 activeExecStates().append(this); 65 87 m_scopeChain.push(globalObject); 66 if (programNode)67 globalObject->setCurrentExec(this);68 88 } 69 89 … … 74 94 , m_emptyList(callingExec->m_emptyList) 75 95 , m_callingExec(callingExec) 76 , m_savedExec(globalObject->currentExec())77 96 , m_scopeNode(evalNode) 78 97 , m_function(0) … … 87 106 , m_codeType(EvalCode) 88 107 { 89 globalObject->setCurrentExec(this); 108 ASSERT(m_scopeNode); 109 activeExecStates().append(this); 90 110 } 91 111 … … 98 118 , m_emptyList(callingExec->m_emptyList) 99 119 , m_callingExec(callingExec) 100 , m_savedExec(globalObject->currentExec())101 120 , m_scopeNode(functionBodyNode) 102 121 , m_function(func) … … 108 127 , m_codeType(FunctionCode) 109 128 { 129 ASSERT(m_scopeNode); 130 activeExecStates().append(this); 131 110 132 ActivationImp* activation = globalObject->pushActivation(this); 111 133 m_activation = activation; … … 113 135 m_variableObject = activation; 114 136 m_scopeChain.push(activation); 115 globalObject->setCurrentExec(this);116 137 } 117 138 118 139 ExecState::~ExecState() 119 140 { 120 if (m_codeType == FunctionCode && m_activation->needsPop()) 141 ASSERT(m_scopeNode && activeExecStates().last() == this || !m_scopeNode); 142 if (m_scopeNode) 143 activeExecStates().removeLast(); 144 145 if (m_activation && m_activation->needsPop()) 121 146 m_globalObject->popActivation(); 122 123 m_globalObject->setCurrentExec(m_savedExec);124 }125 126 void ExecState::mark()127 {128 for (ExecState* exec = this; exec; exec = exec->m_callingExec) {129 exec->m_scopeChain.mark();130 131 if (exec->m_savedExec != exec->m_callingExec && exec->m_savedExec)132 exec->m_savedExec->mark();133 }134 147 } 135 148 … … 146 159 } 147 160 161 void ExecState::markActiveExecStates() 162 { 163 ExecStateStack::const_iterator end = activeExecStates().end(); 164 for (ExecStateStack::const_iterator it = activeExecStates().begin(); it != end; ++it) 165 (*it)->m_scopeChain.mark(); 166 } 167 168 ExecStateStack& ExecState::activeExecStates() 169 { 170 static ExecStateStack staticActiveExecStates; 171 return staticActiveExecStates; 172 } 173 148 174 } // namespace KJS
Note:
See TracChangeset
for help on using the changeset viewer.