- roll out that last change -- it was causing test failures;
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Dec 2007 20:33:42 +0000 (20:33 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Dec 2007 20:33:42 +0000 (20:33 +0000)
          I'll check it back in after fixing them

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28899 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
JavaScriptCore/API/JSContextRef.cpp
JavaScriptCore/ChangeLog
JavaScriptCore/bindings/runtime_method.cpp
JavaScriptCore/bindings/runtime_method.h
JavaScriptCore/kjs/ExecState.h
JavaScriptCore/kjs/array_instance.cpp
JavaScriptCore/kjs/completion.h
JavaScriptCore/kjs/date_object.h
JavaScriptCore/kjs/function.cpp
JavaScriptCore/kjs/function.h
JavaScriptCore/kjs/interpreter.cpp
JavaScriptCore/kjs/nodes.cpp
JavaScriptCore/kjs/nodes.h
JavaScriptCore/kjs/number_object.h

index 203326e251f64e51f5364495abc115796e31970b..4fa1c8cbe1368c034d43d599c0a83e04c20028c5 100644 (file)
@@ -31,6 +31,7 @@
 #include "JSCallbackObject.h"
 #include "JSClassRef.h"
 #include "JSGlobalObject.h"
+#include "completion.h"
 #include "object.h"
 #include <wtf/Platform.h>
 
index 74546a5b18cd7cf4df66cf0f899e5cf49184d4e2..11a8cd4ebbd0bd514127a8b125826449b9597639 100644 (file)
@@ -1,3 +1,8 @@
+2007-12-20  Darin Adler  <darin@apple.com>
+
+        - roll out that last change -- it was causing test failures;
+          I'll check it back in after fixing them
+
 2007-12-20  Darin Adler  <darin@apple.com>
 
         Reviewed by Eric.
index c3c69001174cb9603c4e05a7e5a1f29151e41c5f..50ae64e7c7a89ccc5a2d4abf7a0da878018adc16 100644 (file)
@@ -92,3 +92,8 @@ JSValue *RuntimeMethod::callAsFunction(ExecState *exec, JSObject *thisObj, const
     instance->end();
     return aValue;
 }
+
+Completion RuntimeMethod::execute(ExecState*)
+{
+    return Completion(Normal, jsUndefined());
+}
index 7fbe32a5a3b99cfee47dd0b3b15ea8f4f7caea1e..3fda886665efbf321eee40115b44d2010ebf2ad9 100644 (file)
@@ -32,7 +32,9 @@
 
 namespace KJS {
 
-class RuntimeMethod : public InternalFunctionImp {
+
+class RuntimeMethod : public InternalFunctionImp 
+{
 public:
     RuntimeMethod(ExecState *exec, const Identifier &n, Bindings::MethodList &methodList);
     
@@ -40,6 +42,8 @@ public:
 
     virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
 
+    virtual Completion execute(ExecState *exec);
+
 private:
     static JSValue *lengthGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
 
index c92c598cfff7f5704d2d46ec8c8bfa3a79e6c30a..277e5d0f1fa26f02106c2a32579a1d1b06333647 100644 (file)
@@ -108,69 +108,7 @@ namespace KJS  {
         const CommonIdentifiers& propertyNames() const { return *m_propertyNames; }
 
         LocalStorage& localStorage() { return *m_localStorage; }
-
-        // These are only valid right after calling execute().
-        ComplType completionType() const { return m_completionType; }
-        const Identifier& breakOrContinueTarget() const
-        {
-            ASSERT(m_completionType == Break || m_completionType == Continue);
-            return *m_breakOrContinueTarget;
-        }
-
-        // Only for use in the implementation of execute().
-        void setCompletionType(ComplType type)
-        {
-            ASSERT(type != Break);
-            ASSERT(type != Continue);
-            m_completionType = type;
-        }
-        JSValue* setNormalCompletion()
-        {
-            ASSERT(!hadException());
-            m_completionType = Normal;
-            return 0;
-        }
-        JSValue* setNormalCompletion(JSValue* value)
-        {
-            ASSERT(!hadException());
-            m_completionType = Normal;
-            return value;
-        }
-        JSValue* setBreakCompletion(const Identifier* target)
-        {
-            ASSERT(!hadException());
-            m_completionType = Break;
-            m_breakOrContinueTarget = target;
-            return 0;
-        }
-        JSValue* setContinueCompletion(const Identifier* target)
-        {
-            ASSERT(!hadException());
-            m_completionType = Continue;
-            m_breakOrContinueTarget = target;
-            return 0;
-        }
-        JSValue* setReturnValueCompletion(JSValue* returnValue)
-        {
-            ASSERT(!hadException());
-            ASSERT(returnValue);
-            m_completionType = ReturnValue;
-            return returnValue;
-        }
-        JSValue* setThrowCompletion(JSValue* exception)
-        {
-            ASSERT(!hadException());
-            ASSERT(exception);
-            m_completionType = Throw;
-            return exception;
-        }
-        JSValue* setInterruptedCompletion()
-        {
-            ASSERT(!hadException());
-            m_completionType = Interrupted;
-            return 0;
-        }
-
+    
     public:
         ExecState(JSGlobalObject* glob, JSObject* thisV,
                   ScopeNode* scopeNode, CodeType type = GlobalCode,
@@ -203,9 +141,6 @@ namespace KJS  {
         int m_iterationDepth;
         int m_switchDepth;
         CodeType m_codeType;
-
-        ComplType m_completionType;
-        const Identifier* m_breakOrContinueTarget;
     };
 
 } // namespace KJS
index 49c728ec844f6a51d6f4eb20ed4ca7d79132aa51..a9bca3c0d7e741e9817c61818c40c082db204858 100644 (file)
@@ -180,7 +180,7 @@ bool ArrayInstance::getOwnPropertySlot(ExecState* exec, const Identifier& proper
 
 bool ArrayInstance::getOwnPropertySlot(ExecState* exec, unsigned i, PropertySlot& slot)
 {
-    return inlineGetOwnPropertySlot(exec, i, slot);
+    return JSObject::getOwnPropertySlot(exec, i, slot);
 }
 
 // ECMA 15.4.5.1
index 09f3db79bb3e7157ce28ebf556f16714a02f40c2..dd647d0ce229c12a611199c9661ba532b0a2c7c5 100644 (file)
@@ -26,6 +26,7 @@
 
 namespace KJS {
 
+  class Identifier;
   class JSValue;
 
   enum ComplType { Normal, Break, Continue, ReturnValue, Throw, Interrupted };
@@ -43,16 +44,20 @@ namespace KJS {
   class Completion {
   public:
     Completion(ComplType type = Normal, JSValue* value = 0)
-        : m_type(type), m_value(value) { }
+        : m_type(type), m_value(value), m_target(0) { }
+    Completion(ComplType type, const Identifier* target)
+        : m_type(type), m_value(0), m_target(target) { }
 
     ComplType complType() const { return m_type; }
     JSValue* value() const { return m_value; }
     void setValue(JSValue* v) { m_value = v; }
+    const Identifier& target() const { return *m_target; }
     bool isValueCompletion() const { return !!m_value; }
 
   private:
     ComplType m_type;
     JSValue* m_value;
+    const Identifier* m_target;
   };
 
 }
index bac3a3c8d8355ceca6dc9851ecdfc10bef9aa8d1..6c38e921b51b54ded85e235d53b18d53e14b1773 100644 (file)
@@ -132,6 +132,7 @@ FOR_EACH_CLASS(KJS_IMPLEMENT_PROTOTYPE_FUNCTION_WITH_CREATE)
         virtual JSObject *construct(ExecState *, const List &args);
         virtual JSValue *callAsFunction(ExecState *, JSObject *thisObj, const List &args);
 
+        Completion execute(const List &);
         JSObject *construct(const List &);
     };
 
index 627dd3c230d7437fbe3cd995b5ce82acd717d30c..04b9afaa496494bd4a4315496413c9de17ed9fc5 100644 (file)
@@ -70,14 +70,24 @@ void FunctionImp::mark()
 
 JSValue* FunctionImp::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
 {
-    ExecState newExec(exec->dynamicGlobalObject(), thisObj, body.get(), FunctionCode, exec, exec->dynamicGlobalObject()->currentExec(), this, &args);
-    JSValue* result = body->execute(&newExec);
-    if (newExec.completionType() == Throw) {
-        exec->setException(result);
-        return result;
-    }
-    if (newExec.completionType() == ReturnValue)
-        return result;
+  // enter a new execution context
+  ExecState newExec(exec->dynamicGlobalObject(), thisObj, body.get(), FunctionCode, exec, exec->dynamicGlobalObject()->currentExec(), this, &args);
+  if (exec->hadException())
+    newExec.setException(exec->exception());
+
+  Completion comp = execute(&newExec);
+
+  // if an exception occured, propogate it back to the previous execution object
+  if (newExec.hadException())
+    comp = Completion(Throw, newExec.exception());
+
+  if (comp.complType() == Throw) {
+    exec->setException(comp.value());
+    return comp.value();
+  }
+  else if (comp.complType() == ReturnValue)
+    return comp.value();
+  else
     return jsUndefined();
 }
 
@@ -204,6 +214,15 @@ JSObject* FunctionImp::construct(ExecState* exec, const List& args)
     return obj;
 }
 
+Completion FunctionImp::execute(ExecState* exec)
+{
+  Completion result = body->execute(exec);
+
+  if (result.complType() == Throw || result.complType() == ReturnValue)
+      return result;
+  return Completion(Normal, jsUndefined()); // TODO: or ReturnValue ?
+}
+
 // ------------------------------ IndexToNameMap ---------------------------------
 
 // We map indexes in the arguments array to their corresponding argument names. 
@@ -699,21 +718,30 @@ JSValue* GlobalFuncImp::callAsFunction(ExecState* exec, JSObject* thisObj, const
         JSGlobalObject* globalObject = switchGlobal ? static_cast<JSGlobalObject*>(thisObj) : exec->dynamicGlobalObject();
         JSObject* thisVal = static_cast<JSObject*>(exec->thisValue());
         ExecState newExec(globalObject, thisVal, evalNode.get(), EvalCode, exec, globalObject->currentExec());
+        if (exec->hadException())
+            newExec.setException(exec->exception());
           
         if (switchGlobal) {
             newExec.pushScope(thisObj);
             newExec.setVariableObject(static_cast<JSGlobalObject*>(thisObj));
         }
-        JSValue* value = evalNode->execute(&newExec);
+        
+        Completion c = evalNode->execute(&newExec);
+          
         if (switchGlobal)
             newExec.popScope();
 
-        if (exec->completionType() == Throw) {
-            exec->setException(value);
-            return value;
-        }
-        return value ? value : jsUndefined();
+        // if an exception occured, propogate it back to the previous execution object
+        if (newExec.hadException())
+          exec->setException(newExec.exception());
+
+        res = jsUndefined();
+        if (c.complType() == Throw)
+          exec->setException(c.value());
+        else if (c.isValueCompletion())
+            res = c.value();
       }
+      break;
     }
   case ParseInt:
     res = jsNumber(parseInt(args[0]->toString(exec), args[1]->toInt32(exec)));
index cc8e716c47fb7da16ea8ee0c10c5dfab8bacdf2a..6757088f6725cdb2e0f6a20c6ff1ffbb7de0ea7c 100644 (file)
@@ -82,6 +82,7 @@ namespace KJS {
     virtual JSObject* construct(ExecState*, const List& args);
     
     virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const List& args);
+    Completion execute(ExecState*);
 
     // Note: unlike body->paramName, this returns Identifier::null for parameters 
     // that will never get set, due to later param having the same name
index 4e922523354bf9e05bd1f011f4667613c65c984b..51a06b2b3e8d0b672b01b8d558c9d971beaa8517 100644 (file)
@@ -120,8 +120,7 @@ Completion Interpreter::evaluate(ExecState* exec, const UString& sourceURL, int
     else {
         // execute the code
         ExecState newExec(globalObject, thisObj, progNode.get());
-        JSValue* value = progNode->execute(&newExec);
-        res = Completion(newExec.completionType(), value);
+        res = progNode->execute(&newExec);
     }
     
     globalObject->decRecursion();
index 671f49be30381fa98f17a366d1c8dc8c91456c70..88e33e258e004a85d306d8406a1891e13dbc4918 100644 (file)
@@ -46,7 +46,7 @@ namespace KJS {
 
 #define KJS_BREAKPOINT \
   if (Debugger::debuggersPresent > 0 && !hitStatement(exec)) \
-    return 0;
+    return Completion(Normal);
 
 #define KJS_CHECKEXCEPTION \
   if (exec->hadException()) \
@@ -271,16 +271,16 @@ static inline const UString& currentSourceURL(ExecState* exec)
     return exec->scopeNode()->sourceURL();
 }
 
-JSValue* Node::setErrorCompletion(ExecState* exec, ErrorType e, const char* msg)
+Completion Node::createErrorCompletion(ExecState* exec, ErrorType e, const char *msg)
 {
-    return exec->setThrowCompletion(Error::create(exec, e, msg, lineNo(), currentSourceId(exec), currentSourceURL(exec)));
+    return Completion(Throw, Error::create(exec, e, msg, lineNo(), currentSourceId(exec), currentSourceURL(exec)));
 }
 
-JSValue* Node::setErrorCompletion(ExecState* exec, ErrorType e, const char* msg, const Identifier& ident)
+Completion Node::createErrorCompletion(ExecState *exec, ErrorType e, const char *msg, const Identifier &ident)
 {
     UString message = msg;
     substitute(message, ident.ustring());
-    return exec->setThrowCompletion(Error::create(exec, e, message, lineNo(), currentSourceId(exec), currentSourceURL(exec)));
+    return Completion(Throw, Error::create(exec, e, message, lineNo(), currentSourceId(exec), currentSourceURL(exec)));
 }
 
 JSValue *Node::throwError(ExecState* exec, ErrorType e, const char *msg)
@@ -364,12 +364,12 @@ void Node::handleException(ExecState* exec, JSValue* exceptionValue)
     }
 }
 
-JSValue* Node::rethrowException(ExecState* exec)
+Completion Node::rethrowException(ExecState* exec)
 {
     JSValue* exception = exec->exception();
     exec->clearException();
     handleException(exec, exception);
-    return exec->setThrowCompletion(exception);
+    return Completion(Throw, exception);
 }
 
 // ------------------------------ StatementNode --------------------------------
@@ -386,15 +386,14 @@ void StatementNode::setLoc(int firstLine, int lastLine)
     m_lastLine = lastLine;
 }
 
-// Set normal completion and return false if the debugger wants us to stop at this point.
-// FIXME: This seems like poor naming and strange design. Why false to stop? Why "hit statement"?
+// return true if the debugger wants us to stop at this point
 bool StatementNode::hitStatement(ExecState* exec)
 {
-    Debugger* debugger = exec->dynamicGlobalObject()->debugger();
-    if (!debugger || debugger->atStatement(exec, currentSourceId(exec), firstLine(), lastLine()))
-        return true;
-    exec->setCompletionType(Normal);
-    return false;
+  Debugger *dbg = exec->dynamicGlobalObject()->debugger();
+  if (dbg)
+    return dbg->atStatement(exec, currentSourceId(exec), firstLine(), lastLine());
+  else
+    return true; // continue
 }
 
 // ------------------------------ NullNode -------------------------------------
@@ -3549,14 +3548,14 @@ void VarStatementNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::N
 }
 
 // ECMA 12.2
-JSValue* VarStatementNode::execute(ExecState* exec)
+Completion VarStatementNode::execute(ExecState *exec)
 {
-    KJS_BREAKPOINT
+    KJS_BREAKPOINT;
 
     next->evaluate(exec);
     KJS_CHECKEXCEPTION
 
-    return exec->setNormalCompletion();
+    return Completion(Normal);
 }
 
 // ------------------------------ Helper functions for handling Vectors of StatementNode -------------------------------
@@ -3588,20 +3587,24 @@ static inline Node* statementListInitializeVariableAccessStack(SourceElements& s
     return (*begin).get();
 }
 
-static inline JSValue* statementListExecute(SourceElements& statements, ExecState* exec)
+static inline Completion statementListExecute(SourceElements& statements, ExecState* exec)
 {
-    JSValue* value = 0;
-    size_t size = statements.size();
-    for (size_t i = 0; i != size; ++i) {
-        JSValue* statementValue = statements[i]->execute(exec);
-        if (exec->completionType() != Normal)
-            return statementValue;
-        if (statementValue)
-            value = statementValue;
+    JSValue* v = 0;
+    Completion c(Normal);
+    const SourceElements::iterator end = statements.end();
+    for (SourceElements::iterator ptr = statements.begin(); ptr != end; ++ptr) {
+        c = (*ptr)->execute(exec);
+        
+        if (JSValue* v2 = c.value())
+            v = v2;
+        c.setValue(v);
+        
+        if (c.complType() != Normal)
+            return c;
     }
-    return exec->setNormalCompletion(value);
+    return c;
 }
-
+    
 // ------------------------------ BlockNode ------------------------------------
 
 BlockNode::BlockNode(SourceElements* children)
@@ -3616,7 +3619,7 @@ void BlockNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStac
 }
 
 // ECMA 12.1
-JSValue* BlockNode::execute(ExecState* exec)
+Completion BlockNode::execute(ExecState *exec)
 {
     return statementListExecute(*m_children, exec);
 }
@@ -3624,9 +3627,9 @@ JSValue* BlockNode::execute(ExecState* exec)
 // ------------------------------ EmptyStatementNode ---------------------------
 
 // ECMA 12.3
-JSValue* EmptyStatementNode::execute(ExecState* exec)
+Completion EmptyStatementNode::execute(ExecState *)
 {
-    return exec->setNormalCompletion();
+  return Completion(Normal);
 }
 
 // ------------------------------ ExprStatementNode ----------------------------
@@ -3638,14 +3641,14 @@ void ExprStatementNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::
 }
 
 // ECMA 12.4
