TiValueRef TiEvalScript(TiContextRef ctx, TiStringRef script, TiObjectRef thisObject, TiStringRef sourceURL, int startingLineNumber, TiValueRef* exception) { TiExcState* exec = toJS(ctx); exec->globalData().heap.registerThread(); TiLock lock(exec); TiObject* jsThisObject = toJS(thisObject); // evaluate sets "this" to the global object if it is NULL TiGlobalObject* globalObject = exec->dynamicGlobalObject(); SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), startingLineNumber); Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), source, jsThisObject); if (completion.complType() == Throw) { if (exception) *exception = toRef(exec, completion.value()); return 0; } if (completion.value()) return toRef(exec, completion.value()); // happens, for example, when the only statement is an empty (';') statement return toRef(exec, jsUndefined()); }
bool TiCheckScriptSyntax(TiContextRef ctx, TiStringRef script, TiStringRef sourceURL, int startingLineNumber, TiValueRef* exception) { TiExcState* exec = toJS(ctx); exec->globalData().heap.registerThread(); TiLock lock(exec); SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), startingLineNumber); Completion completion = checkSyntax(exec->dynamicGlobalObject()->globalExec(), source); if (completion.complType() == Throw) { if (exception) *exception = toRef(exec, completion.value()); return false; } return true; }
TiValueRef TiValueMakeFromJSONString(TiContextRef ctx, TiStringRef string) { TiExcState* exec = toJS(ctx); APIEntryShim entryShim(exec); LiteralParser parser(exec, string->ustring(), LiteralParser::StrictJSON); return toRef(exec, parser.tryLiteralParse()); }
TiValueRef TiValueMakeString(TiContextRef ctx, TiStringRef string) { TiExcState* exec = toJS(ctx); APIEntryShim entryShim(exec); return toRef(exec, jsString(exec, string->ustring())); }