Ignore:
Timestamp:
Dec 20, 2007, 12:33:42 PM (17 years ago)
Author:
Darin Adler
Message:
  • roll out that last change -- it was causing test failures; I'll check it back in after fixing them
File:
1 edited

Legend:

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

    r28887 r28899  
    7171JSValue* FunctionImp::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
    7272{
    73     ExecState newExec(exec->dynamicGlobalObject(), thisObj, body.get(), FunctionCode, exec, exec->dynamicGlobalObject()->currentExec(), this, &args);
    74     JSValue* result = body->execute(&newExec);
    75     if (newExec.completionType() == Throw) {
    76         exec->setException(result);
    77         return result;
    78     }
    79     if (newExec.completionType() == ReturnValue)
    80         return result;
     73  // enter a new execution context
     74  ExecState newExec(exec->dynamicGlobalObject(), thisObj, body.get(), FunctionCode, exec, exec->dynamicGlobalObject()->currentExec(), this, &args);
     75  if (exec->hadException())
     76    newExec.setException(exec->exception());
     77
     78  Completion comp = execute(&newExec);
     79
     80  // if an exception occured, propogate it back to the previous execution object
     81  if (newExec.hadException())
     82    comp = Completion(Throw, newExec.exception());
     83
     84  if (comp.complType() == Throw) {
     85    exec->setException(comp.value());
     86    return comp.value();
     87  }
     88  else if (comp.complType() == ReturnValue)
     89    return comp.value();
     90  else
    8191    return jsUndefined();
    8292}
     
    203213  else
    204214    return obj;
     215}
     216
     217Completion FunctionImp::execute(ExecState* exec)
     218{
     219  Completion result = body->execute(exec);
     220
     221  if (result.complType() == Throw || result.complType() == ReturnValue)
     222      return result;
     223  return Completion(Normal, jsUndefined()); // TODO: or ReturnValue ?
    205224}
    206225
     
    700719        JSObject* thisVal = static_cast<JSObject*>(exec->thisValue());
    701720        ExecState newExec(globalObject, thisVal, evalNode.get(), EvalCode, exec, globalObject->currentExec());
     721        if (exec->hadException())
     722            newExec.setException(exec->exception());
    702723         
    703724        if (switchGlobal) {
     
    705726            newExec.setVariableObject(static_cast<JSGlobalObject*>(thisObj));
    706727        }
    707         JSValue* value = evalNode->execute(&newExec);
     728       
     729        Completion c = evalNode->execute(&newExec);
     730         
    708731        if (switchGlobal)
    709732            newExec.popScope();
    710733
    711         if (exec->completionType() == Throw) {
    712             exec->setException(value);
    713             return value;
    714         }
    715         return value ? value : jsUndefined();
     734        // if an exception occured, propogate it back to the previous execution object
     735        if (newExec.hadException())
     736          exec->setException(newExec.exception());
     737
     738        res = jsUndefined();
     739        if (c.complType() == Throw)
     740          exec->setException(c.value());
     741        else if (c.isValueCompletion())
     742            res = c.value();
    716743      }
     744      break;
    717745    }
    718746  case ParseInt:
Note: See TracChangeset for help on using the changeset viewer.