-JSValue* ExprStatementNode::execute(ExecState* exec)
+Completion ExprStatementNode::execute(ExecState *exec)
 {
-    KJS_BREAKPOINT
+  KJS_BREAKPOINT;
 
-    JSValue* value = expr->evaluate(exec);
-    KJS_CHECKEXCEPTION
+  JSValue *v = expr->evaluate(exec);
+  KJS_CHECKEXCEPTION
 
-    return exec->setNormalCompletion(value);
+  return Completion(Normal, v);
 }
 
 // ------------------------------ IfNode ---------------------------------------
@@ -3661,9 +3664,9 @@ void IfNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&
 }
 
 // ECMA 12.5
-JSValue* IfNode::execute(ExecState* exec)
+Completion IfNode::execute(ExecState* exec)
 {
-    KJS_BREAKPOINT
+    KJS_BREAKPOINT;
 
     bool b = expr->evaluateToBoolean(exec);
     KJS_CHECKEXCEPTION
@@ -3674,7 +3677,7 @@ JSValue* IfNode::execute(ExecState* exec)
 
     // no else
     if (!statement2)
-        return exec->setNormalCompletion();
+        return Completion(Normal);
 
     // else
     return statement2->execute(exec);
@@ -3689,39 +3692,37 @@ void DoWhileNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeSt
 }
 
 // ECMA 12.6.1
