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


C++ JSScript::argsObjAliasesFormals方法代码示例

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


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

示例1: ObjectValue

/* static */ void
ArgumentsObject::MaybeForwardToCallObject(AbstractFramePtr frame, ArgumentsObject* obj,
                                          ArgumentsData* data)
{
    JSScript* script = frame.script();
    if (frame.fun()->needsCallObject() && script->argsObjAliasesFormals()) {
        obj->initFixedSlot(MAYBE_CALL_SLOT, ObjectValue(frame.callObj()));
        for (AliasedFormalIter fi(script); fi; fi++)
            data->args[fi.frameIndex()] = MagicScopeSlotValue(fi.scopeSlot());
    }
}
开发者ID:TechnoAyan,项目名称:gecko-dev,代码行数:11,代码来源:ArgumentsObject.cpp

示例2: ObjectValue

/* static */ void
ArgumentsObject::MaybeForwardToCallObject(ion::IonJSFrameLayout *frame, HandleObject callObj,
                                          JSObject *obj, ArgumentsData *data)
{
    JSFunction *callee = ion::CalleeTokenToFunction(frame->calleeToken());
    JSScript *script = callee->nonLazyScript();
    if (callee->isHeavyweight() && script->argsObjAliasesFormals()) {
        JS_ASSERT(callObj && callObj->isCall());
        obj->initFixedSlot(MAYBE_CALL_SLOT, ObjectValue(*callObj.get()));
        for (AliasedFormalIter fi(script); fi; fi++)
            data->args[fi.frameIndex()] = MagicValue(JS_FORWARD_TO_CALL_OBJECT);
    }
}
开发者ID:,项目名称:,代码行数:13,代码来源:

示例3: proto

ArgumentsObject *
ArgumentsObject::create(JSContext *cx, StackFrame *fp)
{
    JSFunction &callee = fp->callee();
    RootedObject proto(cx, callee.global().getOrCreateObjectPrototype(cx));
    if (!proto)
        return NULL;

    RootedTypeObject type(cx);
    type = proto->getNewType(cx);
    if (!type)
        return NULL;

    bool strict = callee.inStrictMode();
    Class *clasp = strict ? &StrictArgumentsObjectClass : &NormalArgumentsObjectClass;

    RootedShape emptyArgumentsShape(cx);
    emptyArgumentsShape =
        EmptyShape::getInitialShape(cx, clasp, proto,
                                    proto->getParent(), FINALIZE_KIND,
                                    BaseShape::INDEXED);
    if (!emptyArgumentsShape)
        return NULL;

    unsigned numActuals = fp->numActualArgs();
    unsigned numFormals = fp->numFormalArgs();
    unsigned numDeletedWords = NumWordsForBitArrayOfLength(numActuals);
    unsigned numArgs = Max(numActuals, numFormals);
    unsigned numBytes = offsetof(ArgumentsData, args) +
                        numDeletedWords * sizeof(size_t) +
                        numArgs * sizeof(Value);

    ArgumentsData *data = (ArgumentsData *)cx->malloc_(numBytes);
    if (!data)
        return NULL;

    data->numArgs = numArgs;
    data->callee.init(ObjectValue(callee));
    data->script = fp->script();

    /* Copy [0, numArgs) into data->slots. */
    HeapValue *dst = data->args, *dstEnd = data->args + numArgs;
    for (Value *src = fp->formals(), *end = src + numFormals; src != end; ++src, ++dst)
        dst->init(*src);
    if (numActuals > numFormals) {
        for (Value *src = fp->actuals() + numFormals; dst != dstEnd; ++src, ++dst)
            dst->init(*src);
    } else if (numActuals < numFormals) {
        for (; dst != dstEnd; ++dst)
            dst->init(UndefinedValue());
    }

    data->deletedBits = reinterpret_cast<size_t *>(dstEnd);
    ClearAllBitArrayElements(data->deletedBits, numDeletedWords);

    JSObject *obj = JSObject::create(cx, FINALIZE_KIND, emptyArgumentsShape, type, NULL);
    if (!obj)
        return NULL;

    obj->initFixedSlot(INITIAL_LENGTH_SLOT, Int32Value(numActuals << PACKED_BITS_COUNT));
    obj->initFixedSlot(DATA_SLOT, PrivateValue(data));

    /*
     * If it exists and the arguments object aliases formals, the call object
     * is the canonical location for formals.
     */
    JSScript *script = fp->script();
    if (fp->fun()->isHeavyweight() && script->argsObjAliasesFormals()) {
        obj->initFixedSlot(MAYBE_CALL_SLOT, ObjectValue(fp->callObj()));

        /* Flag each slot that canonically lives in the callObj. */
        if (script->bindingsAccessedDynamically) {
            for (unsigned i = 0; i < numFormals; ++i)
                data->args[i] = MagicValue(JS_FORWARD_TO_CALL_OBJECT);
        } else {
            for (unsigned i = 0; i < script->numClosedArgs(); ++i)
                data->args[script->getClosedArg(i)] = MagicValue(JS_FORWARD_TO_CALL_OBJECT);
        }
    }

    ArgumentsObject &argsobj = obj->asArguments();
    JS_ASSERT(argsobj.initialLength() == numActuals);
    JS_ASSERT(!argsobj.hasOverriddenLength());
    return &argsobj;
}
开发者ID:msliu,项目名称:mozilla-central,代码行数:85,代码来源:ArgumentsObject.cpp


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