Changeset 28899 in webkit for trunk/JavaScriptCore/kjs/function.cpp
- Timestamp:
- Dec 20, 2007, 12:33:42 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/function.cpp
r28887 r28899 71 71 JSValue* FunctionImp::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) 72 72 { 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 81 91 return jsUndefined(); 82 92 } … … 203 213 else 204 214 return obj; 215 } 216 217 Completion 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 ? 205 224 } 206 225 … … 700 719 JSObject* thisVal = static_cast<JSObject*>(exec->thisValue()); 701 720 ExecState newExec(globalObject, thisVal, evalNode.get(), EvalCode, exec, globalObject->currentExec()); 721 if (exec->hadException()) 722 newExec.setException(exec->exception()); 702 723 703 724 if (switchGlobal) { … … 705 726 newExec.setVariableObject(static_cast<JSGlobalObject*>(thisObj)); 706 727 } 707 JSValue* value = evalNode->execute(&newExec); 728 729 Completion c = evalNode->execute(&newExec); 730 708 731 if (switchGlobal) 709 732 newExec.popScope(); 710 733 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(); 716 743 } 744 break; 717 745 } 718 746 case ParseInt:
Note:
See TracChangeset
for help on using the changeset viewer.