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


C++ JSFunction::hasScript方法代码示例

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


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

示例1: if

bool
TypeInferenceOracle::analyzeTypesForInlinableCallees(JSContext *cx, StackTypeSet *calleeTypes,
                                                     Vector<JSScript*> &seen)
{
    if (calleeTypes->unknownObject())
        return true;

    size_t count = calleeTypes->getObjectCount();
    for (size_t i = 0; i < count; i++) {
        JSScript *script;
        if (JSObject *singleton = calleeTypes->getSingleObject(i)) {
            if (!singleton->isFunction() || !singleton->toFunction()->hasScript())
                continue;
            script = singleton->toFunction()->nonLazyScript();
        } else if (TypeObject *type = calleeTypes->getTypeObject(i)) {
            JSFunction *fun = type->interpretedFunction;
            if (!fun || !fun->hasScript())
                continue;
            script = fun->nonLazyScript();
        } else {
            continue;
        }

        if (!analyzeTypesForInlinableCallees(cx, script, seen))
            return false;

        // The contents of type sets can change after analyzing the types in a
        // script. Make a sanity check to ensure the set is ok to keep using.
        if (calleeTypes->unknownObject() || calleeTypes->getObjectCount() != count)
            break;
    }

    return true;
}
开发者ID:Tripleman,项目名称:mozilla-central,代码行数:34,代码来源:TypeOracle.cpp

示例2: CallArgsFromVp

static bool
IsRelazifiableFunction(JSContext *cx, unsigned argc, Value *vp)
{
    CallArgs args = CallArgsFromVp(argc, vp);
    if (argc != 1) {
        JS_ReportError(cx, "The function takes exactly one argument.");
        return false;
    }
    if (!args[0].isObject() ||
        !args[0].toObject().is<JSFunction>())
    {
        JS_ReportError(cx, "The first argument should be a function.");
        return true;
    }

    JSFunction *fun = &args[0].toObject().as<JSFunction>();
    args.rval().setBoolean(fun->hasScript() && fun->nonLazyScript()->isRelazifiable());
    return true;
}
开发者ID:JCROM-FxOS,项目名称:b2jc_gecko,代码行数:19,代码来源:TestingFunctions.cpp

示例3: if

static void
MarkFunctionsWithinEvalScript(JSScript *script)
{
    // Mark top level functions in an eval script as being within an eval and,
    // if applicable, inside a with statement.

    if (!script->hasObjects())
        return;

    ObjectArray *objects = script->objects();
    size_t start = script->innerObjectsStart();

    for (size_t i = start; i < objects->length; i++) {
        JSObject *obj = objects->vector[i];
        if (obj->is<JSFunction>()) {
            JSFunction *fun = &obj->as<JSFunction>();
            if (fun->hasScript())
                fun->nonLazyScript()->setDirectlyInsideEval();
            else if (fun->isInterpretedLazy())
                fun->lazyScript()->setDirectlyInsideEval();
        }
    }
}
开发者ID:JuannyWang,项目名称:gecko-dev,代码行数:23,代码来源:Eval.cpp


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