本文整理汇总了C++中MutableHandleFunction::native方法的典型用法代码示例。如果您正苦于以下问题:C++ MutableHandleFunction::native方法的具体用法?C++ MutableHandleFunction::native怎么用?C++ MutableHandleFunction::native使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MutableHandleFunction
的用法示例。
在下文中一共展示了MutableHandleFunction::native方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: skip
//.........这里部分代码省略.........
bool canLazilyParse = CanLazilyParse(cx, options);
Maybe<Parser<SyntaxParseHandler> > syntaxParser;
if (canLazilyParse) {
syntaxParser.construct(cx, &cx->tempLifoAlloc(),
options, chars, length, /* foldConstants = */ false,
(Parser<SyntaxParseHandler> *) NULL,
(LazyScript *) NULL);
}
JS_ASSERT(!options.forEval);
Parser<FullParseHandler> parser(cx, &cx->tempLifoAlloc(),
options, chars, length, /* foldConstants = */ true,
canLazilyParse ? &syntaxParser.ref() : NULL, NULL);
parser.sct = &sct;
parser.ss = ss;
JS_ASSERT(fun);
JS_ASSERT(fun->isTenured());
fun->setArgCount(formals.length());
// Speculatively parse using the default directives implied by the context.
// If a directive is encountered (e.g., "use strict") that changes how the
// function should have been parsed, we backup and reparse with the new set
// of directives.
Directives directives(options.strictOption);
TokenStream::Position start(parser.keepAtoms);
parser.tokenStream.tell(&start);
ParseNode *fn;
while (true) {
Directives newDirectives = directives;
fn = parser.standaloneFunctionBody(fun, formals, directives, &newDirectives);
if (fn)
break;
if (parser.hadAbortedSyntaxParse()) {
// Hit some unrecoverable ambiguity during an inner syntax parse.
// Syntax parsing has now been disabled in the parser, so retry
// the parse.
parser.clearAbortedSyntaxParse();
} else {
if (parser.tokenStream.hadError() || directives == newDirectives)
return false;
// Assignment must be monotonic to prevent reparsing iloops
JS_ASSERT_IF(directives.strict(), newDirectives.strict());
JS_ASSERT_IF(directives.asmJS(), newDirectives.asmJS());
directives = newDirectives;
}
parser.tokenStream.seek(start);
}
if (!NameFunctions(cx, fn))
return false;
if (fn->pn_funbox->function()->isInterpreted()) {
JS_ASSERT(fun == fn->pn_funbox->function());
Rooted<JSScript*> script(cx, JSScript::Create(cx, NullPtr(), false, options,
/* staticLevel = */ 0, sourceObject,
/* sourceStart = */ 0, length));
if (!script)
return false;
script->bindings = fn->pn_funbox->bindings;
/*
* The reason for checking fun->environment() below is that certain
* consumers of JS::CompileFunction, namely
* nsEventListenerManager::CompileEventHandlerInternal, passes in a
* NULL environment. This compiled function is never used, but instead
* is cloned immediately onto the right scope chain.
*/
BytecodeEmitter funbce(/* parent = */ NULL, &parser, fn->pn_funbox, script,
/* insideEval = */ false, /* evalCaller = */ NullPtr(),
fun->environment() && fun->environment()->is<GlobalObject>(),
options.lineno);
if (!funbce.init())
return false;
if (!EmitFunctionScript(cx, &funbce, fn->pn_body))
return false;
} else {
fun.set(fn->pn_funbox->function());
JS_ASSERT(IsAsmJSModuleNative(fun->native()));
}
if (!SetSourceMap(cx, parser.tokenStream, ss))
return false;
if (!sct.complete())
return false;
return true;
}
示例2: scriptLogger
//.........这里部分代码省略.........
/* foldConstants = */ false,
(Parser<SyntaxParseHandler> *) nullptr,
(LazyScript *) nullptr);
}
MOZ_ASSERT(!options.forEval);
Parser<FullParseHandler> parser(cx, &cx->tempLifoAlloc(),
options, srcBuf.get(), srcBuf.length(),
/* foldConstants = */ true,
canLazilyParse ? syntaxParser.ptr() : nullptr, nullptr);
parser.sct = &sct;
parser.ss = ss;
MOZ_ASSERT(fun);
MOZ_ASSERT(fun->isTenured());
fun->setArgCount(formals.length());
// Speculatively parse using the default directives implied by the context.
// If a directive is encountered (e.g., "use strict") that changes how the
// function should have been parsed, we backup and reparse with the new set
// of directives.
Directives directives(options.strictOption);
TokenStream::Position start(parser.keepAtoms);
parser.tokenStream.tell(&start);
ParseNode *fn;
while (true) {
Directives newDirectives = directives;
fn = parser.standaloneFunctionBody(fun, formals, generatorKind, directives, &newDirectives);
if (fn)
break;
if (parser.hadAbortedSyntaxParse()) {
// Hit some unrecoverable ambiguity during an inner syntax parse.
// Syntax parsing has now been disabled in the parser, so retry
// the parse.
parser.clearAbortedSyntaxParse();
} else {
if (parser.tokenStream.hadError() || directives == newDirectives)
return false;
// Assignment must be monotonic to prevent reparsing iloops
MOZ_ASSERT_IF(directives.strict(), newDirectives.strict());
MOZ_ASSERT_IF(directives.asmJS(), newDirectives.asmJS());
directives = newDirectives;
}
parser.tokenStream.seek(start);
}
if (!NameFunctions(cx, fn))
return false;
if (!SetDisplayURL(cx, parser.tokenStream, ss))
return false;
if (!SetSourceMap(cx, parser.tokenStream, ss))
return false;
if (fn->pn_funbox->function()->isInterpreted()) {
MOZ_ASSERT(fun == fn->pn_funbox->function());
Rooted<JSScript*> script(cx, JSScript::Create(cx, enclosingScope, false, options,
/* staticLevel = */ 0, sourceObject,
/* sourceStart = */ 0, srcBuf.length()));
if (!script)
return false;
script->bindings = fn->pn_funbox->bindings;
/*
* The reason for checking fun->environment() below is that certain
* consumers of JS::CompileFunction, namely
* EventListenerManager::CompileEventHandlerInternal, passes in a
* nullptr environment. This compiled function is never used, but
* instead is cloned immediately onto the right scope chain.
*/
BytecodeEmitter funbce(/* parent = */ nullptr, &parser, fn->pn_funbox, script,
/* lazyScript = */ js::NullPtr(), /* insideEval = */ false,
/* evalCaller = */ js::NullPtr(),
fun->environment() && fun->environment()->is<GlobalObject>(),
options.lineno);
if (!funbce.init())
return false;
if (!EmitFunctionScript(cx, &funbce, fn->pn_body))
return false;
} else {
fun.set(fn->pn_funbox->function());
MOZ_ASSERT(IsAsmJSModuleNative(fun->native()));
}
if (!sct.complete())
return false;
return true;
}