当前位置: 首页>>代码示例>>C++>>正文


C++ NumberObject类代码示例

本文整理汇总了C++中NumberObject的典型用法代码示例。如果您正苦于以下问题:C++ NumberObject类的具体用法?C++ NumberObject怎么用?C++ NumberObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了NumberObject类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: constructWithNumberConstructor

// ECMA 15.7.1
static EncodedJSValue JSC_HOST_CALL constructWithNumberConstructor(ExecState* exec)
{
    NumberObject* object = new (exec) NumberObject(exec->lexicalGlobalObject()->numberObjectStructure());
    double n = exec->argumentCount() ? exec->argument(0).toNumber(exec) : 0;
    object->setInternalValue(jsNumber(exec, n));
    return JSValue::encode(object);
}
开发者ID:mikedougherty,项目名称:webkit,代码行数:8,代码来源:NumberConstructor.cpp

示例2: constructWithNumberConstructor

// ECMA 15.7.1
static EncodedJSValue JSC_HOST_CALL constructWithNumberConstructor(ExecState* exec)
{
    NumberObject* object = NumberObject::create(exec->vm(), asInternalFunction(exec->callee())->globalObject()->numberObjectStructure());
    double n = exec->argumentCount() ? exec->uncheckedArgument(0).toNumber(exec) : 0;
    object->setInternalValue(exec->vm(), jsNumber(n));
    return JSValue::encode(object);
}
开发者ID:CannedFish,项目名称:webkit,代码行数:8,代码来源:NumberConstructor.cpp

示例3: constructWithNumberConstructor

// ECMA 15.7.1
static JSObject* constructWithNumberConstructor(ExecState* exec, JSObject*, const ArgList& args)
{
    NumberObject* object = new (exec) NumberObject(exec->lexicalGlobalObject()->numberObjectStructure());
    double n = args.isEmpty() ? 0 : args.at(0).toNumber(exec);
    object->setInternalValue(jsNumber(exec, n));
    return object;
}
开发者ID:325116067,项目名称:semc-qsd8x50,代码行数:8,代码来源:NumberConstructor.cpp

示例4: thisNumberValue

inline ReturnedValue thisNumberValue(ExecutionContext *ctx)
{
    if (ctx->thisObject().isNumber())
        return ctx->thisObject().asReturnedValue();
    NumberObject *n = ctx->thisObject().asNumberObject();
    if (!n)
        return ctx->engine()->throwTypeError();
    return Encode(n->value());
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:9,代码来源:qv4numberobject.cpp

示例5: thisNumber

inline double thisNumber(ExecutionContext *ctx)
{
    if (ctx->thisObject().isNumber())
        return ctx->thisObject().asDouble();
    NumberObject *n = ctx->thisObject().asNumberObject();
    if (!n)
        return ctx->engine()->throwTypeError();
    return n->value();
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:9,代码来源:qv4numberobject.cpp

示例6: constructWithNumberConstructor

// ECMA 15.7.1
static EncodedJSValue JSC_HOST_CALL constructWithNumberConstructor(ExecState* exec)
{
    double n = exec->argumentCount() ? exec->uncheckedArgument(0).toNumber(exec) : 0;
    Structure* structure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), exec->lexicalGlobalObject()->numberObjectStructure());
    if (exec->hadException())
        return JSValue::encode(JSValue());

    NumberObject* object = NumberObject::create(exec->vm(), structure);
    object->setInternalValue(exec->vm(), jsNumber(n));
    return JSValue::encode(object);
}
开发者ID:Comcast,项目名称:WebKitForWayland,代码行数:12,代码来源:NumberConstructor.cpp

示例7: constructWithNumberConstructor

