Changeset 37297 in webkit for trunk/JavaScriptCore/kjs/ExecState.h
- Timestamp:
- Oct 4, 2008, 2:12:54 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/ExecState.h
r37257 r37297 30 30 namespace JSC { 31 31 32 class ExecState; 32 33 class JSValue; 33 34 class Register; 34 35 36 typedef ExecState CallFrame; 37 35 38 // Represents the current state of script execution. 36 39 // Passed as the first argument to most functions. 37 class ExecState : Noncopyable { 38 #if ENABLE(CTI) 39 friend class CTI; 40 #endif 41 friend class Machine; 42 friend class DebuggerCallFrame; 40 class ExecState : private Register, Noncopyable { 43 41 public: 44 explicit ExecState(Register* callFrame) 45 : m_exception(0) 46 , m_callFrame(callFrame) 42 static CallFrame* create(Register* callFrameBase) { return static_cast<CallFrame*>(callFrameBase); } 43 Register* registers() { return this; } 44 45 // Global object in which execution began. 46 JSGlobalObject* dynamicGlobalObject() 47 47 { 48 return Machine::scopeChain(Machine::firstCallFrame(this))->globalObject(); 48 49 } 49 50 50 // Global object in which execution began. 51 JSGlobalObject* dynamicGlobalObject() const 51 // Global object in which the currently executing code was defined. 52 // Differs from dynamicGlobalObject() during function calls across web browser frames. 53 JSGlobalObject* lexicalGlobalObject() 52 54 { 53 return Machine::scopeChain( Machine::firstCallFrame(m_callFrame))->globalObject();55 return Machine::scopeChain(this)->globalObject(); 54 56 } 55 57 56 // Global object in which the current script was defined. (Can differ57 // from dynamicGlobalObject() during function calls across frames.)58 JS GlobalObject* lexicalGlobalObject() const58 // Differs from lexicalGlobalObject because this will have DOM window shell rather than 59 // the actual DOM window. 60 JSObject* globalThisValue() 59 61 { 60 return Machine::scopeChain( m_callFrame)->globalObject();62 return Machine::scopeChain(this)->globalThisObject(); 61 63 } 62 64 63 JS Object* globalThisValue() const65 JSGlobalData& globalData() 64 66 { 65 return Machine::scopeChain(m_callFrame)->globalThisObject();67 return *Machine::scopeChain(this)->globalData; 66 68 } 67 69 68 // Exception propogation. 69 void setException(JSValue* exception) { m_exception = exception; } 70 void clearException() { m_exception = 0; } 71 JSValue* exception() const { return m_exception; } 72 JSValue** exceptionSlot() { return &m_exception; } 73 bool hadException() const { return !!m_exception; } 74 #if ENABLE(CTI) 75 void setCTIReturnAddress(void* ctiRA) { m_ctiReturnAddress = ctiRA; } 76 void* ctiReturnAddress() const { return m_ctiReturnAddress; } 77 #endif 70 // Convenience functions for access to global data. 78 71 79 JSGlobalData& globalData() const 80 { 81 return *Machine::scopeChain(m_callFrame)->globalData; 82 } 72 void setException(JSValue* exception) { globalData().exception = exception; } 73 void clearException() { globalData().exception = 0; } 74 JSValue* exception() { return globalData().exception; } 75 JSValue** exceptionSlot() { return &globalData().exception; } 76 bool hadException() { return !!globalData().exception; } 83 77 84 78 IdentifierTable* identifierTable() { return globalData().identifierTable; } 85 const CommonIdentifiers& propertyNames() const{ return *globalData().propertyNames; }86 const ArgList& emptyList() const{ return *globalData().emptyList; }79 const CommonIdentifiers& propertyNames() { return *globalData().propertyNames; } 80 const ArgList& emptyList() { return *globalData().emptyList; } 87 81 Lexer* lexer() { return globalData().lexer; } 88 82 Parser* parser() { return globalData().parser; } 89 Machine* machine() const { return globalData().machine; } 90 static const HashTable* arrayTable(ExecState* exec) { return exec->globalData().arrayTable; } 91 static const HashTable* dateTable(ExecState* exec) { return exec->globalData().dateTable; } 92 static const HashTable* mathTable(ExecState* exec) { return exec->globalData().mathTable; } 93 static const HashTable* numberTable(ExecState* exec) { return exec->globalData().numberTable; } 94 static const HashTable* regExpTable(ExecState* exec) { return exec->globalData().regExpTable; } 95 static const HashTable* regExpConstructorTable(ExecState* exec) { return exec->globalData().regExpConstructorTable; } 96 static const HashTable* stringTable(ExecState* exec) { return exec->globalData().stringTable; } 83 Machine* machine() { return globalData().machine; } 84 Heap* heap() { return &globalData().heap; } 97 85 98 Heap* heap() const { return &globalData().heap; } 86 static const HashTable* arrayTable(CallFrame* callFrame) { return callFrame->globalData().arrayTable; } 87 static const HashTable* dateTable(CallFrame* callFrame) { return callFrame->globalData().dateTable; } 88 static const HashTable* mathTable(CallFrame* callFrame) { return callFrame->globalData().mathTable; } 89 static const HashTable* numberTable(CallFrame* callFrame) { return callFrame->globalData().numberTable; } 90 static const HashTable* regExpTable(CallFrame* callFrame) { return callFrame->globalData().regExpTable; } 91 static const HashTable* regExpConstructorTable(CallFrame* callFrame) { return callFrame->globalData().regExpConstructorTable; } 92 static const HashTable* stringTable(CallFrame* callFrame) { return callFrame->globalData().stringTable; } 99 93 100 94 private: 101 // Default constructor required for gcc 3. 102 ExecState() { } 103 104 bool isGlobalObject(JSObject*) const; 105 106 JSValue* m_exception; 107 #if ENABLE(CTI) 108 void* m_ctiReturnAddress; 109 #endif 110 Register* m_callFrame; // The most recent call frame. 95 ExecState(); 96 ~ExecState(); 111 97 }; 112 98
Note:
See TracChangeset
for help on using the changeset viewer.