Changeset 29810 in webkit for trunk/JavaScriptCore/kjs/nodes.cpp


Ignore:
Timestamp:
Jan 26, 2008, 10:55:52 AM (17 years ago)
Author:
Darin Adler
Message:

Reviewed by Eric Seidel.

  • JavaScriptCore.exp: Export the GlobalExecState constructor instead of the global flavor of the ExecState constructor. It'd probably be cleaner to not export either one, but JSGlobalObject inlines the code that constructs the ExecState. If we changed that, we could remove this export.
  • JavaScriptCore.xcodeproj/project.pbxproj: Re-sorted a few things and put the new source files into the kjs group rather than at the top level.
  • kjs/ExecState.cpp: (KJS::ExecState::ExecState): Marked inline and updated for data member name changes. This is now only for use for the derived classes. Also removed code that sets the unused m_savedExec data member for the global case. That data member is only used for the other two types. (KJS::ExecState::~ExecState): Marked inline and removed all the code. The derived class destructors now inclde the appropriate code. (KJS::ExecState::lexicalGlobalObject): Removed unneeded special case for an empty scope chain. The bottom function already returns 0 for that case, so the general case code handles it fine. Also changed to use data members directly rather than calling functions. (KJS::GlobalExecState::GlobalExecState): Added. Calls through to the base class constructor. (KJS::GlobalExecState::~GlobalExecState): Added. (KJS::InterpreterExecState::InterpreterExecState): Added. Moved code to manipulate activeExecStates here since we don't want to have to check for the special case of globalExec. (KJS::InterpreterExecState::~InterpreterExecState): Added. (KJS::EvalExecState::EvalExecState): Added. (KJS::EvalExecState::~EvalExecState): Added. (KJS::FunctionExecState::FunctionExecState): Added. (KJS::FunctionExecState::~FunctionExecState): Added.
  • kjs/ExecState.h: Tweaked the header, includes, and declarations a bit. Made ExecState inherit from Noncopyable. Reformatted some comments and made them a bit more brief. Rearranged declarations a little bit and removed unused savedExec function. Changed seenLabels function to return a reference rather than a pointer. Made constructors and destructor protected, and also did the same with all data members. Renamed m_thisVal to m_thisValue and ls to m_labelStack. Added three new derived classes for each of the types of ExecState. The primary goal here was to remove a branch from the code in the destructor, but it's also clearer than overloading the arguments to the ExecState constructor.
  • kjs/JSGlobalObject.cpp: (KJS::getCurrentTime): Fixed formatting. (KJS::JSGlobalObject::pushActivation): Removed parentheses that don't make the expression clearer -- other similar sites didn't have these parentheses, even the one a couple lines earlier that sets stackEntry. (KJS::JSGlobalObject::tearOffActivation): Got rid of unneeded static_cast (I think I mentioned this during patch review) and used an early exit so that the entire contents of the function aren't nested inside an if statement. Also removed the check of codeType, instead checking Activation for 0. For now, I kept the codeType check, but inside an assertion.
  • kjs/JSGlobalObject.h: Changed type of globalExec to GlobalExecState.
  • kjs/function.cpp: (KJS::FunctionImp::callAsFunction): Changed type to FunctionExecState. (KJS::GlobalFuncImp::callAsFunction): Changed type to EvalExecState.
  • kjs/interpreter.cpp: (KJS::Interpreter::evaluate): Changed type to GlobalExecState.
  • kjs/nodes.cpp: (KJS::ContinueNode::execute): Changed code since seenLabels() returns a reference now instead of a pointer. (KJS::BreakNode::execute): Ditto. (KJS::LabelNode::execute): Ditto.
File:
1 edited

Legend:

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

    r29428 r29810  
    10141014      KJS_CHECKEXCEPTIONVALUE
    10151015       
    1016       JSObject *thisObj = base;
     1016      JSObject* thisObj = base;
    10171017      // ECMA 11.2.3 says that in this situation the this value should be null.
    10181018      // However, section 10.2.3 says that in the case where the value provided
    10191019      // by the caller is null, the global object should be used. It also says
    1020       // that the section does not apply to interal functions, but for simplicity
     1020      // that the section does not apply to internal functions, but for simplicity
    10211021      // of implementation we use the global object anyway here. This guarantees
    10221022      // that in host objects you always get a valid object for this.
     
    39543954  if (ident.isEmpty() && !exec->inIteration())
    39553955    return setErrorCompletion(exec, SyntaxError, "Invalid continue statement.");
    3956   if (!ident.isEmpty() && !exec->seenLabels()->contains(ident))
     3956  if (!ident.isEmpty() && !exec->seenLabels().contains(ident))
    39573957    return setErrorCompletion(exec, SyntaxError, "Label %s not found.", ident);
    39583958  return exec->setContinueCompletion(&ident);
     
    39663966  if (ident.isEmpty() && !exec->inIteration() && !exec->inSwitch())
    39673967    return setErrorCompletion(exec, SyntaxError, "Invalid break statement.");
    3968   if (!ident.isEmpty() && !exec->seenLabels()->contains(ident))
     3968  if (!ident.isEmpty() && !exec->seenLabels().contains(ident))
    39693969    return setErrorCompletion(exec, SyntaxError, "Label %s not found.");
    39703970  return exec->setBreakCompletion(&ident);
     
    41614161JSValue* LabelNode::execute(ExecState *exec)
    41624162{
    4163   if (!exec->seenLabels()->push(label))
     4163  if (!exec->seenLabels().push(label))
    41644164    return setErrorCompletion(exec, SyntaxError, "Duplicated label %s found.", label);
    41654165  JSValue* result = statement->execute(exec);
    4166   exec->seenLabels()->pop();
     4166  exec->seenLabels().pop();
    41674167
    41684168  if (exec->completionType() == Break && exec->breakOrContinueTarget() == label)
Note: See TracChangeset for help on using the changeset viewer.