Changeset 27097 in webkit for trunk/JavaScriptCore/kjs/ExecState.cpp
- Timestamp:
- Oct 26, 2007, 1:32:40 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/ExecState.cpp
r27027 r27097 23 23 */ 24 24 25 #include "context.h" 25 #include "config.h" 26 #include "ExecState.h" 27 26 28 #include "JSGlobalObject.h" 27 #include "ExecState.h"28 29 #include "internal.h" 29 30 30 31 namespace KJS { 32 33 34 // ECMA 10.2 35 Context::Context(JSGlobalObject* glob, Interpreter* interpreter, JSObject* thisV, 36 FunctionBodyNode* currentBody, CodeType type, Context* callingCon, 37 FunctionImp* func, const List* args) 38 : m_interpreter(interpreter) 39 , m_savedContext(interpreter->context()) 40 , m_currentBody(currentBody) 41 , m_function(func) 42 , m_arguments(args) 43 , m_iterationDepth(0) 44 , m_switchDepth(0) 45 { 46 m_codeType = type; 47 m_callingContext = callingCon; 48 49 // create and initialize activation object (ECMA 10.1.6) 50 if (type == FunctionCode) { 51 m_activation = new ActivationImp(func, *args); 52 m_variable = m_activation; 53 } else { 54 m_activation = 0; 55 m_variable = glob; 56 } 57 58 // ECMA 10.2 59 switch(type) { 60 case EvalCode: 61 if (m_callingContext) { 62 scope = m_callingContext->scopeChain(); 63 m_variable = m_callingContext->variableObject(); 64 m_thisVal = m_callingContext->thisValue(); 65 break; 66 } // else same as GlobalCode 67 case GlobalCode: 68 scope.clear(); 69 scope.push(glob); 70 m_thisVal = static_cast<JSObject*>(glob); 71 break; 72 case FunctionCode: 73 scope = func->scope(); 74 scope.push(m_activation); 75 m_variable = m_activation; // TODO: DontDelete ? (ECMA 10.2.3) 76 m_thisVal = thisV; 77 break; 78 } 79 80 m_interpreter->setContext(this); 81 } 82 83 Context::~Context() 84 { 85 m_interpreter->setContext(m_savedContext); 86 87 // The arguments list is only needed to potentially create the arguments object, 88 // which isn't accessible from nested scopes so we can discard the list as soon 89 // as the function is done running. 90 // This prevents lists of Lists from building up, waiting to be garbage collected 91 ActivationImp* activation = static_cast<ActivationImp*>(m_activation); 92 if (activation) 93 activation->releaseArguments(); 94 } 95 96 void Context::mark() 97 { 98 for (Context* context = this; context; context = context->m_callingContext) 99 context->scope.mark(); 100 } 31 101 32 102 Interpreter* ExecState::lexicalInterpreter() const
Note:
See TracChangeset
for help on using the changeset viewer.