-JSValue* DoWhileNode::execute(ExecState* exec)
+Completion DoWhileNode::execute(ExecState *exec)
 {
-    KJS_BREAKPOINT
+    KJS_BREAKPOINT;
 
     JSValue* value = 0;
 
     while (1) {
         exec->pushIteration();
-        JSValue* statementValue = statement->execute(exec);
+        Completion c = statement->execute(exec);
         exec->popIteration();
 
         if (exec->dynamicGlobalObject()->timedOut())
-            exec->setInterruptedCompletion();
+            return Completion(Interrupted);
 
-        if (statementValue)
-            value = statementValue;
+        if (c.isValueCompletion())
+            value = c.value();
 
-        if (exec->completionType() != Normal) {
-            if (exec->completionType() == Continue && ls.contains(exec->breakOrContinueTarget()))
-                goto continueDoWhileLoop;
-            if (exec->completionType() == Break && ls.contains(exec->breakOrContinueTarget()))
-                break;
-            return statementValue;
+        if (!((c.complType() == Continue) && ls.contains(c.target()))) {
+            if ((c.complType() == Break) && ls.contains(c.target()))
+                return Completion(Normal, value);
+            if (c.complType() != Normal)
+                return c;
         }
 
-continueDoWhileLoop:
         bool b = expr->evaluateToBoolean(exec);
         KJS_CHECKEXCEPTION
         if (!b)
-            break;
+            return Completion(Normal, value);
     }
 
-    return exec->setNormalCompletion(value);
+    return Completion(); // work around gcc 4.0 bug
 }
 
 // ------------------------------ WhileNode ------------------------------------
@@ -3733,9 +3734,9 @@ void WhileNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStac
 }
 
 // ECMA 12.6.2
