Changeset 33979 in webkit for trunk/JavaScriptCore/kjs/ExecState.h
- Timestamp:
- May 21, 2008, 6:20:45 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/ExecState.h
r33038 r33979 33 33 namespace KJS { 34 34 35 class ActivationImp;36 35 class CommonIdentifiers; 37 36 class EvalNode; … … 43 42 class JSGlobalObject; 44 43 class JSVariableObject; 44 class Machine; 45 45 class ProgramNode; 46 class RegisterFile; 46 47 class ScopeNode; 48 49 struct Instruction; 47 50 48 enum CodeType { GlobalCode, EvalCode, FunctionCode };49 50 51 struct PerThreadData { 51 52 const HashTable* arrayTable; … … 64 65 // Passed as the first argument to most functions. 65 66 class ExecState : Noncopyable { 66 friend class JSGlobalObject; 67 friend class Machine; 68 friend class DebuggerCallFrame; 69 67 70 public: 68 // Global object that was in scope when the current script started executing. 71 ExecState(JSGlobalObject*, JSObject* globalThisValue, ScopeChainNode* globalScopeChain); 72 73 // Global object in which execution began. 69 74 JSGlobalObject* dynamicGlobalObject() const { return m_globalObject; } 70 75 71 // Global object that was in scope when the current body of code was defined. 72 JSGlobalObject* lexicalGlobalObject() const; 73 76 // Global object in which the current script was defined. (Can differ 77 // from dynamicGlobalObject() during function calls across frames.) 78 JSGlobalObject* lexicalGlobalObject() const 79 { 80 return m_scopeChain->globalObject(); 81 } 82 83 JSObject* globalThisValue() const { return m_globalThisValue; } 84 85 Machine* machine() const { return m_machine; } 86 87 // Exception propogation. 74 88 void setException(JSValue* exception) { m_exception = exception; } 75 89 void clearException() { m_exception = 0; } … … 77 91 JSValue** exceptionSlot() { return &m_exception; } 78 92 bool hadException() const { return !!m_exception; } 79 JSValue* takeException() { JSValue* exception = m_exception; m_exception = 0; return exception; }80 81 const ScopeChain& scopeChain() const { return m_scopeChain; }82 void pushScope(JSObject* s) { m_scopeChain.push(s); }83 void popScope() { m_scopeChain.pop(); }84 void replaceScopeChainTop(JSObject* o) { m_scopeChain.replaceTop(o); }85 86 JSVariableObject* variableObject() const { return m_variableObject; }87 void setVariableObject(JSVariableObject* v) { m_variableObject = v; }88 89 JSObject* thisValue() const { return m_thisValue; }90 JSObject* globalThisValue() const { return m_globalThisValue; }91 92 ExecState* callingExecState() { return m_callingExec; }93 94 ActivationImp* activationObject() { return m_activation; }95 void setActivationObject(ActivationImp* a) { m_activation = a; }96 CodeType codeType() { return m_codeType; }97 ScopeNode* scopeNode() { return m_scopeNode; }98 FunctionImp* function() const { return m_function; }99 const List* arguments() const { return m_arguments; }100 101 LabelStack& seenLabels() { return m_labelStack; }102 103 void pushIteration() { m_iterationDepth++; }104 void popIteration() { m_iterationDepth--; }105 bool inIteration() const { return (m_iterationDepth > 0); }106 107 void pushSwitch() { m_switchDepth++; }108 void popSwitch() { m_switchDepth--; }109 bool inSwitch() const { return (m_switchDepth > 0); }110 93 111 94 // These pointers are used to avoid accessing global variables for these, … … 121 104 static const HashTable* stringTable(ExecState* exec) { return exec->m_perThreadData->stringTable; } 122 105 123 LocalStorage& localStorage() { return *m_localStorage; } 124 void setLocalStorage(LocalStorage* s) { m_localStorage = s; } 106 private: 107 ExecState(ExecState*, Machine*, RegisterFile*, ScopeChainNode*, int callFrameOffset); 108 109 bool isGlobalObject(JSObject*) const; 110 111 JSGlobalObject* m_globalObject; 112 JSObject* m_globalThisValue; 113 114 JSValue* m_exception; 115 116 const PerThreadData* m_perThreadData; 117 118 // These values are controlled by the machine. 119 ExecState* m_prev; 120 Machine* m_machine; 121 RegisterFile* m_registerFile; 122 ScopeChainNode* m_scopeChain; 123 int m_callFrameOffset; // A negative offset indicates a non-function scope. 124 }; 125 126 // This code is now defunct: 127 128 enum CodeType { GlobalCode, EvalCode, FunctionCode }; 129 class OldInterpreterExecState : public ExecState { 130 public: 131 void pushSwitch() { m_switchDepth++; } 132 void popSwitch() { m_switchDepth--; } 133 bool inSwitch() const { return (m_switchDepth > 0); } 125 134 126 135 // These are only valid right after calling execute(). … … 185 194 return 0; 186 195 } 187 188 protected: 189 ExecState(JSGlobalObject*, JSObject* thisObject); 190 ExecState(JSGlobalObject*, JSObject* thisObject, ProgramNode*); 191 ExecState(JSGlobalObject*, JSObject* thisObject, EvalNode*, ExecState* callingExecState, const ScopeChain&, JSVariableObject*); 192 ExecState(JSGlobalObject*, JSObject* thisObject, JSObject* globalThisValue, FunctionBodyNode*, ExecState* callingExecState, FunctionImp*, const List& args); 193 ~ExecState(); 194 195 // ExecStates are always stack-allocated, and the garbage collector 196 // marks the stack, so we don't need to protect the objects below from GC. 197 198 JSGlobalObject* m_globalObject; 199 JSValue* m_exception; 200 201 ExecState* m_callingExec; 202 203 const PerThreadData* m_perThreadData; 204 205 ScopeNode* m_scopeNode; 206 207 FunctionImp* m_function; 208 const List* m_arguments; 209 ActivationImp* m_activation; 210 LocalStorage* m_localStorage; 211 212 ScopeChain m_scopeChain; 213 ScopeChainNode m_inlineScopeChainNode; 214 JSVariableObject* m_variableObject; 215 216 JSObject* m_thisValue; 217 JSObject* m_globalThisValue; 218 219 LabelStack m_labelStack; 220 int m_iterationDepth; 196 CodeType codeType() { return m_codeType; } 197 void pushIteration() { m_iterationDepth++; } 198 void popIteration() { m_iterationDepth--; } 199 bool inIteration() const { return (m_iterationDepth > 0); } 200 LabelStack& seenLabels() { return m_labelStack; } 201 void pushScope(JSObject* s) { m_scopeChain.push(s); } 202 void popScope() { m_scopeChain.pop(); } 203 JSVariableObject* variableObject() const { ASSERT_NOT_REACHED(); return m_variableObject; } 204 void setVariableObject(JSVariableObject* v) { m_variableObject = v; } 205 ExecState* callingExecState() { return m_callingExec; } 206 ScopeNode* scopeNode() { return m_scopeNode; } 207 const List* arguments() const { return m_arguments; } 208 FunctionImp* function() const { return m_function; } 209 LocalStorage& localStorage() { ASSERT_NOT_REACHED(); return *(LocalStorage*)0; } 210 void setLocalStorage(LocalStorage*) { ASSERT_NOT_REACHED(); } 211 ScopeChain& scopeChain() { return m_scopeChain; } 212 JSObject* thisValue() const { return m_thisValue; } 213 214 ComplType m_completionType; 215 const Identifier* m_breakOrContinueTarget; 221 216 int m_switchDepth; 222 217 CodeType m_codeType; 223 224 ComplType m_completionType; 225 const Identifier* m_breakOrContinueTarget; 218 int m_iterationDepth; 219 LabelStack m_labelStack; 220 ScopeChainNode m_inlineScopeChainNode; 221 ScopeChain m_scopeChain; 222 JSVariableObject* m_variableObject; 223 ScopeNode* m_scopeNode; 224 const List* m_arguments; 225 FunctionImp* m_function; 226 ExecState* m_callingExec; 227 JSObject* m_thisValue; 226 228 }; 227 229 228 class GlobalExecState : public ExecState {229 public:230 GlobalExecState(JSGlobalObject*, JSObject* thisObject);231 ~GlobalExecState();232 };233 234 class InterpreterExecState : public ExecState {235 public:236 InterpreterExecState(JSGlobalObject*, JSObject* thisObject, ProgramNode*);237 ~InterpreterExecState();238 };239 240 class EvalExecState : public ExecState {241 public:242 EvalExecState(JSGlobalObject*, JSObject* thisObj, EvalNode*, ExecState* callingExec, const ScopeChain&, JSVariableObject*);243 ~EvalExecState();244 };245 246 class FunctionExecState : public ExecState {247 public:248 FunctionExecState(JSGlobalObject*, JSObject* thisObject, JSObject* globalThisValue, FunctionBodyNode*,249 ExecState* callingExecState, FunctionImp*, const List& args);250 ~FunctionExecState();251 };252 253 230 } // namespace KJS 254 231
Note:
See TracChangeset
for help on using the changeset viewer.