JSValue DebuggerCallFrame::evaluateNonBlocking(const String& script, NakedPtr<Exception>& exception) { ASSERT(isValid()); CallFrame* callFrame = m_callFrame; if (!callFrame) return jsNull(); if (!callFrame->codeBlock()) return JSValue(); DebuggerEvalEnabler evalEnabler(callFrame); VM& vm = callFrame->vm(); auto& codeBlock = *callFrame->codeBlock(); ThisTDZMode thisTDZMode = codeBlock.unlinkedCodeBlock()->constructorKind() == ConstructorKind::Derived ? ThisTDZMode::AlwaysCheck : ThisTDZMode::CheckIfNeeded; VariableEnvironment variablesUnderTDZ; JSScope::collectVariablesUnderTDZ(scope()->jsScope(), variablesUnderTDZ); EvalExecutable* eval = EvalExecutable::create(callFrame, makeSource(script), codeBlock.isStrictMode(), thisTDZMode, codeBlock.unlinkedCodeBlock()->isDerivedConstructorContext(), codeBlock.unlinkedCodeBlock()->isArrowFunction(), &variablesUnderTDZ); if (vm.exception()) { exception = vm.exception(); vm.clearException(); return jsUndefined(); } JSValue thisValue = thisValueForCallFrame(callFrame); JSValue result = vm.interpreter->execute(eval, callFrame, thisValue, scope()->jsScope()); if (vm.exception()) { exception = vm.exception(); vm.clearException(); } ASSERT(result); return result; }
// Evaluate some JavaScript code in the scope of this frame. JSValue DebuggerCallFrame::evaluateWithScopeExtension(const String& script, JSObject* scopeExtensionObject, NakedPtr<Exception>& exception) { ASSERT(isValid()); CallFrame* callFrame = m_validMachineFrame; if (!callFrame) return jsUndefined(); VM& vm = callFrame->vm(); JSLockHolder lock(vm); auto catchScope = DECLARE_CATCH_SCOPE(vm); CodeBlock* codeBlock = nullptr; if (isTailDeleted()) codeBlock = m_shadowChickenFrame.codeBlock; else codeBlock = callFrame->codeBlock(); if (!codeBlock) return jsUndefined(); DebuggerEvalEnabler evalEnabler(callFrame); EvalContextType evalContextType; if (isFunctionParseMode(codeBlock->unlinkedCodeBlock()->parseMode())) evalContextType = EvalContextType::FunctionEvalContext; else if (codeBlock->unlinkedCodeBlock()->codeType() == EvalCode) evalContextType = codeBlock->unlinkedCodeBlock()->evalContextType(); else evalContextType = EvalContextType::None; VariableEnvironment variablesUnderTDZ; JSScope::collectClosureVariablesUnderTDZ(scope()->jsScope(), variablesUnderTDZ); EvalExecutable* eval = DirectEvalExecutable::create(callFrame, makeSource(script), codeBlock->isStrictMode(), codeBlock->unlinkedCodeBlock()->derivedContextType(), codeBlock->unlinkedCodeBlock()->isArrowFunction(), evalContextType, &variablesUnderTDZ); if (UNLIKELY(catchScope.exception())) { exception = catchScope.exception(); catchScope.clearException(); return jsUndefined(); } JSGlobalObject* globalObject = callFrame->vmEntryGlobalObject(); if (scopeExtensionObject) { JSScope* ignoredPreviousScope = globalObject->globalScope(); globalObject->setGlobalScopeExtension(JSWithScope::create(vm, globalObject, scopeExtensionObject, ignoredPreviousScope)); } JSValue thisValue = this->thisValue(); JSValue result = vm.interpreter->execute(eval, callFrame, thisValue, scope()->jsScope()); if (UNLIKELY(catchScope.exception())) { exception = catchScope.exception(); catchScope.clearException(); } if (scopeExtensionObject) globalObject->clearGlobalScopeExtension(); ASSERT(result); return result; }
Deprecated::ScriptValue InjectedScriptBase::callFunctionWithEvalEnabled(Deprecated::ScriptFunctionCall& function, bool& hadException) const { if (m_environment) m_environment->willCallInjectedScriptFunction(m_injectedScriptObject.scriptState(), name(), 1); JSC::ExecState* scriptState = m_injectedScriptObject.scriptState(); Deprecated::ScriptValue resultValue; { JSC::DebuggerEvalEnabler evalEnabler(scriptState); resultValue = function.call(hadException); } if (m_environment) m_environment->didCallInjectedScriptFunction(m_injectedScriptObject.scriptState()); return resultValue; }
JSC::JSValue InjectedScriptBase::callFunctionWithEvalEnabled(Deprecated::ScriptFunctionCall& function, bool& hadException) const { JSC::ExecState* scriptState = m_injectedScriptObject.scriptState(); JSC::DebuggerEvalEnabler evalEnabler(scriptState); return function.call(hadException); }