-JSValue* WhileNode::execute(ExecState* exec)
+Completion WhileNode::execute(ExecState *exec)
 {
-    KJS_BREAKPOINT
+    KJS_BREAKPOINT;
 
     JSValue* value = 0;
 
@@ -3743,28 +3744,27 @@ JSValue* WhileNode::execute(ExecState* exec)
         bool b = expr->evaluateToBoolean(exec);
         KJS_CHECKEXCEPTION
         if (!b)
-            break;
+            return Completion(Normal, value);
 
         exec->pushIteration();
-        JSValue* statementValue = statement->execute(exec);
+        Completion c = statement->execute(exec);
         exec->popIteration();
 
         if (exec->dynamicGlobalObject()->timedOut())
-            return exec->setInterruptedCompletion();
+            return Completion(Interrupted);
     
-        if (statementValue)
-            value = statementValue;
+        if (c.isValueCompletion())
+            value = c.value();
 
-        if (exec->completionType() != Normal) {
-            if (exec->completionType() == Continue && ls.contains(exec->breakOrContinueTarget()))
-                continue;
-            if (exec->completionType() == Break && ls.contains(exec->breakOrContinueTarget()))
-                break;
-            return statementValue;
-        }
+        if ((c.complType() == Continue) && ls.contains(c.target()))
+            continue;
+        if ((c.complType() == Break) && ls.contains(c.target()))
+            return Completion(Normal, value);
+        if (c.complType() != Normal)
+            return c;
     }
 
-    return exec->setNormalCompletion(value);
+    return Completion(); // work around gcc 4.0 bug
 }
 
 // ------------------------------ ForNode --------------------------------------
@@ -3781,9 +3781,9 @@ void ForNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&
 }
 
 // ECMA 12.6.3
-JSValue* ForNode::execute(ExecState *exec)
+Completion ForNode::execute(ExecState *exec)
 {
-    JSValue* value = 0;
+    JSValue* cval = 0;
 
     if (expr1) {
         expr1->evaluate(exec);
@@ -3795,34 +3795,31 @@ JSValue* ForNode::execute(ExecState *exec)
             bool b = expr2->evaluateToBoolean(exec);
             KJS_CHECKEXCEPTION
             if (!b)
-                break;
+                return Completion(Normal, cval);
         }
 
         exec->pushIteration();
-        JSValue* statementValue = statement->execute(exec);
+        Completion c = statement->execute(exec);
         exec->popIteration();
-        if (statementValue)
-            value = statementValue;
+        if (c.isValueCompletion())
+            cval = c.value();
+        if (!((c.complType() == Continue) && ls.contains(c.target()))) {
+            if ((c.complType() == Break) && ls.contains(c.target()))
+                return Completion(Normal, cval);
+            if (c.complType() != Normal)
+                return c;
+        }
 
         if (exec->dynamicGlobalObject()->timedOut())
-            return exec->setInterruptedCompletion();
-
-        if (exec->completionType() != Normal) {
-            if (exec->completionType() == Continue && ls.contains(exec->breakOrContinueTarget()))
-                goto continueForLoop;
-            if (exec->completionType() == Break && ls.contains(exec->breakOrContinueTarget()))
-                break;
-            return statementValue;
-        }
+            return Completion(Interrupted);
 
-continueForLoop:
         if (expr3) {
             expr3->evaluate(exec);
             KJS_CHECKEXCEPTION
         }
     }
   
-    return exec->setNormalCompletion(value);
+    return Completion(); // work around gcc 4.0 bug
 }
 
 // ------------------------------ ForInNode ------------------------------------
@@ -3850,30 +3847,35 @@ void ForInNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStac
 }
 
 // ECMA 12.6.4
