Ignore:
Timestamp:
Oct 26, 2007, 1:32:40 AM (18 years ago)
Author:
mjs
Message:

JavaScriptCore:

Reviewed by Oliver.


  • moved Context class into ExecState.{h,cpp} in preparation for merging ExecState and Context classes.
  • kjs/ExecState.h: Moved CodeType enum and Context class here in preparation for merging ExecState and Context.
  • kjs/ExecState.cpp: Moved Context class here from Context.cpp. (KJS::Context::Context): (KJS::Context::~Context): (KJS::Context::mark):
  • kjs/context.h: Removed.
  • kjs/Context.cpp: Removed.
  • kjs/function.h: Removed CodeType enum.
  • kjs/LabelStack.h: Added. Pulled LabelStack class out of internal.h.
  • kjs/internal.h: Removed LabelStack.
  • JavaScriptCore.xcodeproj/project.pbxproj: Added new file, removed ones that are gone.
  • kjs/collector.cpp: Fixed includes.
  • kjs/function.cpp: ditto
  • kjs/internal.cpp: ditto
  • kjs/interpreter.cpp: ditto
  • kjs/lookup.h: ditto
  • kjs/nodes.cpp: ditto

WebCore:

Reviewed by Oliver.

  • bindings/objc/WebScriptObject.mm:
  • bridge/mac/WebCoreScriptDebugger.mm:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/ExecState.cpp

    r27027 r27097  
    2323 */
    2424
    25 #include "context.h"
     25#include "config.h"
     26#include "ExecState.h"
     27
    2628#include "JSGlobalObject.h"
    27 #include "ExecState.h"
    2829#include "internal.h"
    2930
    3031namespace KJS {
     32
     33
     34// ECMA 10.2
     35Context::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
     83Context::~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
     96void Context::mark()
     97{
     98    for (Context* context = this; context; context = context->m_callingContext)
     99        context->scope.mark();
     100}
    31101
    32102Interpreter* ExecState::lexicalInterpreter() const
Note: See TracChangeset for help on using the changeset viewer.