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