-JSValue* ForInNode::execute(ExecState* exec)
+Completion ForInNode::execute(ExecState *exec)
 {
-  JSValue* value = 0;
+  JSValue *e;
+  JSValue *retval = 0;
+  JSObject *v;
+  Completion c;
+  PropertyNameArray propertyNames;
 
   if (varDecl) {
     varDecl->evaluate(exec);
     KJS_CHECKEXCEPTION
   }
 
-  JSValue* e = expr->evaluate(exec);
+  e = expr->evaluate(exec);
 
-  // For Null and Undefined, we want to make sure not to go through
-  // the loop at all, because toObject will throw an exception.
+  // for Null and Undefined, we want to make sure not to go through
+  // the loop at all, because their object wrappers will have a
+  // property list but will throw an exception if you attempt to
+  // access any property.
   if (e->isUndefinedOrNull())
-    return exec->setNormalCompletion();
+    return Completion(Normal);
 
   KJS_CHECKEXCEPTION
-  JSObject* v = e->toObject(exec);
-  PropertyNameArray propertyNames;
+  v = e->toObject(exec);
   v->getPropertyNames(exec, propertyNames);
   
   PropertyNameArray::const_iterator end = propertyNames.end();
   for (PropertyNameArray::const_iterator it = propertyNames.begin(); it != end; ++it) {
-      const Identifiername = *it;
+      const Identifier &name = *it;
       if (!v->hasProperty(exec, name))
           continue;
 
@@ -3926,49 +3928,50 @@ JSValue* ForInNode::execute(ExecState* exec)
     KJS_CHECKEXCEPTION
 
     exec->pushIteration();
-    JSValue* statementValue = statement->execute(exec);
+    c = statement->execute(exec);
     exec->popIteration();
-    if (statementValue)
-      value = statementValue;
+    if (c.isValueCompletion())
+      retval = c.value();
 
-    if (exec->completionType() != Normal) {
-        if (exec->completionType() == Continue && ls.contains(exec->breakOrContinueTarget()))
-            continue;
-        if (exec->completionType() == Break && ls.contains(exec->breakOrContinueTarget()))
-            break;
-        return statementValue;
+    if (!((c.complType() == Continue) && ls.contains(c.target()))) {
+      if ((c.complType() == Break) && ls.contains(c.target()))
+        break;
+      if (c.complType() != Normal) {
+        return c;
+      }
     }
   }
 
-  return exec->setNormalCompletion(value);
+  return Completion(Normal, retval);
 }
 
 // ------------------------------ ContinueNode ---------------------------------
 
 // ECMA 12.7
-JSValue* ContinueNode::execute(ExecState* exec)
+Completion ContinueNode::execute(ExecState *exec)
 {
-  KJS_BREAKPOINT
+  KJS_BREAKPOINT;
 
   if (ident.isEmpty() && !exec->inIteration())
-    return setErrorCompletion(exec, SyntaxError, "Invalid continue statement.");
+    return createErrorCompletion(exec, SyntaxError, "Invalid continue statement.");
   if (!ident.isEmpty() && !exec->seenLabels()->contains(ident))
-    return setErrorCompletion(exec, SyntaxError, "Label %s not found.", ident);
-  return exec->setContinueCompletion(&ident);
+    return createErrorCompletion(exec, SyntaxError, "Label %s not found.", ident);
+  return Completion(Continue, &ident);
 }
 
 // ------------------------------ BreakNode ------------------------------------
 
 // ECMA 12.8
-JSValue* BreakNode::execute(ExecState *exec)
+Completion BreakNode::execute(ExecState *exec)
 {
-  KJS_BREAKPOINT
+  KJS_BREAKPOINT;
 
-  if (ident.isEmpty() && !exec->inIteration() && !exec->inSwitch())
-    return setErrorCompletion(exec, SyntaxError, "Invalid break statement.");
+  if (ident.isEmpty() && !exec->inIteration() &&
+      !exec->inSwitch())
+    return createErrorCompletion(exec, SyntaxError, "Invalid break statement.");
   if (!ident.isEmpty() && !exec->seenLabels()->contains(ident))
-    return setErrorCompletion(exec, SyntaxError, "Label %s not found.");
-  return exec->setBreakCompletion(&ident);
+    return createErrorCompletion(exec, SyntaxError, "Label %s not found.");
+  return Completion(Break, &ident);
 }
 
 // ------------------------------ ReturnNode -----------------------------------
@@ -3980,21 +3983,21 @@ void ReturnNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeSta
 }
 
 // ECMA 12.9
-JSValue* ReturnNode::execute(ExecState* exec)
+Completion ReturnNode::execute(ExecState *exec)
 {
-  KJS_BREAKPOINT
+  KJS_BREAKPOINT;
 
   CodeType codeType = exec->codeType();
   if (codeType != FunctionCode)
-    return setErrorCompletion(exec, SyntaxError, "Invalid return statement.");
+    return createErrorCompletion(exec, SyntaxError, "Invalid return statement.");
 
   if (!value)
-    return exec->setReturnValueCompletion(jsUndefined());
+    return Completion(ReturnValue, jsUndefined());
 
-  JSValuev = value->evaluate(exec);
+  JSValue *v = value->evaluate(exec);
   KJS_CHECKEXCEPTION
 
-  return exec->setReturnValueCompletion(v);
+  return Completion(ReturnValue, v);
 }
 
 // ------------------------------ WithNode -------------------------------------
@@ -4006,19 +4009,19 @@ void WithNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack
 }
 
 // ECMA 12.10
-JSValue* WithNode::execute(ExecState *exec)
+Completion WithNode::execute(ExecState *exec)
 {
-  KJS_BREAKPOINT
+  KJS_BREAKPOINT;
 
   JSValue *v = expr->evaluate(exec);
   KJS_CHECKEXCEPTION
   JSObject *o = v->toObject(exec);
   KJS_CHECKEXCEPTION
   exec->pushScope(o);
-  JSValue* value = statement->execute(exec);
+  Completion res = statement->execute(exec);
   exec->popScope();
 
-  return value;
+  return res;
 }
     
 // ------------------------------ CaseClauseNode -------------------------------
@@ -4041,11 +4044,12 @@ JSValue *CaseClauseNode::evaluate(ExecState *exec)
 }
 
 // ECMA 12.11
-JSValue* CaseClauseNode::executeStatements(ExecState* exec)
+Completion CaseClauseNode::evalStatements(ExecState *exec)
 {
   if (m_children)
     return statementListExecute(*m_children, exec);
-  return exec->setNormalCompletion();
+  else
+    return Completion(Normal, jsUndefined());
 }
 
 // ------------------------------ ClauseListNode -------------------------------
@@ -4077,36 +4081,41 @@ void CaseBlockNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::Node
 }
 
 // ECMA 12.11
