本文整理汇总了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;
}
示例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;
}
示例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();
}
}
}