Bug 1545751 - In BinAST, pass Context while parsing;r=arai
The Context 0.1 format specifies that the (de)compression of nodes is determined by: - its node type; - its parent type; - the index in the parent node; - whether the node is an element of an array. This patch modifies the parser generator to pass the information during parsing. Differential Revision: https://phabricator.services.mozilla.com/D28534
This commit is contained in:
@@ -132,7 +132,8 @@ JS::Result<ParseNode*> BinASTParserPerTokenizer<Tok>::parseAux(
|
||||
MOZ_TRY(tokenizer_->readHeader());
|
||||
|
||||
ParseNode* result(nullptr);
|
||||
MOZ_TRY_VAR(result, asFinalParser()->parseProgram());
|
||||
const Context topContext(Context::topLevel());
|
||||
MOZ_TRY_VAR(result, asFinalParser()->parseProgram(topContext));
|
||||
|
||||
mozilla::Maybe<GlobalScope::Data*> bindings =
|
||||
NewGlobalScopeData(cx_, varScope, alloc_, pc_);
|
||||
@@ -191,7 +192,12 @@ JS::Result<FunctionNode*> BinASTParserPerTokenizer<Tok>::parseLazyFunction(
|
||||
ListNode* tmpBody;
|
||||
auto parseFunc = isExpr ? &FinalParser::parseFunctionExpressionContents
|
||||
: &FinalParser::parseFunctionOrMethodContents;
|
||||
MOZ_TRY((asFinalParser()->*parseFunc)(func->nargs(), ¶ms, &tmpBody));
|
||||
|
||||
// Inject a toplevel context (i.e. no parent) to parse the lazy content.
|
||||
// In the future, we may move this to a more specific context.
|
||||
const Context context(Context::topLevel());
|
||||
MOZ_TRY(
|
||||
(asFinalParser()->*parseFunc)(func->nargs(), ¶ms, &tmpBody, context));
|
||||
|
||||
BINJS_TRY_DECL(lexicalScopeData,
|
||||
NewLexicalScopeData(cx_, lexicalScope, alloc_, pc_));
|
||||
|
||||
Reference in New Issue
Block a user