-JSValue* CaseBlockNode::executeBlock(ExecState* exec, JSValue* input)
+Completion CaseBlockNode::evalBlock(ExecState *exec, JSValue *input)
 {
-  ClauseListNode* a = list1.get();
+  JSValue *v;
+  Completion res;
+  ClauseListNode *a = list1.get();
+  ClauseListNode *b = list2.get();
+  CaseClauseNode *clause;
+
     while (a) {
-      CaseClauseNode* clause = a->getClause();
+      clause = a->getClause();
       a = a->getNext();
-      JSValue* v = clause->evaluate(exec);
+      v = clause->evaluate(exec);
       KJS_CHECKEXCEPTION
       if (strictEqual(exec, input, v)) {
-        JSValue* res = clause->executeStatements(exec);
-        if (exec->completionType() != Normal)
+        res = clause->evalStatements(exec);
+        if (res.complType() != Normal)
           return res;
-        for (; a; a = a->getNext()) {
-          JSValue* res = a->getClause()->executeStatements(exec);
-          if (exec->completionType() != Normal)
+        while (a) {
+          res = a->getClause()->evalStatements(exec);
+          if (res.complType() != Normal)
             return res;
+          a = a->getNext();
         }
         break;
       }
     }
 
-  ClauseListNode* b = list2.get();
   while (b) {
-    CaseClauseNode* clause = b->getClause();
+    clause = b->getClause();
     b = b->getNext();
-    JSValue* v = clause->evaluate(exec);
+    v = clause->evaluate(exec);
     KJS_CHECKEXCEPTION
     if (strictEqual(exec, input, v)) {
-      JSValue* res = clause->executeStatements(exec);
-      if (exec->completionType() != Normal)
+      res = clause->evalStatements(exec);
+      if (res.complType() != Normal)
         return res;
       goto step18;
     }
@@ -4114,16 +4123,16 @@ JSValue* CaseBlockNode::executeBlock(ExecState* exec, JSValue* input)
 
   // default clause
   if (def) {
-    JSValue* res = def->executeStatements(exec);
-    if (exec->completionType() != Normal)
+    res = def->evalStatements(exec);
+    if (res.complType() != Normal)
       return res;
   }
   b = list2.get();
  step18:
   while (b) {
-    CaseClauseNode* clause = b->getClause();
-    JSValue* res = clause->executeStatements(exec);
-    if (exec->completionType() != Normal)
+    clause = b->getClause();
+    res = clause->evalStatements(exec);
+    if (res.complType() != Normal)
       return res;
     b = b->getNext();
   }
@@ -4131,7 +4140,7 @@ JSValue* CaseBlockNode::executeBlock(ExecState* exec, JSValue* input)
   // bail out on error
   KJS_CHECKEXCEPTION
 
-  return exec->setNormalCompletion();
+  return Completion(Normal);
 }
 
 // ------------------------------ SwitchNode -----------------------------------
@@ -4143,20 +4152,20 @@ void SwitchNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeSta
 }
 
 // ECMA 12.11
-JSValue* SwitchNode::execute(ExecState* exec)
+Completion SwitchNode::execute(ExecState *exec)
 {
-  KJS_BREAKPOINT
+  KJS_BREAKPOINT;
 
   JSValue *v = expr->evaluate(exec);
   KJS_CHECKEXCEPTION
 
   exec->pushSwitch();
-  JSValue* result = block->executeBlock(exec, v);
+  Completion res = block->evalBlock(exec,v);
   exec->popSwitch();
 
-  if (exec->completionType() == Break && ls.contains(exec->breakOrContinueTarget()))
-    exec->setCompletionType(Normal);
-  return result;
+  if ((res.complType() == Break) && ls.contains(res.target()))
+    return Completion(Normal, res.value());
+  return res;
 }
 
 // ------------------------------ LabelNode ------------------------------------
@@ -4167,16 +4176,16 @@ void LabelNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStac
 }
 
 // ECMA 12.12
-JSValue* LabelNode::execute(ExecState *exec)
+Completion LabelNode::execute(ExecState *exec)
 {
   if (!exec->seenLabels()->push(label))
-    return setErrorCompletion(exec, SyntaxError, "Duplicated label %s found.", label);
-  JSValue* result = statement->execute(exec);
+    return createErrorCompletion(exec, SyntaxError, "Duplicated label %s found.", label);
+  Completion e = statement->execute(exec);
   exec->seenLabels()->pop();
 
-  if (exec->completionType() == Break && exec->breakOrContinueTarget() == label)
-    exec->setCompletionType(Normal);
-  return result;
+  if ((e.complType() == Break) && (e.target() == label))
+    return Completion(Normal, e.value());
+  return e;
 }
 
 // ------------------------------ ThrowNode ------------------------------------
@@ -4187,15 +4196,15 @@ void ThrowNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStac
 }
 
 // ECMA 12.13
-JSValue* ThrowNode::execute(ExecState* exec)
+Completion ThrowNode::execute(ExecState *exec)
 {
-  KJS_BREAKPOINT
+  KJS_BREAKPOINT;
 
   JSValue *v = expr->evaluate(exec);
   KJS_CHECKEXCEPTION
 
   handleException(exec, v);
-  return exec->setThrowCompletion(v);
+  return Completion(Throw, v);
 }
 
 // ------------------------------ TryNode --------------------------------------
@@ -4209,33 +4218,30 @@ void TryNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&
 }
 
 // ECMA 12.14
-JSValue* TryNode::execute(ExecState *exec)
+Completion TryNode::execute(ExecState *exec)
 {
-  KJS_BREAKPOINT
+  KJS_BREAKPOINT;
 
-  JSValue* result = tryBlock->execute(exec);
+  Completion c = tryBlock->execute(exec);
 
   if (Collector::isOutOfMemory())
-      return result; // don't try to catch an out of memory exception thrown by the collector
+      return c; // don't try to catch an out of memory exception thrown by the collector
   
-  if (catchBlock && exec->completionType() == Throw) {
-    JSObjectobj = new JSObject;
-    obj->put(exec, exceptionIdent, result, DontDelete);
+  if (catchBlock && c.complType() == Throw) {
+    JSObject *obj = new JSObject;
+    obj->put(exec, exceptionIdent, c.value(), DontDelete);
     exec->pushScope(obj);
-    result = catchBlock->execute(exec);
+    c = catchBlock->execute(exec);
     exec->popScope();
   }
 
   if (finallyBlock) {
-    ComplType savedCompletionType = exec->completionType();
-    JSValue* finallyResult = finallyBlock->execute(exec);
-    if (exec->completionType() != Normal)
-        result = finallyResult;
-    else
-        exec->setCompletionType(savedCompletionType);
+    Completion c2 = finallyBlock->execute(exec);
+    if (c2.complType() != Normal)
+      c = c2;
   }
 
-  return result;
+  return c;
 }
 
 // ------------------------------ FunctionBodyNode -----------------------------
@@ -4490,42 +4496,43 @@ UString FunctionBodyNode::paramString() const
   return s;
 }
 
-JSValue* ProgramNode::execute(ExecState* exec)
+Completion ProgramNode::execute(ExecState* exec)
 {
     processDeclarations(exec);
     return ScopeNode::execute(exec);
 }
 
-JSValue* EvalNode::execute(ExecState* exec)
+Completion EvalNode::execute(ExecState* exec)
 {
     processDeclarations(exec);
     return ScopeNode::execute(exec);
 }
 
