本文整理汇总了C++中JSFunction::generatorKind方法的典型用法代码示例。如果您正苦于以下问题:C++ JSFunction::generatorKind方法的具体用法?C++ JSFunction::generatorKind怎么用?C++ JSFunction::generatorKind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSFunction
的用法示例。
在下文中一共展示了JSFunction::generatorKind方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: source
//.........这里部分代码省略.........
// reset when this occurs.
Maybe<ParseContext<FullParseHandler> > pc;
pc.construct(&parser, (GenericParseContext *) nullptr, (ParseNode *) nullptr, &globalsc,
(Directives *) nullptr, staticLevel, /* bodyid = */ 0);
if (!pc.ref().init(parser.tokenStream))
return nullptr;
/* If this is a direct call to eval, inherit the caller's strictness. */
if (evalCaller && evalCaller->strict)
globalsc.strict = true;
if (options.compileAndGo) {
if (source) {
/*
* Save eval program source in script->atoms[0] for the
* eval cache (see EvalCacheLookup in jsobj.cpp).
*/
JSAtom *atom = AtomizeString<CanGC>(cx, source);
jsatomid _;
if (!atom || !bce.makeAtomIndex(atom, &_))
return nullptr;
}
if (evalCaller && evalCaller->functionOrCallerFunction()) {
/*
* An eval script in a caller frame needs to have its enclosing
* function captured in case it refers to an upvar, and someone
* wishes to decompile it while it's running.
*/
JSFunction *fun = evalCaller->functionOrCallerFunction();
Directives directives(/* strict = */ fun->strict());
ObjectBox *funbox = parser.newFunctionBox(/* fn = */ nullptr, fun, pc.addr(),
directives, fun->generatorKind());
if (!funbox)
return nullptr;
bce.objectList.add(funbox);
}
}
bool canHaveDirectives = true;
for (;;) {
TokenKind tt = parser.tokenStream.peekToken(TokenStream::Operand);
if (tt <= TOK_EOF) {
if (tt == TOK_EOF)
break;
JS_ASSERT(tt == TOK_ERROR);
return nullptr;
}
TokenStream::Position pos(parser.keepAtoms);
parser.tokenStream.tell(&pos);
ParseNode *pn = parser.statement(canHaveDirectives);
if (!pn) {
if (parser.hadAbortedSyntaxParse()) {
// Parsing inner functions lazily may lead the parser into an
// unrecoverable state and may require starting over on the top
// level statement. Restart the parse; syntax parsing has
// already been disabled for the parser and the result will not
// be ambiguous.
parser.clearAbortedSyntaxParse();
parser.tokenStream.seek(pos);
// Destroying the parse context will destroy its free
// variables, so check if any deoptimization is needed.
示例2: source
//.........这里部分代码省略.........
BytecodeEmitter::EmitterMode emitterMode =
options.selfHostingMode ? BytecodeEmitter::SelfHosting : BytecodeEmitter::Normal;
BytecodeEmitter bce(/* parent = */ nullptr, &parser, &globalsc, script,
/* lazyScript = */ js::NullPtr(), options.forEval,
evalCaller, !!globalScope, options.lineno, emitterMode);
if (!bce.init())
return nullptr;
// Syntax parsing may cause us to restart processing of top level
// statements in the script. Use Maybe<> so that the parse context can be
// reset when this occurs.
Maybe<ParseContext<FullParseHandler> > pc;
pc.emplace(&parser, (GenericParseContext *) nullptr, (ParseNode *) nullptr, &globalsc,
(Directives *) nullptr, staticLevel, /* bodyid = */ 0,
/* blockScopeDepth = */ 0);
if (!pc->init(parser.tokenStream))
return nullptr;
/* If this is a direct call to eval, inherit the caller's strictness. */
if (evalCaller && evalCaller->strict())
globalsc.strict = true;
if (options.compileAndGo && evalCaller && evalCaller->functionOrCallerFunction()) {
/*
* An eval script in a caller frame needs to have its enclosing
* function captured in case it refers to an upvar, and someone
* wishes to decompile it while it's running.
*/
JSFunction *fun = evalCaller->functionOrCallerFunction();
Directives directives(/* strict = */ fun->strict());
ObjectBox *funbox = parser.newFunctionBox(/* fn = */ nullptr, fun, pc.ptr(),
directives, fun->generatorKind());
if (!funbox)
return nullptr;
bce.objectList.add(funbox);
}
bool canHaveDirectives = true;
for (;;) {
TokenKind tt;
if (!parser.tokenStream.peekToken(&tt, TokenStream::Operand))
return nullptr;
if (tt == TOK_EOF)
break;
TokenStream::Position pos(parser.keepAtoms);
parser.tokenStream.tell(&pos);
ParseNode *pn = parser.statement(canHaveDirectives);
if (!pn) {
if (parser.hadAbortedSyntaxParse()) {
// Parsing inner functions lazily may lead the parser into an
// unrecoverable state and may require starting over on the top
// level statement. Restart the parse; syntax parsing has
// already been disabled for the parser and the result will not
// be ambiguous.
parser.clearAbortedSyntaxParse();
parser.tokenStream.seek(pos);
// Destroying the parse context will destroy its free
// variables, so check if any deoptimization is needed.
if (!MaybeCheckEvalFreeVariables(cx, evalCaller, scopeChain, parser, *pc))
return nullptr;