本文整理汇总了C++中NumberObject::internalValue方法的典型用法代码示例。如果您正苦于以下问题:C++ NumberObject::internalValue方法的具体用法?C++ NumberObject::internalValue怎么用?C++ NumberObject::internalValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NumberObject
的用法示例。
在下文中一共展示了NumberObject::internalValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: encode
static EncodedJSValue JSC_HOST_CALL promiseAllCountdownFunction(ExecState* exec)
{
JSValue x = exec->argument(0);
VM& vm = exec->vm();
JSObject* F = exec->callee();
// 1. Let 'index' be the value of F's [[Index]] internal slot.
uint32_t index = F->get(exec, vm.propertyNames->indexPrivateName).asUInt32();
// 2. Let 'values' be the value of F's [[Values]] internal slot..
JSArray* values = jsCast<JSArray*>(F->get(exec, vm.propertyNames->valuesPrivateName));
// 3. Let 'deferred' be the value of F's [[Deferred]] internal slot.
JSPromiseDeferred* deferred = jsCast<JSPromiseDeferred*>(F->get(exec, vm.propertyNames->deferredPrivateName));
// 4. Let 'countdownHolder' be the value of F's [[CountdownHolder]] internal slot.
NumberObject* countdownHolder = jsCast<NumberObject*>(F->get(exec, vm.propertyNames->countdownHolderPrivateName));
// 5. Let 'result' be the result of calling the [[DefineOwnProperty]] internal method
// of 'values' with arguments 'index' and Property Descriptor { [[Value]]: x,
// [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }.
values->putDirectIndex(exec, index, x);
// 6. RejectIfAbrupt(result, deferred).
if (exec->hadException())
abruptRejection(exec, deferred);
// 7. Set countdownHolder.[[Countdown]] to countdownHolder.[[Countdown]] - 1.
uint32_t newCountdownValue = countdownHolder->internalValue().asUInt32() - 1;
countdownHolder->setInternalValue(vm, JSValue(newCountdownValue));
// 8. If countdownHolder.[[Countdown]] is 0,
if (!newCountdownValue) {
// i. Return the result of calling the [[Call]] internal method of deferred.[[Resolve]]
// with undefined as thisArgument and a List containing 'values' as argumentsList.
performDeferredResolve(exec, deferred, values);
}
// 9. Return.
return JSValue::encode(jsUndefined());
}
示例2: performPromiseAll
//.........这里部分代码省略.........
// 9. Repeat.
do {
// i. Let 'next' be the result of calling IteratorStep(iterator).
JSValue next = iteratorStep(exec, iterator);
if (exec->hadException())
return jsUndefined();
// iii. If 'next' is false,
if (next.isFalse()) {
// a. If 'index' is 0,
if (!index) {
// a. Let 'resolveResult' be the result of calling the [[Call]] internal method
// of deferred.[[Resolve]] with undefined as thisArgument and a List containing
// values as argumentsList.
performDeferredResolve(exec, deferred, values);
// b. ReturnIfAbrupt(resolveResult).
if (exec->hadException())
return jsUndefined();
}
// b. Return deferred.[[Promise]].
return deferred->promise();
}
// iv. Let 'nextValue' be the result of calling IteratorValue(next).
// v. RejectIfAbrupt(nextValue, deferred).
JSValue nextValue = iteratorValue(exec, next);
if (exec->hadException())
return jsUndefined();
values->push(exec, jsUndefined());
// vi. Let 'nextPromise' be the result of calling Invoke(C, "resolve", (nextValue)).
JSValue resolveFunction = C.get(exec, vm.propertyNames->resolve);
if (exec->hadException())
return jsUndefined();
CallData resolveFunctionCallData;
CallType resolveFunctionCallType = getCallData(resolveFunction, resolveFunctionCallData);
if (resolveFunctionCallType == CallTypeNone) {
throwTypeError(exec);
return jsUndefined();
}
MarkedArgumentBuffer resolveFunctionArguments;
resolveFunctionArguments.append(nextValue);
JSValue nextPromise = call(exec, resolveFunction, resolveFunctionCallType, resolveFunctionCallData, C, resolveFunctionArguments);
// vii. RejectIfAbrupt(nextPromise, deferred).
if (exec->hadException())
return jsUndefined();
// viii. Let 'countdownFunction' be a new built-in function object as defined in Promise.all Countdown Functions.
JSFunction* countdownFunction = createPromiseAllCountdownFunction(vm, thisObject->globalObject());
// ix. Set the [[Index]] internal slot of 'countdownFunction' to 'index'.
countdownFunction->putDirect(vm, vm.propertyNames->indexPrivateName, JSValue(index));
// x. Set the [[Values]] internal slot of 'countdownFunction' to 'values'.
countdownFunction->putDirect(vm, vm.propertyNames->valuesPrivateName, values);
// xi. Set the [[Deferred]] internal slot of 'countdownFunction' to 'deferred'.
countdownFunction->putDirect(vm, vm.propertyNames->deferredPrivateName, deferred);
// xii. Set the [[CountdownHolder]] internal slot of 'countdownFunction' to 'countdownHolder'.
countdownFunction->putDirect(vm, vm.propertyNames->countdownHolderPrivateName, countdownHolder);
// xiii. Let 'result' be the result of calling Invoke(nextPromise, "then", (countdownFunction, deferred.[[Reject]])).
JSValue thenFunction = nextPromise.get(exec, vm.propertyNames->then);
if (exec->hadException())
return jsUndefined();
CallData thenFunctionCallData;
CallType thenFunctionCallType = getCallData(thenFunction, thenFunctionCallData);
if (thenFunctionCallType == CallTypeNone) {
throwTypeError(exec);
return jsUndefined();
}
MarkedArgumentBuffer thenFunctionArguments;
thenFunctionArguments.append(countdownFunction);
thenFunctionArguments.append(deferred->reject());
call(exec, thenFunction, thenFunctionCallType, thenFunctionCallData, nextPromise, thenFunctionArguments);
// xiv. RejectIfAbrupt(result, deferred).
if (exec->hadException())
return jsUndefined();
// xv. Set index to index + 1.
index++;
// xvi. Set countdownHolder.[[Countdown]] to countdownHolder.[[Countdown]] + 1.
uint32_t newCountdownValue = countdownHolder->internalValue().asUInt32() + 1;
countdownHolder->setInternalValue(vm, JSValue(newCountdownValue));
} while (true);
ASSERT_NOT_REACHED();
return jsUndefined();
}