-JSValue* FunctionBodyNode::execute(ExecState* exec)
+Completion FunctionBodyNode::execute(ExecState* exec)
 {
     processDeclarations(exec);
 
     if (Debugger* dbg = exec->dynamicGlobalObject()->debugger()) {
         if (!dbg->callEvent(exec, sourceId(), lineNo(), exec->function(), *exec->arguments())) {
             dbg->imp()->abort();
-            return exec->setInterruptedCompletion();
+            return Completion(Interrupted, jsUndefined());
         }
     }    
     
-    JSValue* result = ScopeNode::execute(exec);
+    Completion completion = ScopeNode::execute(exec);
     
     if (Debugger* dbg = exec->dynamicGlobalObject()->debugger()) {
-        if (exec->completionType() == Throw)
-            exec->setException(result);
+        if (completion.complType() == Throw)
+            exec->setException(completion.value());
+
         if (!dbg->returnEvent(exec, sourceId(), lineNo(), exec->function())) {
             dbg->imp()->abort();
-            return exec->setInterruptedCompletion();
+            return Completion(Interrupted, jsUndefined());
         }
     }
 
     
-    return result;
+    return completion;
 }
 
 // ------------------------------ FuncDeclNode ---------------------------------
@@ -4548,9 +4555,9 @@ FunctionImp* FuncDeclNode::makeFunction(ExecState* exec)
   return func;
 }
 
-JSValue* FuncDeclNode::execute(ExecState* exec)
+Completion FuncDeclNode::execute(ExecState *)
 {
-    return exec->setNormalCompletion();
+    return Completion(Normal);
 }
 
 // ------------------------------ FuncExprNode ---------------------------------
