Changeset 15463 in webkit for trunk/JavaScriptCore/API/JSObjectRef.cpp
- Timestamp:
- Jul 15, 2006, 6:40:07 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSObjectRef.cpp
r15462 r15463 90 90 } 91 91 92 JSObjectRef JSObjectMakeFunctionWithBody(JSContextRef context, JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception) 93 { 94 JSLock lock; 95 96 ExecState* exec = toJS(context); 92 JSObjectRef JSObjectMakeFunctionWithBody(JSContextRef context, JSStringRef name, unsigned parameterCount, JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception) 93 { 94 JSLock lock; 95 96 ExecState* exec = toJS(context); 97 UString::Rep* nameRep = name ? toJS(name) : &UString::Rep::null; 97 98 UString::Rep* bodyRep = toJS(body); 98 UString jsSourceURL = UString(toJS(sourceURL)); 99 100 if (!bodyRep) 101 bodyRep = &UString::Rep::null; 102 103 int sid; 104 int errLine; 105 UString errMsg; 106 RefPtr<FunctionBodyNode> bodyNode = Parser::parse(jsSourceURL, startingLineNumber, bodyRep->data(), bodyRep->size(), &sid, &errLine, &errMsg); 107 if (!bodyNode) { 108 if (exception) 109 *exception = toRef(Error::create(exec, SyntaxError, errMsg, errLine, sid, jsSourceURL)); 110 return 0; 111 } 112 113 ScopeChain scopeChain; 114 scopeChain.push(exec->dynamicInterpreter()->globalObject()); 115 return toRef(static_cast<JSObject*>(new DeclaredFunctionImp(exec, "anonymous", bodyNode.get(), scopeChain))); 99 UString::Rep* sourceURLRep = sourceURL ? toJS(sourceURL) : &UString::Rep::null; 100 101 Identifier nameIdentifier = nameRep ? Identifier(nameRep) : Identifier("anonymous"); 102 103 List args; 104 for (unsigned i = 0; i < parameterCount; i++) 105 args.append(jsString(UString(toJS(parameterNames[i])))); 106 args.append(jsString(UString(bodyRep))); 107 108 JSObject* result = exec->dynamicInterpreter()->builtinFunction()->construct(exec, args, nameIdentifier, UString(sourceURLRep), startingLineNumber); 109 if (exec->hadException()) { 110 if (exception) 111 *exception = toRef(exec->exception()); 112 exec->clearException(); 113 result = 0; 114 } 115 return toRef(result); 116 116 } 117 117
Note:
See TracChangeset
for help on using the changeset viewer.