JSValueRef JSEvaluateScriptInternal(const JSLockHolder&, ExecState* exec, JSContextRef ctx, JSObjectRef thisObject, const SourceCode& source, JSValueRef* exception) { UNUSED_PARAM(ctx); JSObject* jsThisObject = toJS(thisObject); // evaluate sets "this" to the global object if it is NULL VM& vm = exec->vm(); JSGlobalObject* globalObject = vm.vmEntryGlobalObject(exec); NakedPtr<Exception> evaluationException; JSValue returnValue = profiledEvaluate(globalObject->globalExec(), ProfilingReason::API, source, jsThisObject, evaluationException); if (evaluationException) { if (exception) *exception = toRef(exec, evaluationException->value()); #if ENABLE(REMOTE_INSPECTOR) // FIXME: If we have a debugger attached we could learn about ParseError exceptions through // ScriptDebugServer::sourceParsed and this path could produce a duplicate warning. The // Debugger path is currently ignored by inspector. // NOTE: If we don't have a debugger, this SourceCode will be forever lost to the inspector. // We could stash it in the inspector in case an inspector is ever opened. globalObject->inspectorController().reportAPIException(exec, evaluationException); #endif return nullptr; } if (returnValue) return toRef(exec, returnValue); // happens, for example, when the only statement is an empty (';') statement return toRef(exec, jsUndefined()); }
void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSGlobalContextRef ctx, bool includesNativeCallStack) { #if ENABLE(REMOTE_INSPECTOR) if (!ctx) { ASSERT_NOT_REACHED(); return; } ExecState* exec = toJS(ctx); JSLockHolder lock(exec); JSGlobalObject* globalObject = exec->vmEntryGlobalObject(); globalObject->inspectorController().setIncludesNativeCallStackWhenReportingExceptions(includesNativeCallStack); #else UNUSED_PARAM(ctx); UNUSED_PARAM(includesNativeCallStack); #endif }
JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception) { if (!ctx) { ASSERT_NOT_REACHED(); return 0; } ExecState* exec = toJS(ctx); JSLockHolder locker(exec); JSObject* jsThisObject = toJS(thisObject); startingLineNumber = std::max(1, startingLineNumber); // evaluate sets "this" to the global object if it is NULL JSGlobalObject* globalObject = exec->vmEntryGlobalObject(); auto sourceURLString = sourceURL ? sourceURL->string() : String(); SourceCode source = makeSource(script->string(), SourceOrigin { sourceURLString }, sourceURLString, TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber())); NakedPtr<Exception> evaluationException; JSValue returnValue = profiledEvaluate(globalObject->globalExec(), ProfilingReason::API, source, jsThisObject, evaluationException); if (evaluationException) { if (exception) *exception = toRef(exec, evaluationException->value()); #if ENABLE(REMOTE_INSPECTOR) // FIXME: If we have a debugger attached we could learn about ParseError exceptions through // ScriptDebugServer::sourceParsed and this path could produce a duplicate warning. The // Debugger path is currently ignored by inspector. // NOTE: If we don't have a debugger, this SourceCode will be forever lost to the inspector. // We could stash it in the inspector in case an inspector is ever opened. globalObject->inspectorController().reportAPIException(exec, evaluationException); #endif return 0; } if (returnValue) return toRef(exec, returnValue); // happens, for example, when the only statement is an empty (';') statement return toRef(exec, jsUndefined()); }