index b9451f5230bfe4724ebe34b7c90419f4bf5a88f5..fc2e1df88e4ca5de79ba5d87f850ccff499b3c52 100644 (file)
@@ -144,12 +144,9 @@ namespace KJS {
 
   protected:
     Node(JSType) KJS_FAST_CALL; // used by ExpressionNode
+    Completion createErrorCompletion(ExecState *, ErrorType, const char *msg) KJS_FAST_CALL;
+    Completion createErrorCompletion(ExecState *, ErrorType, const char *msg, const Identifier &) KJS_FAST_CALL;
 
-    // for use in execute()
-    JSValue* setErrorCompletion(ExecState*, ErrorType, const char* msg) KJS_FAST_CALL;
-    JSValue* setErrorCompletion(ExecState*, ErrorType, const char* msg, const Identifier&) KJS_FAST_CALL;
-
-    // for use in evaluate()
     JSValue* throwError(ExecState*, ErrorType, const char* msg) KJS_FAST_CALL;
     JSValue* throwError(ExecState*, ErrorType, const char* msg, const char*) KJS_FAST_CALL;
     JSValue* throwError(ExecState*, ErrorType, const char* msg, JSValue*, Node*) KJS_FAST_CALL;
@@ -163,8 +160,7 @@ namespace KJS {
     void handleException(ExecState*) KJS_FAST_CALL;
     void handleException(ExecState*, JSValue*) KJS_FAST_CALL;
 
-    // for use in execute()
-    JSValue* rethrowException(ExecState*) KJS_FAST_CALL;
+    Completion rethrowException(ExecState*) KJS_FAST_CALL;
 
     int m_line : 28;
     unsigned m_expectedReturnType : 3; // JSType
@@ -204,11 +200,11 @@ namespace KJS {
     void setLoc(int line0, int line1) KJS_FAST_CALL;
     int firstLine() const KJS_FAST_CALL { return lineNo(); }
     int lastLine() const KJS_FAST_CALL { return m_lastLine; }
-    virtual JSValue* execute(ExecState *exec) KJS_FAST_CALL = 0;
+    bool hitStatement(ExecState*) KJS_FAST_CALL;
+    virtual Completion execute(ExecState *exec) KJS_FAST_CALL = 0;
     void pushLabel(const Identifier &id) KJS_FAST_CALL { ls.push(id); }
     virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
   protected:
-    bool hitStatement(ExecState*) KJS_FAST_CALL;
     LabelStack ls;
   private:
     int m_lastLine;
@@ -1728,7 +1724,7 @@ namespace KJS {
   public:
     VarStatementNode(VarDeclNode* l) KJS_FAST_CALL : next(l) { }
     virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
-    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
+    virtual Completion execute(ExecState*) KJS_FAST_CALL;
     virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
   private:
     RefPtr<VarDeclNode> next;
@@ -1747,7 +1743,7 @@ namespace KJS {
         return elems;
     }
     virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL { ASSERT_NOT_REACHED(); }
-    virtual JSValue* execute(ExecState*) KJS_FAST_CALL  { ASSERT_NOT_REACHED(); return 0; }
+    virtual Completion execute(ExecState*) KJS_FAST_CALL  { ASSERT_NOT_REACHED(); return Completion(); }
     virtual void streamTo(SourceStream&) const KJS_FAST_CALL  { ASSERT_NOT_REACHED(); }
     virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
   private:
@@ -1758,7 +1754,7 @@ namespace KJS {
   public:
     BlockNode(SourceElements* children) KJS_FAST_CALL;
     virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
-    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
+    virtual Completion execute(ExecState*) KJS_FAST_CALL;
     virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
   protected:
     OwnPtr<SourceElements> m_children;
@@ -1767,7 +1763,7 @@ namespace KJS {
   class EmptyStatementNode : public StatementNode {
   public:
     EmptyStatementNode() KJS_FAST_CALL { } // debug
-    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
+    virtual Completion execute(ExecState*) KJS_FAST_CALL;
     virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
   };
 
@@ -1775,7 +1771,7 @@ namespace KJS {
   public:
     ExprStatementNode(ExpressionNode* e) KJS_FAST_CALL : expr(e) { }
     virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
-    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
+    virtual Completion execute(ExecState*) KJS_FAST_CALL;
     virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
   private:
     RefPtr<ExpressionNode> expr;
@@ -1786,7 +1782,7 @@ namespace KJS {
     IfNode(ExpressionNode* e, StatementNode *s1, StatementNode *s2) KJS_FAST_CALL
       : expr(e), statement1(s1), statement2(s2) { }
     virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
-    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
+    virtual Completion execute(ExecState*) KJS_FAST_CALL;
     virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
   private:
     RefPtr<ExpressionNode> expr;
@@ -1798,7 +1794,7 @@ namespace KJS {
   public:
     DoWhileNode(StatementNode *s, ExpressionNode* e) KJS_FAST_CALL : statement(s), expr(e) { }
     virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
-    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
+    virtual Completion execute(ExecState*) KJS_FAST_CALL;
     virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
   private:
     RefPtr<StatementNode> statement;
@@ -1809,7 +1805,7 @@ namespace KJS {
   public:
     WhileNode(ExpressionNode* e, StatementNode *s) KJS_FAST_CALL : expr(e), statement(s) { }
     virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
-    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
+    virtual Completion execute(ExecState*) KJS_FAST_CALL;
     virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
   private:
     RefPtr<ExpressionNode> expr;
@@ -1828,7 +1824,7 @@ namespace KJS {
     }
 
     virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
-    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
+    virtual Completion execute(ExecState*) KJS_FAST_CALL;
     virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
   private:
     RefPtr<ExpressionNode> expr1;
@@ -1842,7 +1838,7 @@ namespace KJS {
     ForInNode(ExpressionNode*  l, ExpressionNode* e, StatementNode *s) KJS_FAST_CALL;
     ForInNode(const Identifier &i, AssignExprNode *in, ExpressionNode* e, StatementNode *s) KJS_FAST_CALL;
     virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
-    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
+    virtual Completion execute(ExecState*) KJS_FAST_CALL;
     virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
     VarDeclNode* getVarDecl() { return varDecl.get(); }
   private:
@@ -1858,7 +1854,7 @@ namespace KJS {
   public:
     ContinueNode() KJS_FAST_CALL { }
     ContinueNode(const Identifier &i) KJS_FAST_CALL : ident(i) { }
-    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
+    virtual Completion execute(ExecState*) KJS_FAST_CALL;
     virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
   private:
     Identifier ident;
@@ -1868,7 +1864,7 @@ namespace KJS {
   public:
     BreakNode() KJS_FAST_CALL { }
     BreakNode(const Identifier &i) KJS_FAST_CALL : ident(i) { }
-    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
+    virtual Completion execute(ExecState*) KJS_FAST_CALL;
     virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
   private:
     Identifier ident;
@@ -1878,7 +1874,7 @@ namespace KJS {
   public:
     ReturnNode(ExpressionNode* v) KJS_FAST_CALL : value(v) {}
     virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
-    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
+    virtual Completion execute(ExecState*) KJS_FAST_CALL;
     virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
   private:
     RefPtr<ExpressionNode> value;
@@ -1888,7 +1884,7 @@ namespace KJS {
   public:
     WithNode(ExpressionNode* e, StatementNode* s) KJS_FAST_CALL : expr(e), statement(s) { }
     virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
-    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
+    virtual Completion execute(ExecState*) KJS_FAST_CALL;
     virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
   private:
     RefPtr<ExpressionNode> expr;
@@ -1899,7 +1895,7 @@ namespace KJS {
   public:
     LabelNode(const Identifier &l, StatementNode *s) KJS_FAST_CALL : label(l), statement(s) { }
     virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
-    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
+    virtual Completion execute(ExecState*) KJS_FAST_CALL;
     virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
   private:
     Identifier label;
@@ -1910,7 +1906,7 @@ namespace KJS {
   public:
     ThrowNode(ExpressionNode* e) KJS_FAST_CALL : expr(e) {}
     virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
-    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
+    virtual Completion execute(ExecState*) KJS_FAST_CALL;
     virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
   private:
     RefPtr<ExpressionNode> expr;
@@ -1921,7 +1917,7 @@ namespace KJS {
     TryNode(StatementNode *b, const Identifier &e, StatementNode *c, StatementNode *f) KJS_FAST_CALL
       : tryBlock(b), exceptionIdent(e), catchBlock(c), finallyBlock(f) { }
     virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
-    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
+    virtual Completion execute(ExecState*) KJS_FAST_CALL;
     virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
   private:
     RefPtr<StatementNode> tryBlock;
@@ -1968,7 +1964,7 @@ namespace KJS {
   class ProgramNode : public ScopeNode {
   public:
     ProgramNode(SourceElements*, DeclarationStacks::VarStack*, DeclarationStacks::FunctionStack*) KJS_FAST_CALL;
-    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
+    virtual Completion execute(ExecState*) KJS_FAST_CALL;
     
   private:
     void initializeSymbolTable(ExecState*) KJS_FAST_CALL;
@@ -1981,7 +1977,7 @@ namespace KJS {
   class EvalNode : public ScopeNode {
   public:
     EvalNode(SourceElements*, DeclarationStacks::VarStack*, DeclarationStacks::FunctionStack*) KJS_FAST_CALL;
-    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
+    virtual Completion execute(ExecState*) KJS_FAST_CALL;
     
   private:
     ALWAYS_INLINE void processDeclarations(ExecState*) KJS_FAST_CALL;
@@ -1991,7 +1987,7 @@ namespace KJS {
   public:
     FunctionBodyNode(SourceElements*, DeclarationStacks::VarStack*, DeclarationStacks::FunctionStack*) KJS_FAST_CALL;
 
-    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
+    virtual Completion execute(ExecState*) KJS_FAST_CALL;
 
     SymbolTable& symbolTable() KJS_FAST_CALL { return m_symbolTable; }
 
@@ -2029,7 +2025,7 @@ namespace KJS {
       : ident(i), body(b) { addParams(); }
     FuncDeclNode(const Identifier& i, ParameterNode* p, FunctionBodyNode* b) KJS_FAST_CALL
       : ident(i), param(p), body(b) { addParams(); }
-    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
+    virtual Completion execute(ExecState*) KJS_FAST_CALL;
     virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
     ALWAYS_INLINE FunctionImp* makeFunction(ExecState*) KJS_FAST_CALL;
     Identifier ident;
@@ -2049,7 +2045,7 @@ namespace KJS {
       virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
 
       JSValue* evaluate(ExecState*) KJS_FAST_CALL;
-      JSValue* executeStatements(ExecState*) KJS_FAST_CALL;
+      Completion evalStatements(ExecState*) KJS_FAST_CALL;
 
   private:
       RefPtr<ExpressionNode> expr;
@@ -2077,7 +2073,7 @@ namespace KJS {
   public:
       CaseBlockNode(ClauseListNode* l1, CaseClauseNode* d, ClauseListNode* l2) KJS_FAST_CALL;
       virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
-      JSValue* executeBlock(ExecState*, JSValue *input) KJS_FAST_CALL;
+      Completion evalBlock(ExecState *exec, JSValue *input) KJS_FAST_CALL;
       virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
       virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
   private:
@@ -2090,7 +2086,7 @@ namespace KJS {
   public:
       SwitchNode(ExpressionNode* e, CaseBlockNode *b) KJS_FAST_CALL : expr(e), block(b) { }
       virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
-      virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
+      virtual Completion execute(ExecState*) KJS_FAST_CALL;
       virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
   private:
       RefPtr<ExpressionNode> expr;
index 68570d87ac1432ffcb427026042bbb9019006303..8a3e39c9c3e6d2f8827eb4047000a64c7f7545c1 100644 (file)
@@ -88,6 +88,7 @@ namespace KJS {
     static const ClassInfo info;
     enum { NaNValue, NegInfinity, PosInfinity, MaxValue, MinValue };
 
+    Completion execute(const List &);
     JSObject *construct(const List &);
   };