本文整理汇总了C++中ExecState类的典型用法代码示例。如果您正苦于以下问题:C++ ExecState类的具体用法?C++ ExecState怎么用?C++ ExecState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ExecState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: linkFor
inline char* linkFor(ExecState* execCallee, CodeSpecializationKind kind)
{
ExecState* exec = execCallee->callerFrame();
VM* vm = &exec->vm();
NativeCallFrameTracer tracer(vm, exec);
JSValue calleeAsValue = execCallee->calleeAsValue();
JSCell* calleeAsFunctionCell = getJSFunction(calleeAsValue);
if (!calleeAsFunctionCell)
return reinterpret_cast<char*>(handleHostCall(execCallee, calleeAsValue, kind));
JSFunction* callee = jsCast<JSFunction*>(calleeAsFunctionCell);
execCallee->setScope(callee->scopeUnchecked());
ExecutableBase* executable = callee->executable();
MacroAssemblerCodePtr codePtr;
CodeBlock* codeBlock = 0;
if (executable->isHostFunction())
codePtr = executable->generatedJITCodeFor(kind)->addressForCall();
else {
FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
JSObject* error = functionExecutable->prepareForExecution(execCallee, callee->scope(), kind);
if (error) {
vm->throwException(exec, createStackOverflowError(exec));
return reinterpret_cast<char*>(vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress());
}
codeBlock = functionExecutable->codeBlockFor(kind);
if (execCallee->argumentCountIncludingThis() < static_cast<size_t>(codeBlock->numParameters()))
codePtr = functionExecutable->generatedJITCodeWithArityCheckFor(kind);
else
codePtr = functionExecutable->generatedJITCodeFor(kind)->addressForCall();
}
CallLinkInfo& callLinkInfo = exec->codeBlock()->getCallLinkInfo(execCallee->returnPC());
if (!callLinkInfo.seenOnce())
callLinkInfo.setSeen();
else
linkFor(execCallee, callLinkInfo, codeBlock, callee, codePtr, kind);
return reinterpret_cast<char*>(codePtr.executableAddress());
}
示例2: linkFor
inline void* linkFor(ExecState* execCallee, ReturnAddressPtr returnAddress, CodeSpecializationKind kind)
{
ExecState* exec = execCallee->callerFrame();
JSGlobalData* globalData = &exec->globalData();
NativeCallFrameTracer tracer(globalData, exec);
JSValue calleeAsValue = execCallee->calleeAsValue();
JSCell* calleeAsFunctionCell = getJSFunction(calleeAsValue);
if (!calleeAsFunctionCell)
return handleHostCall(execCallee, calleeAsValue, kind);
JSFunction* callee = asFunction(calleeAsFunctionCell);
execCallee->setScopeChain(callee->scopeUnchecked());
ExecutableBase* executable = callee->executable();
MacroAssemblerCodePtr codePtr;
CodeBlock* codeBlock = 0;
if (executable->isHostFunction())
codePtr = executable->generatedJITCodeFor(kind).addressForCall();
else {
FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
JSObject* error = functionExecutable->compileFor(execCallee, callee->scope(), kind);
if (error) {
globalData->exception = createStackOverflowError(exec);
return 0;
}
codeBlock = &functionExecutable->generatedBytecodeFor(kind);
if (execCallee->argumentCountIncludingThis() < static_cast<size_t>(codeBlock->numParameters()))
codePtr = functionExecutable->generatedJITCodeWithArityCheckFor(kind);
else
codePtr = functionExecutable->generatedJITCodeFor(kind).addressForCall();
}
CallLinkInfo& callLinkInfo = exec->codeBlock()->getCallLinkInfo(returnAddress);
if (!callLinkInfo.seenOnce())
callLinkInfo.setSeen();
else
dfgLinkFor(execCallee, callLinkInfo, codeBlock, callee, codePtr, kind);
return codePtr.executableAddress();
}
示例3: getContext
JSValue JSHTMLCanvasElement::getContext(ExecState& state)
{
if (UNLIKELY(state.argumentCount() < 1))
return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
HTMLCanvasElement& canvas = wrapped();
const String& contextId = state.uncheckedArgument(0).toWTFString(&state);
RefPtr<CanvasContextAttributes> attrs;
#if ENABLE(WEBGL)
if (HTMLCanvasElement::is3dType(contextId)) {
get3DContextAttributes(state, attrs);
if (state.hadException())
return jsUndefined();
}
#endif
CanvasRenderingContext* context = canvas.getContext(contextId, attrs.get());
if (!context)
return jsNull();
return toJS(&state, globalObject(), *context);
}
示例4: JSObjectMakeFunction
JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return 0;
}
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
startingLineNumber = std::max(1, startingLineNumber);
Identifier nameID = name ? name->identifier(&exec->vm()) : Identifier::fromString(exec, "anonymous");
MarkedArgumentBuffer args;
for (unsigned i = 0; i < parameterCount; i++)
args.append(jsString(exec, parameterNames[i]->string()));
args.append(jsString(exec, body->string()));
JSObject* result = constructFunction(exec, exec->lexicalGlobalObject(), args, nameID, sourceURL ? sourceURL->string() : String(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first()));
if (handleExceptionIfNeeded(exec, exception) == ExceptionStatus::DidThrow)
result = 0;
return toRef(result);
}
示例5: JSObjectDeletePrivateProperty
bool JSObjectDeletePrivateProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName)
{
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
JSObject* jsObject = toJS(object);
Identifier name(propertyName->identifier(&exec->globalData()));
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info)) {
jsCast<JSCallbackObject<JSGlobalObject>*>(jsObject)->deletePrivateProperty(name);
return true;
}
if (jsObject->inherits(&JSCallbackObject<JSDestructibleObject>::s_info)) {
jsCast<JSCallbackObject<JSDestructibleObject>*>(jsObject)->deletePrivateProperty(name);
return true;
}
#if JSC_OBJC_API_ENABLED
if (jsObject->inherits(&JSCallbackObject<JSAPIWrapperObject>::s_info)) {
jsCast<JSCallbackObject<JSAPIWrapperObject>*>(jsObject)->deletePrivateProperty(name);
return true;
}
#endif
return false;
}
示例6: ASSERT
String JSCustomXPathNSResolver::lookupNamespaceURI(const String& prefix)
{
ASSERT(m_customResolver);
JSLockHolder lock(JSDOMWindowBase::commonVM());
ExecState* exec = m_globalObject->globalExec();
JSValue function = m_customResolver->get(exec, Identifier(exec, "lookupNamespaceURI"));
CallData callData;
CallType callType = getCallData(function, callData);
if (callType == CallTypeNone) {
callType = m_customResolver->methodTable()->getCallData(m_customResolver.get(), callData);
if (callType == CallTypeNone) {
// FIXME: <http://webkit.org/b/114312> JSCustomXPathNSResolver::lookupNamespaceURI Console Message should include Line, Column, and SourceURL
if (PageConsole* console = m_globalObject->impl().pageConsole())
console->addMessage(JSMessageSource, ErrorMessageLevel, "XPathNSResolver does not have a lookupNamespaceURI method.");
return String();
}
function = m_customResolver.get();
}
Ref<JSCustomXPathNSResolver> selfProtector(*this);
MarkedArgumentBuffer args;
args.append(jsStringWithCache(exec, prefix));
JSValue retval = JSMainThreadExecState::call(exec, function, callType, callData, m_customResolver.get(), args);
String result;
if (exec->hadException())
reportCurrentException(exec);
else {
if (!retval.isUndefinedOrNull())
result = retval.toString(exec)->value(exec);
}
return result;
}
示例7: showContextMenu
JSValue JSInspectorFrontendHost::showContextMenu(ExecState& state)
{
#if ENABLE(CONTEXT_MENUS)
if (state.argumentCount() < 2)
return jsUndefined();
Event* event = JSEvent::toWrapped(state.argument(0));
JSArray* array = asArray(state.argument(1));
ContextMenu menu;
populateContextMenuItems(&state, array, menu);
#if !USE(CROSS_PLATFORM_CONTEXT_MENUS)
Vector<ContextMenuItem> items = contextMenuItemVector(menu.platformDescription());
#else
Vector<ContextMenuItem> items = menu.items();
#endif
impl().showContextMenu(event, items);
#else
UNUSED_PARAM(state);
#endif
return jsUndefined();
}
示例8: JSObjectSetProperty
void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception)
{
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
JSObject* jsObject = toJS(object);
Identifier name(propertyName->identifier(&exec->globalData()));
JSValue jsValue = toJS(exec, value);
if (attributes && !jsObject->hasProperty(exec, name))
jsObject->methodTable()->putDirectVirtual(jsObject, exec, name, jsValue, attributes);
else {
PutPropertySlot slot;
jsObject->methodTable()->put(jsObject, exec, name, jsValue, slot);
}
if (exec->hadException()) {
if (exception)
*exception = toRef(exec, exec->exception());
exec->clearException();
}
}
示例9: JSObjectMakeError
JSObjectRef JSObjectMakeError(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return 0;
}
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
JSValue message = argumentCount ? toJS(exec, arguments[0]) : jsUndefined();
Structure* errorStructure = exec->lexicalGlobalObject()->errorStructure();
JSObject* result = ErrorInstance::create(exec, errorStructure, message);
if (exec->hadException()) {
if (exception)
*exception = toRef(exec, exec->exception());
exec->clearException();
result = 0;
}
return toRef(result);
}
示例10: getAttachedShaders
JSValue JSWebGLRenderingContextBase::getAttachedShaders(ExecState& state)
{
if (state.argumentCount() < 1)
return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
ExceptionCode ec = 0;
WebGLRenderingContextBase& context = wrapped();
WebGLProgram* program = JSWebGLProgram::toWrapped(state.uncheckedArgument(0));
if (!program && !state.uncheckedArgument(0).isUndefinedOrNull())
return throwTypeError(&state);
Vector<RefPtr<WebGLShader>> shaders;
bool succeed = context.getAttachedShaders(program, shaders, ec);
if (ec) {
setDOMException(&state, ec);
return jsNull();
}
if (!succeed)
return jsNull();
JSC::MarkedArgumentBuffer list;
for (size_t ii = 0; ii < shaders.size(); ++ii)
list.append(toJS(&state, globalObject(), shaders[ii].get()));
return constructArray(&state, 0, globalObject(), list);
}
示例11: JSCheckScriptSyntax
bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return false;
}
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
SourceCode source = makeSource(script->string(), sourceURL->string(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first()));
JSValue syntaxException;
bool isValidSyntax = checkSyntax(exec->dynamicGlobalObject()->globalExec(), source, &syntaxException);
if (!isValidSyntax) {
if (exception)
*exception = toRef(exec, syntaxException);
return false;
}
return true;
}
示例12: JSObjectGetPrivateProperty
JSValueRef JSObjectGetPrivateProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName)
{
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
JSObject* jsObject = toJS(object);
JSValue result;
Identifier name(propertyName->identifier(&exec->vm()));
// Get wrapped object if proxied
if (jsObject->inherits(JSProxy::info()))
jsObject = jsCast<JSProxy*>(jsObject)->target();
if (jsObject->inherits(JSCallbackObject<JSGlobalObject>::info()))
result = jsCast<JSCallbackObject<JSGlobalObject>*>(jsObject)->getPrivateProperty(name);
else if (jsObject->inherits(JSCallbackObject<JSDestructibleObject>::info()))
result = jsCast<JSCallbackObject<JSDestructibleObject>*>(jsObject)->getPrivateProperty(name);
#if JSC_OBJC_API_ENABLED
else if (jsObject->inherits(JSCallbackObject<JSAPIWrapperObject>::info()))
result = jsCast<JSCallbackObject<JSAPIWrapperObject>*>(jsObject)->getPrivateProperty(name);
#endif
return toRef(exec, result);
}
示例13: JSObjectSetPrototype
void JSObjectSetPrototype(JSContextRef ctx, JSObjectRef object, JSValueRef value)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return;
}
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
JSObject* jsObject = toJS(object);
JSValue jsValue = toJS(exec, value);
if (JSProxy* proxy = jsDynamicCast<JSProxy*>(jsObject)) {
if (JSGlobalObject* globalObject = jsDynamicCast<JSGlobalObject*>(proxy->target())) {
globalObject->resetPrototype(exec->vm(), jsValue.isObject() ? jsValue : jsNull());
return;
}
// Someday we might use proxies for something other than JSGlobalObjects, but today is not that day.
RELEASE_ASSERT_NOT_REACHED();
}
jsObject->setPrototype(exec->vm(), exec, jsValue.isObject() ? jsValue : jsNull());
}
示例14: DECLARE_THROW_SCOPE
JSValue JSWebKitSubtleCrypto::generateKey(ExecState& state)
{
VM& vm = state.vm();
auto scope = DECLARE_THROW_SCOPE(vm);
if (state.argumentCount() < 1)
return throwException(&state, scope, createNotEnoughArgumentsError(&state));
auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
ASSERT(scope.exception() || algorithm);
if (!algorithm)
return jsUndefined();
auto parameters = JSCryptoAlgorithmDictionary::createParametersForGenerateKey(&state, algorithm->identifier(), state.uncheckedArgument(0));
ASSERT(scope.exception() || parameters);
if (!parameters)
return jsUndefined();
bool extractable = false;
if (state.argumentCount() >= 2) {
extractable = state.uncheckedArgument(1).toBoolean(&state);
RETURN_IF_EXCEPTION(scope, JSValue());
}
CryptoKeyUsageBitmap keyUsages = 0;
if (state.argumentCount() >= 3) {
auto success = cryptoKeyUsagesFromJSValue(state, state.argument(2), keyUsages);
ASSERT(scope.exception() || success);
if (!success)
return jsUndefined();
}
RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
auto promise = wrapper->promise();
auto successCallback = [wrapper](CryptoKey* key, CryptoKeyPair* keyPair) mutable {
ASSERT(key || keyPair);
ASSERT(!key || !keyPair);
if (key)
wrapper->resolve(key);
else
wrapper->resolve(keyPair);
};
auto failureCallback = [wrapper]() mutable {
wrapper->reject(nullptr);
};
auto result = algorithm->generateKey(*parameters, extractable, keyUsages, WTFMove(successCallback), WTFMove(failureCallback), *scriptExecutionContextFromExecState(&state));
if (result.hasException()) {
propagateException(state, scope, result.releaseException());
return { };
}
return promise;
}
示例15: ASSERT
void JSCustomVoidCallback::handleEvent()
{
ASSERT(m_callback);
ASSERT(m_frame);
if (!m_frame->script()->isEnabled())
return;
JSGlobalObject* globalObject = m_frame->script()->globalObject();
ExecState* exec = globalObject->globalExec();
KJS::JSLock lock(false);
JSValue* function = m_callback->get(exec, Identifier(exec, "handleEvent"));
CallData callData;
CallType callType = function->getCallData(callData);
if (callType == CallTypeNone) {
callType = m_callback->getCallData(callData);
if (callType == CallTypeNone) {
// FIXME: Should an exception be thrown here?
return;
}
function = m_callback;
}
RefPtr<JSCustomVoidCallback> protect(this);
ArgList args;
globalObject->startTimeoutCheck();
call(exec, function, callType, callData, m_callback, args);
globalObject->stopTimeoutCheck();
if (exec->hadException())
m_frame->domWindow()->console()->reportCurrentException(exec);
Document::updateDocumentsRendering();
}