// ECMA 15.7.1
static EncodedJSValue JSC_HOST_CALL constructWithNumberConstructor(ExecState* exec)
{
    VM& vm = exec->vm();
    auto scope = DECLARE_THROW_SCOPE(vm);
    double n = exec->argumentCount() ? exec->uncheckedArgument(0).toNumber(exec) : 0;
    Structure* structure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), exec->lexicalGlobalObject()->numberObjectStructure());
    RETURN_IF_EXCEPTION(scope, encodedJSValue());

    NumberObject* object = NumberObject::create(exec->vm(), structure);
    object->setInternalValue(exec->vm(), jsNumber(n));
    return JSValue::encode(object);
}
开发者ID:ollie314,项目名称:webkit,代码行数:13,代码来源:NumberConstructor.cpp

示例8: promiseAllCountdownFunction

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());
}
开发者ID:violetbaddley,项目名称:WebKit-Persona,代码行数:41,代码来源:JSPromiseFunctions.cpp

示例9: getGameNumber

int GameSelectWorld::getGameNumber(Room *room)
{
    NumberObject *first = NULL, *second = NULL;
    int gameNumber = 0;

    for (UINT i=0; i<room->getObjects()->length(); i++)
    {
        if ( (first != NULL) && (second != NULL) )
            break;
        GameObject *object = (GameObject *)(room->getObjects()->elementAt(i));
        if ( (object->getType() == GameObject::GAMEOBJECT_TYPE_NUMBER) &&
                (object->getIsBeingHeld() == FALSE) )
        {
            if (first != NULL)
                second = (NumberObject *)object;
            else
                first = (NumberObject *)object;
        }
    }
    if (first != NULL)
    {


        if (second == NULL)
        {
            gameNumber = first->getNumber();
        }
        else
        {
            // the game number is the number as readable on screen (ignoring vertical
            // position)
            if (first->getX() < second->getX())
                gameNumber = ( first->getNumber() * 10 ) + second->getNumber();
            else
                gameNumber = ( second->getNumber() * 10 ) + first->getNumber();
        }
    }
    return gameNumber;

}
开发者ID:davetron5000,项目名称:adventureclone,代码行数:40,代码来源:GameSelectWorld.cpp

示例10: constructNumber

NumberObject* constructNumber(ExecState* exec, JSGlobalObject* globalObject, JSValue number)
{
    NumberObject* object = NumberObject::create(exec->globalData(), globalObject->numberObjectStructure());
    object->setInternalValue(exec->globalData(), number);
    return object;
}
开发者ID:CannedFish,项目名称:deepin-webkit,代码行数:6,代码来源:NumberObject.cpp

示例11: constructNumberFromImmediateNumber

NumberObject* constructNumberFromImmediateNumber(ExecState* exec, JSValue* value)
{
    NumberObject* obj = new (exec) NumberObject(exec->lexicalGlobalObject()->numberPrototype());
    obj->setInternalValue(value);
    return obj;
}
开发者ID:Chingliu,项目名称:EAWebkit,代码行数:6,代码来源:NumberConstructor.cpp

示例12: constructNumber

NumberObject* constructNumber(ExecState* exec, JSNumberCell* number)
{
    NumberObject* obj = new (exec) NumberObject(exec->lexicalGlobalObject()->numberPrototype());
    obj->setInternalValue(number);
    return obj;
}
开发者ID:Chingliu,项目名称:EAWebkit,代码行数:6,代码来源:NumberConstructor.cpp

示例13: performPromiseAll

static JSValue performPromiseAll(ExecState* exec, JSValue iterator, JSValue C, JSPromiseDeferred* deferred)
{
    JSObject* thisObject = asObject(C);
    VM& vm = exec->vm();

    // 6. Let 'values' be the result of calling ArrayCreate(0).
    JSArray* values = constructEmptyArray(exec, nullptr, thisObject->globalObject());

    // 7. Let 'countdownHolder' be Record { [[Countdown]]: 0 }.
    NumberObject* countdownHolder = constructNumber(exec, thisObject->globalObject(), JSValue(0));

    // 8. Let 'index' be 0.
    unsigned index = 0;

    // 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);

//.........这里部分代码省略.........
开发者ID:mu326668629,项目名称:webkit,代码行数:101,代码来源:JSPromiseConstructor.cpp


注:本文中的NumberObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。