本文整理汇总了C++中JSGlobalObject::promiseStructure方法的典型用法代码示例。如果您正苦于以下问题:C++ JSGlobalObject::promiseStructure方法的具体用法?C++ JSGlobalObject::promiseStructure怎么用?C++ JSGlobalObject::promiseStructure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSGlobalObject
的用法示例。
在下文中一共展示了JSGlobalObject::promiseStructure方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: throwVMTypeError
static EncodedJSValue JSC_HOST_CALL constructPromise(ExecState* exec)
{
JSGlobalObject* globalObject = exec->callee()->globalObject();
VM& vm = exec->vm();
JSValue newTarget = exec->newTarget();
if (!newTarget || newTarget.isUndefined())
return throwVMTypeError(exec);
JSPromise* promise = JSPromise::create(vm, globalObject->promiseStructure());
if (!jsDynamicCast<JSPromiseConstructor*>(newTarget)) {
JSValue proto = asObject(newTarget)->getDirect(vm, vm.propertyNames->prototype);
asObject(promise)->setPrototypeWithCycleCheck(exec, proto);
}
promise->initialize(exec, globalObject, exec->argument(0));
return JSValue::encode(promise);
}
示例2: throwVMTypeError
static EncodedJSValue JSC_HOST_CALL constructPromise(ExecState* exec)
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSGlobalObject* globalObject = exec->jsCallee()->globalObject();
JSValue newTarget = exec->newTarget();
if (newTarget.isUndefined())
return throwVMTypeError(exec, scope);
Structure* promiseStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), globalObject->promiseStructure());
RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSPromise* promise = JSPromise::create(vm, promiseStructure);
promise->initialize(exec, globalObject, exec->argument(0));
return JSValue::encode(promise);
}