зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1528837 - Part 11: Rename BinASTParserBase::parseContext_ field to pc_. r=Yoric
Differential Revision: https://phabricator.services.mozilla.com/D20223 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
1c79a6e610
Коммит
2c43d5027c
|
@ -693,12 +693,12 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseSumParameter(
|
|||
break;
|
||||
case BinKind::BindingIdentifier:
|
||||
MOZ_TRY_VAR(result, parseInterfaceBindingIdentifier(start, kind, fields));
|
||||
if (!parseContext_->positionalFormalParameterNames().append(
|
||||
if (!pc_->positionalFormalParameterNames().append(
|
||||
result->template as<NameNode>().atom())) {
|
||||
return raiseOOM();
|
||||
}
|
||||
if (parseContext_->isFunctionBox()) {
|
||||
parseContext_->functionBox()->length++;
|
||||
if (pc_->isFunctionBox()) {
|
||||
pc_->functionBox()->length++;
|
||||
}
|
||||
break;
|
||||
case BinKind::BindingWithInitializer:
|
||||
|
@ -1356,14 +1356,13 @@ JS::Result<Ok> BinASTParser<Tok>::parseInterfaceAssertedBlockScope(
|
|||
|
||||
BINJS_MOZ_TRY_DECL(hasDirectEval, tokenizer_->readBool());
|
||||
if (hasDirectEval) {
|
||||
parseContext_->sc()->setHasDirectEval();
|
||||
parseContext_->sc()->setBindingsAccessedDynamically();
|
||||
pc_->sc()->setHasDirectEval();
|
||||
pc_->sc()->setBindingsAccessedDynamically();
|
||||
}
|
||||
if (hasDirectEval && parseContext_->isFunctionBox() &&
|
||||
!parseContext_->sc()->strict()) {
|
||||
if (hasDirectEval && pc_->isFunctionBox() && !pc_->sc()->strict()) {
|
||||
// In non-strict mode code, direct calls to eval can
|
||||
// add variables to the call object.
|
||||
parseContext_->functionBox()->setHasExtensibleScope();
|
||||
pc_->functionBox()->setHasExtensibleScope();
|
||||
}
|
||||
auto result = Ok();
|
||||
return result;
|
||||
|
@ -1461,14 +1460,13 @@ JS::Result<Ok> BinASTParser<Tok>::parseInterfaceAssertedBoundNamesScope(
|
|||
|
||||
BINJS_MOZ_TRY_DECL(hasDirectEval, tokenizer_->readBool());
|
||||
if (hasDirectEval) {
|
||||
parseContext_->sc()->setHasDirectEval();
|
||||
parseContext_->sc()->setBindingsAccessedDynamically();
|
||||
pc_->sc()->setHasDirectEval();
|
||||
pc_->sc()->setBindingsAccessedDynamically();
|
||||
}
|
||||
if (hasDirectEval && parseContext_->isFunctionBox() &&
|
||||
!parseContext_->sc()->strict()) {
|
||||
if (hasDirectEval && pc_->isFunctionBox() && !pc_->sc()->strict()) {
|
||||
// In non-strict mode code, direct calls to eval can
|
||||
// add variables to the call object.
|
||||
parseContext_->functionBox()->setHasExtensibleScope();
|
||||
pc_->functionBox()->setHasExtensibleScope();
|
||||
}
|
||||
auto result = Ok();
|
||||
return result;
|
||||
|
@ -1580,16 +1578,15 @@ JS::Result<Ok> BinASTParser<Tok>::parseInterfaceAssertedParameterScope(
|
|||
|
||||
BINJS_MOZ_TRY_DECL(hasDirectEval, tokenizer_->readBool());
|
||||
if (hasDirectEval) {
|
||||
parseContext_->sc()->setHasDirectEval();
|
||||
parseContext_->sc()->setBindingsAccessedDynamically();
|
||||
pc_->sc()->setHasDirectEval();
|
||||
pc_->sc()->setBindingsAccessedDynamically();
|
||||
}
|
||||
BINJS_MOZ_TRY_DECL(isSimpleParameterList, tokenizer_->readBool());
|
||||
(void)isSimpleParameterList;
|
||||
if (hasDirectEval && parseContext_->isFunctionBox() &&
|
||||
!parseContext_->sc()->strict()) {
|
||||
if (hasDirectEval && pc_->isFunctionBox() && !pc_->sc()->strict()) {
|
||||
// In non-strict mode code, direct calls to eval can
|
||||
// add variables to the call object.
|
||||
parseContext_->functionBox()->setHasExtensibleScope();
|
||||
pc_->functionBox()->setHasExtensibleScope();
|
||||
}
|
||||
auto result = Ok();
|
||||
return result;
|
||||
|
@ -1608,7 +1605,7 @@ JS::Result<Ok> BinASTParser<Tok>::parseInterfaceAssertedPositionalParameterName(
|
|||
BinField::IsCaptured};
|
||||
MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields));
|
||||
#endif // defined(DEBUG)
|
||||
bool allowDuplicateName = !parseContext_->sc()->strict();
|
||||
bool allowDuplicateName = !pc_->sc()->strict();
|
||||
|
||||
BINJS_MOZ_TRY_DECL(index, tokenizer_->readUnsignedLong());
|
||||
|
||||
|
@ -1687,14 +1684,13 @@ JS::Result<Ok> BinASTParser<Tok>::parseInterfaceAssertedScriptGlobalScope(
|
|||
|
||||
BINJS_MOZ_TRY_DECL(hasDirectEval, tokenizer_->readBool());
|
||||
if (hasDirectEval) {
|
||||
parseContext_->sc()->setHasDirectEval();
|
||||
parseContext_->sc()->setBindingsAccessedDynamically();
|
||||
pc_->sc()->setHasDirectEval();
|
||||
pc_->sc()->setBindingsAccessedDynamically();
|
||||
}
|
||||
if (hasDirectEval && parseContext_->isFunctionBox() &&
|
||||
!parseContext_->sc()->strict()) {
|
||||
if (hasDirectEval && pc_->isFunctionBox() && !pc_->sc()->strict()) {
|
||||
// In non-strict mode code, direct calls to eval can
|
||||
// add variables to the call object.
|
||||
parseContext_->functionBox()->setHasExtensibleScope();
|
||||
pc_->functionBox()->setHasExtensibleScope();
|
||||
}
|
||||
auto result = Ok();
|
||||
return result;
|
||||
|
@ -1741,14 +1737,13 @@ JS::Result<Ok> BinASTParser<Tok>::parseInterfaceAssertedVarScope(
|
|||
|
||||
BINJS_MOZ_TRY_DECL(hasDirectEval, tokenizer_->readBool());
|
||||
if (hasDirectEval) {
|
||||
parseContext_->sc()->setHasDirectEval();
|
||||
parseContext_->sc()->setBindingsAccessedDynamically();
|
||||
pc_->sc()->setHasDirectEval();
|
||||
pc_->sc()->setBindingsAccessedDynamically();
|
||||
}
|
||||
if (hasDirectEval && parseContext_->isFunctionBox() &&
|
||||
!parseContext_->sc()->strict()) {
|
||||
if (hasDirectEval && pc_->isFunctionBox() && !pc_->sc()->strict()) {
|
||||
// In non-strict mode code, direct calls to eval can
|
||||
// add variables to the call object.
|
||||
parseContext_->functionBox()->setHasExtensibleScope();
|
||||
pc_->functionBox()->setHasExtensibleScope();
|
||||
}
|
||||
auto result = Ok();
|
||||
return result;
|
||||
|
@ -1792,8 +1787,8 @@ BinASTParser<Tok>::parseInterfaceAssignmentTargetIdentifier(
|
|||
if (!IsIdentifier(name)) {
|
||||
return raiseError("Invalid identifier");
|
||||
}
|
||||
BINJS_TRY(usedNames_.noteUse(cx_, name, parseContext_->scriptId(),
|
||||
parseContext_->innermostScope()->id()));
|
||||
BINJS_TRY(usedNames_.noteUse(cx_, name, pc_->scriptId(),
|
||||
pc_->innermostScope()->id()));
|
||||
BINJS_TRY_DECL(result, factory_.newName(name->asPropertyName(),
|
||||
tokenizer_->pos(start), cx_));
|
||||
return result;
|
||||
|
@ -2005,17 +2000,16 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceBlock(
|
|||
const BinField expected_fields[2] = {BinField::Scope, BinField::Statements};
|
||||
MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields));
|
||||
#endif // defined(DEBUG)
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::Block);
|
||||
ParseContext::Scope currentScope(cx_, parseContext_, usedNames_);
|
||||
BINJS_TRY(currentScope.init(parseContext_));
|
||||
ParseContext::Statement stmt(pc_, StatementKind::Block);
|
||||
ParseContext::Scope currentScope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(currentScope.init(pc_));
|
||||
|
||||
MOZ_TRY(parseAssertedBlockScope());
|
||||
|
||||
BINJS_MOZ_TRY_DECL(statements, parseListOfStatement());
|
||||
|
||||
MOZ_TRY(checkClosedVars(currentScope));
|
||||
BINJS_TRY_DECL(bindings,
|
||||
NewLexicalScopeData(cx_, currentScope, alloc_, parseContext_));
|
||||
BINJS_TRY_DECL(bindings, NewLexicalScopeData(cx_, currentScope, alloc_, pc_));
|
||||
BINJS_TRY_DECL(result, factory_.newLexicalScope(*bindings, statements));
|
||||
return result;
|
||||
}
|
||||
|
@ -2039,8 +2033,8 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceBreakStatement(
|
|||
}
|
||||
}
|
||||
|
||||
auto validity = parseContext_->checkBreakStatement(
|
||||
label ? label->asPropertyName() : nullptr);
|
||||
auto validity =
|
||||
pc_->checkBreakStatement(label ? label->asPropertyName() : nullptr);
|
||||
if (validity.isErr()) {
|
||||
switch (validity.unwrapErr()) {
|
||||
case ParseContext::BreakStatementError::ToughBreak:
|
||||
|
@ -2079,8 +2073,8 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceCallExpression(
|
|||
if (PropertyName* prop = factory_.maybeDottedProperty(callee)) {
|
||||
if (prop == cx_->names().apply) {
|
||||
op = JSOP_FUNAPPLY;
|
||||
if (parseContext_->isFunctionBox()) {
|
||||
parseContext_->functionBox()->usesApply = true;
|
||||
if (pc_->isFunctionBox()) {
|
||||
pc_->functionBox()->usesApply = true;
|
||||
}
|
||||
} else if (prop == cx_->names().call) {
|
||||
op = JSOP_FUNCALL;
|
||||
|
@ -2089,16 +2083,14 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceCallExpression(
|
|||
|
||||
// Check for direct calls to `eval`.
|
||||
if (factory_.isEvalName(callee, cx_)) {
|
||||
if (!parseContext_->varScope().lookupDeclaredNameForAdd(
|
||||
cx_->names().eval) &&
|
||||
!parseContext_->innermostScope()->lookupDeclaredNameForAdd(
|
||||
cx_->names().eval)) {
|
||||
if (!pc_->varScope().lookupDeclaredNameForAdd(cx_->names().eval) &&
|
||||
!pc_->innermostScope()->lookupDeclaredNameForAdd(cx_->names().eval)) {
|
||||
// This is a direct call to `eval`.
|
||||
if (!parseContext_->sc()->hasDirectEval()) {
|
||||
if (!pc_->sc()->hasDirectEval()) {
|
||||
return raiseMissingDirectEvalInAssertedScope();
|
||||
}
|
||||
|
||||
op = parseContext_->sc()->strict() ? JSOP_STRICTEVAL : JSOP_EVAL;
|
||||
op = pc_->sc()->strict() ? JSOP_STRICTEVAL : JSOP_EVAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2142,9 +2134,9 @@ JS::Result<LexicalScopeNode*> BinASTParser<Tok>::parseInterfaceCatchClause(
|
|||
BinField::Binding, BinField::Body};
|
||||
MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields));
|
||||
#endif // defined(DEBUG)
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::Catch);
|
||||
ParseContext::Scope currentScope(cx_, parseContext_, usedNames_);
|
||||
BINJS_TRY(currentScope.init(parseContext_));
|
||||
ParseContext::Statement stmt(pc_, StatementKind::Catch);
|
||||
ParseContext::Scope currentScope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(currentScope.init(pc_));
|
||||
|
||||
MOZ_TRY(parseAssertedBoundNamesScope());
|
||||
|
||||
|
@ -2153,8 +2145,7 @@ JS::Result<LexicalScopeNode*> BinASTParser<Tok>::parseInterfaceCatchClause(
|
|||
BINJS_MOZ_TRY_DECL(body, parseBlock());
|
||||
|
||||
MOZ_TRY(checkClosedVars(currentScope));
|
||||
BINJS_TRY_DECL(bindings,
|
||||
NewLexicalScopeData(cx_, currentScope, alloc_, parseContext_));
|
||||
BINJS_TRY_DECL(bindings, NewLexicalScopeData(cx_, currentScope, alloc_, pc_));
|
||||
BINJS_TRY_DECL(result, factory_.newLexicalScope(*bindings, body));
|
||||
BINJS_TRY(factory_.setupCatchScope(result, binding, body));
|
||||
return result;
|
||||
|
@ -2327,8 +2318,8 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceContinueStatement(
|
|||
}
|
||||
}
|
||||
|
||||
auto validity = parseContext_->checkContinueStatement(
|
||||
label ? label->asPropertyName() : nullptr);
|
||||
auto validity =
|
||||
pc_->checkContinueStatement(label ? label->asPropertyName() : nullptr);
|
||||
if (validity.isErr()) {
|
||||
switch (validity.unwrapErr()) {
|
||||
case ParseContext::ContinueStatementError::NotInALoop:
|
||||
|
@ -2435,7 +2426,7 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceDoWhileStatement(
|
|||
const BinField expected_fields[2] = {BinField::Test, BinField::Body};
|
||||
MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields));
|
||||
#endif // defined(DEBUG)
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::DoLoop);
|
||||
ParseContext::Statement stmt(pc_, StatementKind::DoLoop);
|
||||
|
||||
BINJS_MOZ_TRY_DECL(test, parseExpression());
|
||||
|
||||
|
@ -2511,17 +2502,17 @@ BinASTParser<Tok>::parseInterfaceEagerFunctionDeclaration(
|
|||
// the function.
|
||||
BinParseContext funpc(cx_, this, funbox, /* newDirectives = */ nullptr);
|
||||
BINJS_TRY(funpc.init());
|
||||
parseContext_->functionScope().useAsVarScope(parseContext_);
|
||||
MOZ_ASSERT(parseContext_->isFunctionBox());
|
||||
pc_->functionScope().useAsVarScope(pc_);
|
||||
MOZ_ASSERT(pc_->isFunctionBox());
|
||||
|
||||
ParseContext::Scope lexicalScope(cx_, parseContext_, usedNames_);
|
||||
BINJS_TRY(lexicalScope.init(parseContext_));
|
||||
ParseContext::Scope lexicalScope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(lexicalScope.init(pc_));
|
||||
ListNode* params;
|
||||
ListNode* body;
|
||||
MOZ_TRY(parseFunctionOrMethodContents(length, ¶ms, &body));
|
||||
MOZ_TRY(prependDirectivesToBody(body, directives));
|
||||
BINJS_TRY_DECL(lexicalScopeData,
|
||||
NewLexicalScopeData(cx_, lexicalScope, alloc_, parseContext_));
|
||||
NewLexicalScopeData(cx_, lexicalScope, alloc_, pc_));
|
||||
BINJS_TRY_DECL(bodyScope, factory_.newLexicalScope(*lexicalScopeData, body));
|
||||
BINJS_MOZ_TRY_DECL(
|
||||
result, buildFunction(start, kind, name, params, bodyScope, funbox));
|
||||
|
@ -2574,17 +2565,17 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceEagerFunctionExpression(
|
|||
// the function.
|
||||
BinParseContext funpc(cx_, this, funbox, /* newDirectives = */ nullptr);
|
||||
BINJS_TRY(funpc.init());
|
||||
parseContext_->functionScope().useAsVarScope(parseContext_);
|
||||
MOZ_ASSERT(parseContext_->isFunctionBox());
|
||||
pc_->functionScope().useAsVarScope(pc_);
|
||||
MOZ_ASSERT(pc_->isFunctionBox());
|
||||
|
||||
ParseContext::Scope lexicalScope(cx_, parseContext_, usedNames_);
|
||||
BINJS_TRY(lexicalScope.init(parseContext_));
|
||||
ParseContext::Scope lexicalScope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(lexicalScope.init(pc_));
|
||||
ListNode* params;
|
||||
ListNode* body;
|
||||
MOZ_TRY(parseFunctionExpressionContents(length, ¶ms, &body));
|
||||
MOZ_TRY(prependDirectivesToBody(body, directives));
|
||||
BINJS_TRY_DECL(lexicalScopeData,
|
||||
NewLexicalScopeData(cx_, lexicalScope, alloc_, parseContext_));
|
||||
NewLexicalScopeData(cx_, lexicalScope, alloc_, pc_));
|
||||
BINJS_TRY_DECL(bodyScope, factory_.newLexicalScope(*lexicalScopeData, body));
|
||||
BINJS_MOZ_TRY_DECL(
|
||||
result, buildFunction(start, kind, name, params, bodyScope, funbox));
|
||||
|
@ -2629,11 +2620,11 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceEagerGetter(
|
|||
// the function.
|
||||
BinParseContext funpc(cx_, this, funbox, /* newDirectives = */ nullptr);
|
||||
BINJS_TRY(funpc.init());
|
||||
parseContext_->functionScope().useAsVarScope(parseContext_);
|
||||
MOZ_ASSERT(parseContext_->isFunctionBox());
|
||||
pc_->functionScope().useAsVarScope(pc_);
|
||||
MOZ_ASSERT(pc_->isFunctionBox());
|
||||
|
||||
ParseContext::Scope lexicalScope(cx_, parseContext_, usedNames_);
|
||||
BINJS_TRY(lexicalScope.init(parseContext_));
|
||||
ParseContext::Scope lexicalScope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(lexicalScope.init(pc_));
|
||||
ListNode* params;
|
||||
ListNode* body;
|
||||
MOZ_TRY(parseGetterContents(length, ¶ms, &body));
|
||||
|
@ -2692,11 +2683,11 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceEagerMethod(
|
|||
// the function.
|
||||
BinParseContext funpc(cx_, this, funbox, /* newDirectives = */ nullptr);
|
||||
BINJS_TRY(funpc.init());
|
||||
parseContext_->functionScope().useAsVarScope(parseContext_);
|
||||
MOZ_ASSERT(parseContext_->isFunctionBox());
|
||||
pc_->functionScope().useAsVarScope(pc_);
|
||||
MOZ_ASSERT(pc_->isFunctionBox());
|
||||
|
||||
ParseContext::Scope lexicalScope(cx_, parseContext_, usedNames_);
|
||||
BINJS_TRY(lexicalScope.init(parseContext_));
|
||||
ParseContext::Scope lexicalScope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(lexicalScope.init(pc_));
|
||||
ListNode* params;
|
||||
ListNode* body;
|
||||
MOZ_TRY(parseFunctionOrMethodContents(length, ¶ms, &body));
|
||||
|
@ -2748,11 +2739,11 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceEagerSetter(
|
|||
// the function.
|
||||
BinParseContext funpc(cx_, this, funbox, /* newDirectives = */ nullptr);
|
||||
BINJS_TRY(funpc.init());
|
||||
parseContext_->functionScope().useAsVarScope(parseContext_);
|
||||
MOZ_ASSERT(parseContext_->isFunctionBox());
|
||||
pc_->functionScope().useAsVarScope(pc_);
|
||||
MOZ_ASSERT(pc_->isFunctionBox());
|
||||
|
||||
ParseContext::Scope lexicalScope(cx_, parseContext_, usedNames_);
|
||||
BINJS_TRY(lexicalScope.init(parseContext_));
|
||||
ParseContext::Scope lexicalScope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(lexicalScope.init(pc_));
|
||||
ListNode* params;
|
||||
ListNode* body;
|
||||
MOZ_TRY(parseSetterContents(length, ¶ms, &body));
|
||||
|
@ -2840,13 +2831,13 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceForInStatement(
|
|||
BinField::Body};
|
||||
MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields));
|
||||
#endif // defined(DEBUG)
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::ForInLoop);
|
||||
ParseContext::Statement stmt(pc_, StatementKind::ForInLoop);
|
||||
|
||||
// Implicit scope around the `for`, used to store `for (let x in ...)`
|
||||
// or `for (const x in ...)`-style declarations. Detail on the
|
||||
// declaration is stored as part of `scope`.
|
||||
ParseContext::Scope scope(cx_, parseContext_, usedNames_);
|
||||
BINJS_TRY(scope.init(parseContext_));
|
||||
ParseContext::Scope scope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(scope.init(pc_));
|
||||
|
||||
BINJS_MOZ_TRY_DECL(left, parseForInOfBindingOrAssignmentTarget());
|
||||
|
||||
|
@ -2862,8 +2853,7 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceForInStatement(
|
|||
/* iflags = */ 0));
|
||||
|
||||
if (!scope.isEmpty()) {
|
||||
BINJS_TRY_DECL(bindings,
|
||||
NewLexicalScopeData(cx_, scope, alloc_, parseContext_));
|
||||
BINJS_TRY_DECL(bindings, NewLexicalScopeData(cx_, scope, alloc_, pc_));
|
||||
BINJS_TRY_VAR(result, factory_.newLexicalScope(*bindings, result));
|
||||
}
|
||||
return result;
|
||||
|
@ -2887,13 +2877,13 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceForStatement(
|
|||
BinField::Update, BinField::Body};
|
||||
MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields));
|
||||
#endif // defined(DEBUG)
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::ForLoop);
|
||||
ParseContext::Statement stmt(pc_, StatementKind::ForLoop);
|
||||
|
||||
// Implicit scope around the `for`, used to store `for (let x; ...; ...)`
|
||||
// or `for (const x; ...; ...)`-style declarations. Detail on the
|
||||
// declaration is stored as part of `BINJS_Scope`.
|
||||
ParseContext::Scope scope(cx_, parseContext_, usedNames_);
|
||||
BINJS_TRY(scope.init(parseContext_));
|
||||
ParseContext::Scope scope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(scope.init(pc_));
|
||||
|
||||
BINJS_MOZ_TRY_DECL(init, parseOptionalVariableDeclarationOrExpression());
|
||||
|
||||
|
@ -2910,8 +2900,7 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceForStatement(
|
|||
/* iflags = */ 0));
|
||||
|
||||
if (!scope.isEmpty()) {
|
||||
BINJS_TRY_DECL(bindings,
|
||||
NewLexicalScopeData(cx_, scope, alloc_, parseContext_));
|
||||
BINJS_TRY_DECL(bindings, NewLexicalScopeData(cx_, scope, alloc_, pc_));
|
||||
BINJS_TRY_VAR(result, factory_.newLexicalScope(*bindings, result));
|
||||
}
|
||||
return result;
|
||||
|
@ -3015,7 +3004,7 @@ JS::Result<Ok> BinASTParser<Tok>::parseInterfaceFunctionExpressionContents(
|
|||
// Per spec, isFunctionNameCaptured can be true for anonymous
|
||||
// function. Check isFunctionNameCaptured only for named
|
||||
// function.
|
||||
if (parseContext_->functionBox()->function()->isNamedLambda() &&
|
||||
if (pc_->functionBox()->function()->isNamedLambda() &&
|
||||
isFunctionNameCaptured) {
|
||||
captureFunctionName();
|
||||
}
|
||||
|
@ -3197,8 +3186,8 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceIdentifierExpression(
|
|||
if (!IsIdentifier(name)) {
|
||||
return raiseError("Invalid identifier");
|
||||
}
|
||||
BINJS_TRY(usedNames_.noteUse(cx_, name, parseContext_->scriptId(),
|
||||
parseContext_->innermostScope()->id()));
|
||||
BINJS_TRY(usedNames_.noteUse(cx_, name, pc_->scriptId(),
|
||||
pc_->innermostScope()->id()));
|
||||
BINJS_TRY_DECL(result, factory_.newName(name->asPropertyName(),
|
||||
tokenizer_->pos(start), cx_));
|
||||
return result;
|
||||
|
@ -3243,7 +3232,7 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceLabelledStatement(
|
|||
if (!IsIdentifier(label)) {
|
||||
return raiseError("Invalid identifier");
|
||||
}
|
||||
ParseContext::LabelStatement stmt(parseContext_, label);
|
||||
ParseContext::LabelStatement stmt(pc_, label);
|
||||
BINJS_MOZ_TRY_DECL(body, parseStatement());
|
||||
|
||||
BINJS_TRY_DECL(result, factory_.newLabeledStatement(label->asPropertyName(),
|
||||
|
@ -3319,8 +3308,8 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceLazyFunctionDeclaration(
|
|||
auto skipStart = contentsSkip.startOffset();
|
||||
BINJS_TRY_DECL(
|
||||
lazy, LazyScript::Create(cx_, fun, sourceObject_,
|
||||
parseContext_->closedOverBindingsForLazy(),
|
||||
parseContext_->innerFunctionsForLazy, skipStart,
|
||||
pc_->closedOverBindingsForLazy(),
|
||||
pc_->innerFunctionsForLazy, skipStart,
|
||||
skipStart + contentsSkip.length(), skipStart, 0,
|
||||
skipStart, ParseGoal::Script));
|
||||
|
||||
|
@ -3384,8 +3373,8 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceLazyFunctionExpression(
|
|||
auto skipStart = contentsSkip.startOffset();
|
||||
BINJS_TRY_DECL(
|
||||
lazy, LazyScript::Create(cx_, fun, sourceObject_,
|
||||
parseContext_->closedOverBindingsForLazy(),
|
||||
parseContext_->innerFunctionsForLazy, skipStart,
|
||||
pc_->closedOverBindingsForLazy(),
|
||||
pc_->innerFunctionsForLazy, skipStart,
|
||||
skipStart + contentsSkip.length(), skipStart, 0,
|
||||
skipStart, ParseGoal::Script));
|
||||
|
||||
|
@ -3643,12 +3632,12 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceReturnStatement(
|
|||
const BinField expected_fields[1] = {BinField::Expression};
|
||||
MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields));
|
||||
#endif // defined(DEBUG)
|
||||
if (!parseContext_->isFunctionBox()) {
|
||||
if (!pc_->isFunctionBox()) {
|
||||
// Return statements are permitted only inside functions.
|
||||
return raiseInvalidKind("Toplevel Statement", kind);
|
||||
}
|
||||
|
||||
parseContext_->functionBox()->usesReturn = true;
|
||||
pc_->functionBox()->usesReturn = true;
|
||||
|
||||
BINJS_MOZ_TRY_DECL(expression, parseOptionalExpression());
|
||||
|
||||
|
@ -3672,10 +3661,10 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceScript(
|
|||
MOZ_TRY(parseAssertedScriptGlobalScope());
|
||||
|
||||
BINJS_MOZ_TRY_DECL(directives, parseListOfDirective());
|
||||
forceStrictIfNecessary(parseContext_->sc(), directives);
|
||||
forceStrictIfNecessary(pc_->sc(), directives);
|
||||
BINJS_MOZ_TRY_DECL(statements, parseListOfStatement());
|
||||
|
||||
MOZ_TRY(checkClosedVars(parseContext_->varScope()));
|
||||
MOZ_TRY(checkClosedVars(pc_->varScope()));
|
||||
MOZ_TRY(prependDirectivesToBody(/* body = */ statements, directives));
|
||||
auto result = statements;
|
||||
return result;
|
||||
|
@ -3928,7 +3917,7 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceSwitchStatement(
|
|||
#endif // defined(DEBUG)
|
||||
|
||||
BINJS_MOZ_TRY_DECL(discriminant, parseExpression());
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::Switch);
|
||||
ParseContext::Statement stmt(pc_, StatementKind::Switch);
|
||||
BINJS_MOZ_TRY_DECL(cases, parseListOfSwitchCase());
|
||||
|
||||
BINJS_TRY_DECL(scope, factory_.newLexicalScope(nullptr, cases));
|
||||
|
@ -3952,7 +3941,7 @@ BinASTParser<Tok>::parseInterfaceSwitchStatementWithDefault(
|
|||
#endif // defined(DEBUG)
|
||||
|
||||
BINJS_MOZ_TRY_DECL(discriminant, parseExpression());
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::Switch);
|
||||
ParseContext::Statement stmt(pc_, StatementKind::Switch);
|
||||
BINJS_MOZ_TRY_DECL(preDefaultCases, parseListOfSwitchCase());
|
||||
|
||||
BINJS_MOZ_TRY_DECL(defaultCase, parseSwitchDefault());
|
||||
|
@ -3989,16 +3978,16 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceThisExpression(
|
|||
BINJS_TRY(CheckRecursionLimit(cx_));
|
||||
MOZ_TRY(tokenizer_->checkFields0(kind, fields));
|
||||
|
||||
if (parseContext_->isFunctionBox()) {
|
||||
parseContext_->functionBox()->usesThis = true;
|
||||
if (pc_->isFunctionBox()) {
|
||||
pc_->functionBox()->usesThis = true;
|
||||
}
|
||||
|
||||
TokenPos pos = tokenizer_->pos(start);
|
||||
ParseNode* thisName(nullptr);
|
||||
if (parseContext_->sc()->thisBinding() == ThisBinding::Function) {
|
||||
if (pc_->sc()->thisBinding() == ThisBinding::Function) {
|
||||
HandlePropertyName dotThis = cx_->names().dotThis;
|
||||
BINJS_TRY(usedNames_.noteUse(cx_, dotThis, parseContext_->scriptId(),
|
||||
parseContext_->innermostScope()->id()));
|
||||
BINJS_TRY(usedNames_.noteUse(cx_, dotThis, pc_->scriptId(),
|
||||
pc_->innermostScope()->id()));
|
||||
BINJS_TRY_VAR(thisName, factory_.newName(dotThis, pos, cx_));
|
||||
}
|
||||
|
||||
|
@ -4036,9 +4025,9 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceTryCatchStatement(
|
|||
#endif // defined(DEBUG)
|
||||
ParseNode* body;
|
||||
{
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::Try);
|
||||
ParseContext::Scope scope(cx_, parseContext_, usedNames_);
|
||||
BINJS_TRY(scope.init(parseContext_));
|
||||
ParseContext::Statement stmt(pc_, StatementKind::Try);
|
||||
ParseContext::Scope scope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(scope.init(pc_));
|
||||
MOZ_TRY_VAR(body, parseBlock());
|
||||
}
|
||||
|
||||
|
@ -4063,18 +4052,18 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceTryFinallyStatement(
|
|||
#endif // defined(DEBUG)
|
||||
ParseNode* body;
|
||||
{
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::Try);
|
||||
ParseContext::Scope scope(cx_, parseContext_, usedNames_);
|
||||
BINJS_TRY(scope.init(parseContext_));
|
||||
ParseContext::Statement stmt(pc_, StatementKind::Try);
|
||||
ParseContext::Scope scope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(scope.init(pc_));
|
||||
MOZ_TRY_VAR(body, parseBlock());
|
||||
}
|
||||
|
||||
BINJS_MOZ_TRY_DECL(catchClause, parseOptionalCatchClause());
|
||||
ParseNode* finalizer;
|
||||
{
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::Finally);
|
||||
ParseContext::Scope scope(cx_, parseContext_, usedNames_);
|
||||
BINJS_TRY(scope.init(parseContext_));
|
||||
ParseContext::Statement stmt(pc_, StatementKind::Finally);
|
||||
ParseContext::Scope scope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(scope.init(pc_));
|
||||
MOZ_TRY_VAR(finalizer, parseBlock());
|
||||
}
|
||||
|
||||
|
@ -4129,7 +4118,7 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceUnaryExpression(
|
|||
operand->setOp(JSOP_DELNAME);
|
||||
pnk = ParseNodeKind::DeleteNameExpr;
|
||||
BINJS_TRY(this->strictModeError(JSMSG_DEPRECATED_DELETE_OPERAND));
|
||||
parseContext_->sc()->setBindingsAccessedDynamically();
|
||||
pc_->sc()->setBindingsAccessedDynamically();
|
||||
break;
|
||||
case ParseNodeKind::DotExpr:
|
||||
pnk = ParseNodeKind::DeletePropExpr;
|
||||
|
@ -4292,7 +4281,7 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceWhileStatement(
|
|||
const BinField expected_fields[2] = {BinField::Test, BinField::Body};
|
||||
MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields));
|
||||
#endif // defined(DEBUG)
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::WhileLoop);
|
||||
ParseContext::Statement stmt(pc_, StatementKind::WhileLoop);
|
||||
|
||||
BINJS_MOZ_TRY_DECL(test, parseExpression());
|
||||
|
||||
|
@ -4315,10 +4304,10 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceWithStatement(
|
|||
|
||||
BINJS_MOZ_TRY_DECL(object, parseExpression());
|
||||
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::With);
|
||||
ParseContext::Statement stmt(pc_, StatementKind::With);
|
||||
BINJS_MOZ_TRY_DECL(body, parseStatement());
|
||||
|
||||
parseContext_->sc()->setBindingsAccessedDynamically();
|
||||
pc_->sc()->setBindingsAccessedDynamically();
|
||||
BINJS_TRY_DECL(result, factory_.newWithStatement(start, object, body));
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ class BinASTParser : public BinASTParserPerTokenizer<Tok> {
|
|||
using Base::usedNames_;
|
||||
|
||||
using Base::factory_;
|
||||
using Base::parseContext_;
|
||||
using Base::pc_;
|
||||
using Base::sourceObject_;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -26,7 +26,7 @@ BinASTParserBase::BinASTParserBase(JSContext* cx, LifoAlloc& alloc,
|
|||
keepAtoms_(cx),
|
||||
sourceObject_(cx, sourceObject),
|
||||
lazyScript_(cx, lazyScript),
|
||||
parseContext_(nullptr),
|
||||
pc_(nullptr),
|
||||
factory_(cx, alloc, nullptr, SourceKind::Binary) {
|
||||
MOZ_ASSERT_IF(lazyScript, lazyScript->isBinAST());
|
||||
cx->frontendCollectionPool().addActiveCompilation();
|
||||
|
@ -48,7 +48,7 @@ BinASTParserBase::~BinASTParserBase() {
|
|||
|
||||
bool BinASTParserBase::hasUsedName(HandlePropertyName name) {
|
||||
if (UsedNamePtr p = usedNames_.lookup(name)) {
|
||||
return p->value().isUsedInScript(parseContext_->scriptId());
|
||||
return p->value().isUsedInScript(pc_->scriptId());
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -74,7 +74,7 @@ class BinASTParserBase : private JS::AutoGCRooter {
|
|||
|
||||
RootedScriptSourceObject sourceObject_;
|
||||
Rooted<LazyScript*> lazyScript_;
|
||||
ParseContext* parseContext_;
|
||||
ParseContext* pc_;
|
||||
FullParseHandler factory_;
|
||||
|
||||
friend class BinParseContext;
|
||||
|
|
|
@ -120,7 +120,7 @@ JS::Result<ParseNode*> BinASTParserPerTokenizer<Tok>::parseAux(
|
|||
MOZ_TRY_VAR(result, asFinalParser()->parseProgram());
|
||||
|
||||
mozilla::Maybe<GlobalScope::Data*> bindings =
|
||||
NewGlobalScopeData(cx_, varScope, alloc_, parseContext_);
|
||||
NewGlobalScopeData(cx_, varScope, alloc_, pc_);
|
||||
if (!bindings) {
|
||||
return cx_->alreadyReportedError();
|
||||
}
|
||||
|
@ -167,11 +167,11 @@ JS::Result<FunctionNode*> BinASTParserPerTokenizer<Tok>::parseLazyFunction(
|
|||
// the function.
|
||||
BinParseContext funpc(cx_, this, funbox, /* newDirectives = */ nullptr);
|
||||
BINJS_TRY(funpc.init());
|
||||
parseContext_->functionScope().useAsVarScope(parseContext_);
|
||||
MOZ_ASSERT(parseContext_->isFunctionBox());
|
||||
pc_->functionScope().useAsVarScope(pc_);
|
||||
MOZ_ASSERT(pc_->isFunctionBox());
|
||||
|
||||
ParseContext::Scope lexicalScope(cx_, parseContext_, usedNames_);
|
||||
BINJS_TRY(lexicalScope.init(parseContext_));
|
||||
ParseContext::Scope lexicalScope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(lexicalScope.init(pc_));
|
||||
ListNode* params;
|
||||
ListNode* tmpBody;
|
||||
auto parseFunc = isExpr ? &FinalParser::parseFunctionExpressionContents
|
||||
|
@ -179,7 +179,7 @@ JS::Result<FunctionNode*> BinASTParserPerTokenizer<Tok>::parseLazyFunction(
|
|||
MOZ_TRY((asFinalParser()->*parseFunc)(func->nargs(), ¶ms, &tmpBody));
|
||||
|
||||
BINJS_TRY_DECL(lexicalScopeData,
|
||||
NewLexicalScopeData(cx_, lexicalScope, alloc_, parseContext_));
|
||||
NewLexicalScopeData(cx_, lexicalScope, alloc_, pc_));
|
||||
BINJS_TRY_DECL(body, factory_.newLexicalScope(*lexicalScopeData, tmpBody));
|
||||
|
||||
auto binKind = isExpr ? BinKind::LazyFunctionExpression
|
||||
|
@ -204,7 +204,7 @@ template <typename Tok>
|
|||
JS::Result<FunctionBox*> BinASTParserPerTokenizer<Tok>::buildFunctionBox(
|
||||
GeneratorKind generatorKind, FunctionAsyncKind functionAsyncKind,
|
||||
FunctionSyntaxKind syntax, ParseNode* name) {
|
||||
MOZ_ASSERT_IF(!parseContext_, lazyScript_);
|
||||
MOZ_ASSERT_IF(!pc_, lazyScript_);
|
||||
|
||||
RootedAtom atom(cx_);
|
||||
|
||||
|
@ -213,8 +213,8 @@ JS::Result<FunctionBox*> BinASTParserPerTokenizer<Tok>::buildFunctionBox(
|
|||
atom = name->as<NameNode>().atom();
|
||||
}
|
||||
|
||||
if (parseContext_ && syntax == FunctionSyntaxKind::Statement) {
|
||||
auto ptr = parseContext_->varScope().lookupDeclaredName(atom);
|
||||
if (pc_ && syntax == FunctionSyntaxKind::Statement) {
|
||||
auto ptr = pc_->varScope().lookupDeclaredName(atom);
|
||||
if (!ptr) {
|
||||
return raiseError(
|
||||
"FunctionDeclaration without corresponding AssertedDeclaredName.");
|
||||
|
@ -231,15 +231,14 @@ JS::Result<FunctionBox*> BinASTParserPerTokenizer<Tok>::buildFunctionBox(
|
|||
|
||||
// Allocate the function before walking down the tree.
|
||||
RootedFunction fun(cx_);
|
||||
BINJS_TRY_VAR(fun, !parseContext_
|
||||
? lazyScript_->functionNonDelazifying()
|
||||
: AllocNewFunction(cx_, atom, syntax, generatorKind,
|
||||
functionAsyncKind, nullptr));
|
||||
MOZ_ASSERT_IF(parseContext_, fun->explicitName() == atom);
|
||||
BINJS_TRY_VAR(fun, !pc_ ? lazyScript_->functionNonDelazifying()
|
||||
: AllocNewFunction(cx_, atom, syntax, generatorKind,
|
||||
functionAsyncKind, nullptr));
|
||||
MOZ_ASSERT_IF(pc_, fun->explicitName() == atom);
|
||||
|
||||
mozilla::Maybe<Directives> directives;
|
||||
if (parseContext_) {
|
||||
directives.emplace(parseContext_);
|
||||
if (pc_) {
|
||||
directives.emplace(pc_);
|
||||
} else {
|
||||
directives.emplace(lazyScript_->strict());
|
||||
}
|
||||
|
@ -252,8 +251,8 @@ JS::Result<FunctionBox*> BinASTParserPerTokenizer<Tok>::buildFunctionBox(
|
|||
}
|
||||
|
||||
traceListHead_ = funbox;
|
||||
if (parseContext_) {
|
||||
funbox->initWithEnclosingParseContext(parseContext_, syntax);
|
||||
if (pc_) {
|
||||
funbox->initWithEnclosingParseContext(pc_, syntax);
|
||||
} else {
|
||||
funbox->initFromLazyFunction();
|
||||
}
|
||||
|
@ -327,12 +326,11 @@ JS::Result<FunctionNode*> BinASTParserPerTokenizer<Tok>::buildFunction(
|
|||
funbox->isDerivedClassConstructor();
|
||||
|
||||
if (declareThis) {
|
||||
ParseContext::Scope& funScope = parseContext_->functionScope();
|
||||
ParseContext::Scope& funScope = pc_->functionScope();
|
||||
ParseContext::Scope::AddDeclaredNamePtr p =
|
||||
funScope.lookupDeclaredNameForAdd(dotThis);
|
||||
MOZ_ASSERT(!p);
|
||||
BINJS_TRY(funScope.addDeclaredName(parseContext_, p, dotThis,
|
||||
DeclarationKind::Var,
|
||||
BINJS_TRY(funScope.addDeclaredName(pc_, p, dotThis, DeclarationKind::Var,
|
||||
DeclaredNameInfo::npos));
|
||||
funbox->setHasThisBinding();
|
||||
|
||||
|
@ -344,16 +342,15 @@ JS::Result<FunctionNode*> BinASTParserPerTokenizer<Tok>::buildFunction(
|
|||
// subtleties removed, as they don't yet apply to us.
|
||||
HandlePropertyName arguments = cx_->names().arguments;
|
||||
if (hasUsedName(arguments) ||
|
||||
parseContext_->functionBox()->bindingsAccessedDynamically()) {
|
||||
pc_->functionBox()->bindingsAccessedDynamically()) {
|
||||
funbox->usesArguments = true;
|
||||
|
||||
ParseContext::Scope& funScope = parseContext_->functionScope();
|
||||
ParseContext::Scope& funScope = pc_->functionScope();
|
||||
ParseContext::Scope::AddDeclaredNamePtr p =
|
||||
funScope.lookupDeclaredNameForAdd(arguments);
|
||||
if (!p) {
|
||||
BINJS_TRY(funScope.addDeclaredName(parseContext_, p, arguments,
|
||||
DeclarationKind::Var,
|
||||
DeclaredNameInfo::npos));
|
||||
BINJS_TRY(funScope.addDeclaredName(
|
||||
pc_, p, arguments, DeclarationKind::Var, DeclaredNameInfo::npos));
|
||||
funbox->declaredArguments = true;
|
||||
} else if (p->value()->kind() != DeclarationKind::Var) {
|
||||
// Lexicals, formal parameters, and body level functions shadow.
|
||||
|
@ -363,26 +360,25 @@ JS::Result<FunctionNode*> BinASTParserPerTokenizer<Tok>::buildFunction(
|
|||
if (funbox->usesArguments) {
|
||||
funbox->setArgumentsHasLocalBinding();
|
||||
|
||||
if (parseContext_->sc()->bindingsAccessedDynamically() ||
|
||||
parseContext_->sc()->hasDebuggerStatement()) {
|
||||
if (pc_->sc()->bindingsAccessedDynamically() ||
|
||||
pc_->sc()->hasDebuggerStatement()) {
|
||||
funbox->setDefinitelyNeedsArgsObj();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (funbox->needsDotGeneratorName()) {
|
||||
ParseContext::Scope& funScope = parseContext_->functionScope();
|
||||
ParseContext::Scope& funScope = pc_->functionScope();
|
||||
HandlePropertyName dotGenerator = cx_->names().dotGenerator;
|
||||
ParseContext::Scope::AddDeclaredNamePtr p =
|
||||
funScope.lookupDeclaredNameForAdd(dotGenerator);
|
||||
if (!p) {
|
||||
BINJS_TRY(funScope.addDeclaredName(parseContext_, p, dotGenerator,
|
||||
DeclarationKind::Var,
|
||||
DeclaredNameInfo::npos));
|
||||
BINJS_TRY(funScope.addDeclaredName(
|
||||
pc_, p, dotGenerator, DeclarationKind::Var, DeclaredNameInfo::npos));
|
||||
}
|
||||
|
||||
BINJS_TRY(usedNames_.noteUse(cx_, dotGenerator, parseContext_->scriptId(),
|
||||
parseContext_->innermostScope()->id()));
|
||||
BINJS_TRY(usedNames_.noteUse(cx_, dotGenerator, pc_->scriptId(),
|
||||
pc_->innermostScope()->id()));
|
||||
|
||||
BINJS_TRY_DECL(
|
||||
dotGen, factory_.newName(dotGenerator,
|
||||
|
@ -396,17 +392,16 @@ JS::Result<FunctionNode*> BinASTParserPerTokenizer<Tok>::buildFunction(
|
|||
// Check all our bindings after maybe adding function metavars.
|
||||
MOZ_TRY(checkFunctionClosedVars());
|
||||
|
||||
BINJS_TRY_DECL(bindings,
|
||||
NewFunctionScopeData(cx_, parseContext_->functionScope(),
|
||||
/* hasParameterExprs = */ false, alloc_,
|
||||
parseContext_));
|
||||
BINJS_TRY_DECL(bindings, NewFunctionScopeData(cx_, pc_->functionScope(),
|
||||
/* hasParameterExprs = */ false,
|
||||
alloc_, pc_));
|
||||
|
||||
funbox->functionScopeBindings().set(*bindings);
|
||||
|
||||
if (funbox->function()->isNamedLambda()) {
|
||||
BINJS_TRY_DECL(recursiveBinding,
|
||||
NewLexicalScopeData(cx_, parseContext_->namedLambdaScope(),
|
||||
alloc_, parseContext_));
|
||||
BINJS_TRY_DECL(
|
||||
recursiveBinding,
|
||||
NewLexicalScopeData(cx_, pc_->namedLambdaScope(), alloc_, pc_));
|
||||
|
||||
funbox->namedLambdaBindings().set(*recursiveBinding);
|
||||
}
|
||||
|
@ -426,7 +421,7 @@ JS::Result<Ok> BinASTParserPerTokenizer<Tok>::addScopeName(
|
|||
return raiseError("Variable redeclaration");
|
||||
}
|
||||
|
||||
BINJS_TRY(scope->addDeclaredName(parseContext_, ptr, name.get(), declKind,
|
||||
BINJS_TRY(scope->addDeclaredName(pc_, ptr, name.get(), declKind,
|
||||
tokenizer_->offset()));
|
||||
|
||||
if (isCaptured) {
|
||||
|
@ -440,14 +435,13 @@ JS::Result<Ok> BinASTParserPerTokenizer<Tok>::addScopeName(
|
|||
|
||||
template <typename Tok>
|
||||
void BinASTParserPerTokenizer<Tok>::captureFunctionName() {
|
||||
MOZ_ASSERT(parseContext_->isFunctionBox());
|
||||
MOZ_ASSERT(parseContext_->functionBox()->function()->isNamedLambda());
|
||||
MOZ_ASSERT(pc_->isFunctionBox());
|
||||
MOZ_ASSERT(pc_->functionBox()->function()->isNamedLambda());
|
||||
|
||||
RootedAtom funName(cx_,
|
||||
parseContext_->functionBox()->function()->explicitName());
|
||||
RootedAtom funName(cx_, pc_->functionBox()->function()->explicitName());
|
||||
MOZ_ASSERT(funName);
|
||||
|
||||
auto ptr = parseContext_->namedLambdaScope().lookupDeclaredName(funName);
|
||||
auto ptr = pc_->namedLambdaScope().lookupDeclaredName(funName);
|
||||
MOZ_ASSERT(ptr);
|
||||
ptr->value()->setClosedOver();
|
||||
}
|
||||
|
@ -465,15 +459,15 @@ JS::Result<Ok> BinASTParserPerTokenizer<Tok>::getDeclaredScope(
|
|||
return raiseError("AssertedBlockScope cannot contain 'var' binding");
|
||||
}
|
||||
declKind = DeclarationKind::Var;
|
||||
scope = &parseContext_->varScope();
|
||||
scope = &pc_->varScope();
|
||||
break;
|
||||
case AssertedDeclaredKind::NonConstLexical:
|
||||
declKind = DeclarationKind::Let;
|
||||
scope = parseContext_->innermostScope();
|
||||
scope = pc_->innermostScope();
|
||||
break;
|
||||
case AssertedDeclaredKind::ConstLexical:
|
||||
declKind = DeclarationKind::Const;
|
||||
scope = parseContext_->innermostScope();
|
||||
scope = pc_->innermostScope();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -489,12 +483,12 @@ JS::Result<Ok> BinASTParserPerTokenizer<Tok>::getBoundScope(
|
|||
switch (scopeKind) {
|
||||
case AssertedScopeKind::Catch:
|
||||
declKind = DeclarationKind::CatchParameter;
|
||||
scope = parseContext_->innermostScope();
|
||||
scope = pc_->innermostScope();
|
||||
break;
|
||||
case AssertedScopeKind::Parameter:
|
||||
MOZ_ASSERT(parseContext_->isFunctionBox());
|
||||
MOZ_ASSERT(pc_->isFunctionBox());
|
||||
declKind = DeclarationKind::PositionalFormalParameter;
|
||||
scope = &parseContext_->functionScope();
|
||||
scope = &pc_->functionScope();
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Unexpected AssertedScopeKind");
|
||||
|
@ -509,8 +503,8 @@ JS::Result<Ok> BinASTParserPerTokenizer<Tok>::checkBinding(JSAtom* name) {
|
|||
// Check that the variable appears in the corresponding scope.
|
||||
ParseContext::Scope& scope =
|
||||
variableDeclarationKind_ == VariableDeclarationKind::Var
|
||||
? parseContext_->varScope()
|
||||
: *parseContext_->innermostScope();
|
||||
? pc_->varScope()
|
||||
: *pc_->innermostScope();
|
||||
|
||||
auto ptr = scope.lookupDeclaredName(name->asPropertyName());
|
||||
if (!ptr) {
|
||||
|
@ -537,7 +531,7 @@ JS::Result<Ok> BinASTParserPerTokenizer<Tok>::checkPositionalParameterIndices(
|
|||
// CreatePositionalParameterIndices (3.1.5 CheckPositionalParameterIndices
|
||||
// step 1) are done implicitly.
|
||||
uint32_t i = 0;
|
||||
const bool hasRest = parseContext_->functionBox()->hasRest();
|
||||
const bool hasRest = pc_->functionBox()->hasRest();
|
||||
for (ParseNode* param : params->contents()) {
|
||||
if (param->isKind(ParseNodeKind::AssignExpr)) {
|
||||
param = param->as<AssignmentNode>().left();
|
||||
|
@ -623,7 +617,7 @@ JS::Result<Ok> BinASTParserPerTokenizer<Tok>::checkPositionalParameterIndices(
|
|||
template <typename Tok>
|
||||
JS::Result<Ok> BinASTParserPerTokenizer<Tok>::checkFunctionLength(
|
||||
uint32_t expectedLength) {
|
||||
if (parseContext_->functionBox()->length != expectedLength) {
|
||||
if (pc_->functionBox()->length != expectedLength) {
|
||||
return raiseError("Function length does't match");
|
||||
}
|
||||
return Ok();
|
||||
|
@ -632,12 +626,10 @@ JS::Result<Ok> BinASTParserPerTokenizer<Tok>::checkFunctionLength(
|
|||
template <typename Tok>
|
||||
JS::Result<Ok> BinASTParserPerTokenizer<Tok>::checkClosedVars(
|
||||
ParseContext::Scope& scope) {
|
||||
for (ParseContext::Scope::BindingIter bi = scope.bindings(parseContext_); bi;
|
||||
bi++) {
|
||||
for (ParseContext::Scope::BindingIter bi = scope.bindings(pc_); bi; bi++) {
|
||||
if (UsedNamePtr p = usedNames_.lookup(bi.name())) {
|
||||
bool closedOver;
|
||||
p->value().noteBoundInScope(parseContext_->scriptId(), scope.id(),
|
||||
&closedOver);
|
||||
p->value().noteBoundInScope(pc_->scriptId(), scope.id(), &closedOver);
|
||||
if (closedOver && !bi.closedOver()) {
|
||||
return raiseInvalidClosedVar(bi.name());
|
||||
}
|
||||
|
@ -649,12 +641,12 @@ JS::Result<Ok> BinASTParserPerTokenizer<Tok>::checkClosedVars(
|
|||
|
||||
template <typename Tok>
|
||||
JS::Result<Ok> BinASTParserPerTokenizer<Tok>::checkFunctionClosedVars() {
|
||||
MOZ_ASSERT(parseContext_->isFunctionBox());
|
||||
MOZ_ASSERT(pc_->isFunctionBox());
|
||||
|
||||
MOZ_TRY(checkClosedVars(*parseContext_->innermostScope()));
|
||||
MOZ_TRY(checkClosedVars(parseContext_->functionScope()));
|
||||
if (parseContext_->functionBox()->function()->isNamedLambda()) {
|
||||
MOZ_TRY(checkClosedVars(parseContext_->namedLambdaScope()));
|
||||
MOZ_TRY(checkClosedVars(*pc_->innermostScope()));
|
||||
MOZ_TRY(checkClosedVars(pc_->functionScope()));
|
||||
if (pc_->functionBox()->function()->isNamedLambda()) {
|
||||
MOZ_TRY(checkClosedVars(pc_->namedLambdaScope()));
|
||||
}
|
||||
|
||||
return Ok();
|
||||
|
|
|
@ -206,9 +206,7 @@ class BinASTParserPerTokenizer : public BinASTParserBase,
|
|||
|
||||
JSContext* getContext() const override { return cx_; };
|
||||
|
||||
MOZ_MUST_USE bool strictMode() const override {
|
||||
return parseContext_->sc()->strict();
|
||||
}
|
||||
MOZ_MUST_USE bool strictMode() const override { return pc_->sc()->strict(); }
|
||||
|
||||
MOZ_MUST_USE bool computeErrorMetadata(ErrorMetadata* err,
|
||||
const ErrorOffset& offset) override;
|
||||
|
@ -322,7 +320,7 @@ class BinParseContext : public ParseContext {
|
|||
template <typename Tok>
|
||||
BinParseContext(JSContext* cx, BinASTParserPerTokenizer<Tok>* parser,
|
||||
SharedContext* sc, Directives* newDirectives)
|
||||
: ParseContext(cx, parser->parseContext_, sc, *parser, parser->usedNames_,
|
||||
: ParseContext(cx, parser->pc_, sc, *parser, parser->usedNames_,
|
||||
newDirectives, /* isFull = */ true) {}
|
||||
};
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ hpp:
|
|||
using Base::usedNames_;
|
||||
|
||||
using Base::sourceObject_;
|
||||
using Base::parseContext_;
|
||||
using Base::pc_;
|
||||
using Base::factory_;
|
||||
|
||||
protected:
|
||||
|
@ -370,15 +370,15 @@ AssertedBlockScope:
|
|||
hasDirectEval:
|
||||
after: |
|
||||
if (hasDirectEval) {
|
||||
parseContext_->sc()->setHasDirectEval();
|
||||
parseContext_->sc()->setBindingsAccessedDynamically();
|
||||
pc_->sc()->setHasDirectEval();
|
||||
pc_->sc()->setBindingsAccessedDynamically();
|
||||
}
|
||||
build: |
|
||||
if (hasDirectEval && parseContext_->isFunctionBox() &&
|
||||
!parseContext_->sc()->strict()) {
|
||||
if (hasDirectEval && pc_->isFunctionBox() &&
|
||||
!pc_->sc()->strict()) {
|
||||
// In non-strict mode code, direct calls to eval can
|
||||
// add variables to the call object.
|
||||
parseContext_->functionBox()->setHasExtensibleScope();
|
||||
pc_->functionBox()->setHasExtensibleScope();
|
||||
}
|
||||
auto result = Ok();
|
||||
|
||||
|
@ -433,7 +433,7 @@ AssertedMaybePositionalParameterName:
|
|||
AssertedPositionalParameterName:
|
||||
inherits: AssertedMaybePositionalParameterName
|
||||
init: |
|
||||
bool allowDuplicateName = !parseContext_->sc()->strict();
|
||||
bool allowDuplicateName = !pc_->sc()->strict();
|
||||
fields:
|
||||
name:
|
||||
after: |
|
||||
|
@ -502,8 +502,8 @@ AssignmentTargetIdentifier:
|
|||
if (!IsIdentifier(name)) {
|
||||
return raiseError("Invalid identifier");
|
||||
}
|
||||
BINJS_TRY(usedNames_.noteUse(cx_, name, parseContext_->scriptId(),
|
||||
parseContext_->innermostScope()->id()));
|
||||
BINJS_TRY(usedNames_.noteUse(cx_, name, pc_->scriptId(),
|
||||
pc_->innermostScope()->id()));
|
||||
BINJS_TRY_DECL(result,
|
||||
factory_.newName(name->asPropertyName(),
|
||||
tokenizer_->pos(start), cx_));
|
||||
|
@ -614,14 +614,13 @@ BinaryExpression:
|
|||
|
||||
Block:
|
||||
init: |
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::Block);
|
||||
ParseContext::Scope currentScope(cx_, parseContext_, usedNames_);
|
||||
BINJS_TRY(currentScope.init(parseContext_));
|
||||
ParseContext::Statement stmt(pc_, StatementKind::Block);
|
||||
ParseContext::Scope currentScope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(currentScope.init(pc_));
|
||||
build: |
|
||||
MOZ_TRY(checkClosedVars(currentScope));
|
||||
BINJS_TRY_DECL(bindings,
|
||||
NewLexicalScopeData(cx_, currentScope, alloc_,
|
||||
parseContext_));
|
||||
NewLexicalScopeData(cx_, currentScope, alloc_, pc_));
|
||||
BINJS_TRY_DECL(result, factory_.newLexicalScope(*bindings, statements));
|
||||
|
||||
BreakStatement:
|
||||
|
@ -640,8 +639,7 @@ BreakStatement:
|
|||
}
|
||||
|
||||
auto validity
|
||||
= parseContext_->checkBreakStatement(label ? label->asPropertyName()
|
||||
: nullptr);
|
||||
= pc_->checkBreakStatement(label ? label->asPropertyName() : nullptr);
|
||||
if (validity.isErr()) {
|
||||
switch (validity.unwrapErr()) {
|
||||
case ParseContext::BreakStatementError::ToughBreak:
|
||||
|
@ -666,8 +664,8 @@ CallExpression:
|
|||
if (PropertyName* prop = factory_.maybeDottedProperty(callee)) {
|
||||
if (prop == cx_->names().apply) {
|
||||
op = JSOP_FUNAPPLY;
|
||||
if (parseContext_->isFunctionBox()) {
|
||||
parseContext_->functionBox()->usesApply = true;
|
||||
if (pc_->isFunctionBox()) {
|
||||
pc_->functionBox()->usesApply = true;
|
||||
}
|
||||
} else if (prop == cx_->names().call) {
|
||||
op = JSOP_FUNCALL;
|
||||
|
@ -676,14 +674,14 @@ CallExpression:
|
|||
|
||||
// Check for direct calls to `eval`.
|
||||
if (factory_.isEvalName(callee, cx_)) {
|
||||
if (!parseContext_->varScope().lookupDeclaredNameForAdd(cx_->names().eval) &&
|
||||
!parseContext_->innermostScope()->lookupDeclaredNameForAdd(cx_->names().eval)) {
|
||||
if (!pc_->varScope().lookupDeclaredNameForAdd(cx_->names().eval) &&
|
||||
!pc_->innermostScope()->lookupDeclaredNameForAdd(cx_->names().eval)) {
|
||||
// This is a direct call to `eval`.
|
||||
if (!parseContext_->sc()->hasDirectEval()) {
|
||||
if (!pc_->sc()->hasDirectEval()) {
|
||||
return raiseMissingDirectEvalInAssertedScope();
|
||||
}
|
||||
|
||||
op = parseContext_->sc()->strict() ? JSOP_STRICTEVAL : JSOP_EVAL;
|
||||
op = pc_->sc()->strict() ? JSOP_STRICTEVAL : JSOP_EVAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -694,14 +692,13 @@ CatchClause:
|
|||
type-ok:
|
||||
LexicalScopeNode*
|
||||
init: |
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::Catch);
|
||||
ParseContext::Scope currentScope(cx_, parseContext_, usedNames_);
|
||||
BINJS_TRY(currentScope.init(parseContext_));
|
||||
ParseContext::Statement stmt(pc_, StatementKind::Catch);
|
||||
ParseContext::Scope currentScope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(currentScope.init(pc_));
|
||||
build: |
|
||||
MOZ_TRY(checkClosedVars(currentScope));
|
||||
BINJS_TRY_DECL(bindings,
|
||||
NewLexicalScopeData(cx_, currentScope, alloc_,
|
||||
parseContext_));
|
||||
NewLexicalScopeData(cx_, currentScope, alloc_, pc_));
|
||||
BINJS_TRY_DECL(result, factory_.newLexicalScope(*bindings, body));
|
||||
BINJS_TRY(factory_.setupCatchScope(result, binding, body));
|
||||
|
||||
|
@ -781,8 +778,7 @@ ContinueStatement:
|
|||
}
|
||||
|
||||
auto validity
|
||||
= parseContext_->checkContinueStatement(label ? label->asPropertyName()
|
||||
: nullptr);
|
||||
= pc_->checkContinueStatement(label ? label->asPropertyName() : nullptr);
|
||||
if (validity.isErr()) {
|
||||
switch (validity.unwrapErr()) {
|
||||
case ParseContext::ContinueStatementError::NotInALoop:
|
||||
|
@ -825,7 +821,7 @@ Directive:
|
|||
|
||||
DoWhileStatement:
|
||||
init:
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::DoLoop);
|
||||
ParseContext::Statement stmt(pc_, StatementKind::DoLoop);
|
||||
build: |
|
||||
BINJS_TRY_DECL(result,
|
||||
factory_.newDoWhileStatement(body, test,
|
||||
|
@ -860,7 +856,7 @@ FunctionExpressionContents:
|
|||
// Per spec, isFunctionNameCaptured can be true for anonymous
|
||||
// function. Check isFunctionNameCaptured only for named
|
||||
// function.
|
||||
if (parseContext_->functionBox()->function()->isNamedLambda() &&
|
||||
if (pc_->functionBox()->function()->isNamedLambda() &&
|
||||
isFunctionNameCaptured) {
|
||||
captureFunctionName();
|
||||
}
|
||||
|
@ -932,11 +928,11 @@ EagerFunctionExpression:
|
|||
// the function.
|
||||
BinParseContext funpc(cx_, this, funbox, /* newDirectives = */ nullptr);
|
||||
BINJS_TRY(funpc.init());
|
||||
parseContext_->functionScope().useAsVarScope(parseContext_);
|
||||
MOZ_ASSERT(parseContext_->isFunctionBox());
|
||||
pc_->functionScope().useAsVarScope(pc_);
|
||||
MOZ_ASSERT(pc_->isFunctionBox());
|
||||
|
||||
ParseContext::Scope lexicalScope(cx_, parseContext_, usedNames_);
|
||||
BINJS_TRY(lexicalScope.init(parseContext_));
|
||||
ParseContext::Scope lexicalScope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(lexicalScope.init(pc_));
|
||||
ListNode* params;
|
||||
ListNode* body;
|
||||
extra-args: |
|
||||
|
@ -945,8 +941,7 @@ EagerFunctionExpression:
|
|||
MOZ_TRY(prependDirectivesToBody(body, directives));
|
||||
build: |
|
||||
BINJS_TRY_DECL(lexicalScopeData,
|
||||
NewLexicalScopeData(cx_, lexicalScope, alloc_,
|
||||
parseContext_));
|
||||
NewLexicalScopeData(cx_, lexicalScope, alloc_, pc_));
|
||||
BINJS_TRY_DECL(bodyScope,
|
||||
factory_.newLexicalScope(*lexicalScopeData, body));
|
||||
BINJS_MOZ_TRY_DECL(result,
|
||||
|
@ -989,8 +984,8 @@ LazyFunctionExpression:
|
|||
auto skipStart = contentsSkip.startOffset();
|
||||
BINJS_TRY_DECL(lazy, LazyScript::Create(
|
||||
cx_, fun, sourceObject_,
|
||||
parseContext_->closedOverBindingsForLazy(),
|
||||
parseContext_->innerFunctionsForLazy,
|
||||
pc_->closedOverBindingsForLazy(),
|
||||
pc_->innerFunctionsForLazy,
|
||||
skipStart, skipStart + contentsSkip.length(),
|
||||
skipStart, 0, skipStart, ParseGoal::Script));
|
||||
|
||||
|
@ -1065,13 +1060,13 @@ ForInOfBinding:
|
|||
|
||||
ForInStatement:
|
||||
init: |
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::ForInLoop);
|
||||
ParseContext::Statement stmt(pc_, StatementKind::ForInLoop);
|
||||
|
||||
// Implicit scope around the `for`, used to store `for (let x in ...)`
|
||||
// or `for (const x in ...)`-style declarations. Detail on the
|
||||
// declaration is stored as part of `scope`.
|
||||
ParseContext::Scope scope(cx_, parseContext_, usedNames_);
|
||||
BINJS_TRY(scope.init(parseContext_));
|
||||
ParseContext::Scope scope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(scope.init(pc_));
|
||||
build: |
|
||||
BINJS_TRY_DECL(forHead,
|
||||
factory_.newForInOrOfHead(ParseNodeKind::ForIn, left, right,
|
||||
|
@ -1082,7 +1077,7 @@ ForInStatement:
|
|||
/* iflags = */ 0));
|
||||
|
||||
if (!scope.isEmpty()) {
|
||||
BINJS_TRY_DECL(bindings, NewLexicalScopeData(cx_, scope, alloc_, parseContext_));
|
||||
BINJS_TRY_DECL(bindings, NewLexicalScopeData(cx_, scope, alloc_, pc_));
|
||||
BINJS_TRY_VAR(result, factory_.newLexicalScope(*bindings, result));
|
||||
}
|
||||
|
||||
|
@ -1097,13 +1092,13 @@ FormalParameters:
|
|||
|
||||
ForStatement:
|
||||
init: |
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::ForLoop);
|
||||
ParseContext::Statement stmt(pc_, StatementKind::ForLoop);
|
||||
|
||||
// Implicit scope around the `for`, used to store `for (let x; ...; ...)`
|
||||
// or `for (const x; ...; ...)`-style declarations. Detail on the
|
||||
// declaration is stored as part of `BINJS_Scope`.
|
||||
ParseContext::Scope scope(cx_, parseContext_, usedNames_);
|
||||
BINJS_TRY(scope.init(parseContext_));
|
||||
ParseContext::Scope scope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(scope.init(pc_));
|
||||
build: |
|
||||
BINJS_TRY_DECL(forHead,
|
||||
factory_.newForHead(init, test, update,
|
||||
|
@ -1115,7 +1110,7 @@ ForStatement:
|
|||
|
||||
if (!scope.isEmpty()) {
|
||||
BINJS_TRY_DECL(bindings,
|
||||
NewLexicalScopeData(cx_, scope, alloc_, parseContext_));
|
||||
NewLexicalScopeData(cx_, scope, alloc_, pc_));
|
||||
BINJS_TRY_VAR(result, factory_.newLexicalScope(*bindings, result));
|
||||
}
|
||||
|
||||
|
@ -1127,8 +1122,8 @@ IdentifierExpression:
|
|||
if (!IsIdentifier(name)) {
|
||||
return raiseError("Invalid identifier");
|
||||
}
|
||||
BINJS_TRY(usedNames_.noteUse(cx_, name, parseContext_->scriptId(),
|
||||
parseContext_->innermostScope()->id()));
|
||||
BINJS_TRY(usedNames_.noteUse(cx_, name, pc_->scriptId(),
|
||||
pc_->innermostScope()->id()));
|
||||
BINJS_TRY_DECL(result,
|
||||
factory_.newName(name->asPropertyName(),
|
||||
tokenizer_->pos(start), cx_));
|
||||
|
@ -1145,7 +1140,7 @@ LabelledStatement:
|
|||
if (!IsIdentifier(label)) {
|
||||
return raiseError("Invalid identifier");
|
||||
}
|
||||
ParseContext::LabelStatement stmt(parseContext_, label);
|
||||
ParseContext::LabelStatement stmt(pc_, label);
|
||||
build: |
|
||||
BINJS_TRY_DECL(result,
|
||||
factory_.newLabeledStatement(label->asPropertyName(), body,
|
||||
|
@ -1344,22 +1339,22 @@ Parameter:
|
|||
sum-arms:
|
||||
BindingIdentifier:
|
||||
after: |
|
||||
if (!parseContext_->positionalFormalParameterNames().append(
|
||||
if (!pc_->positionalFormalParameterNames().append(
|
||||
result->template as<NameNode>().atom())) {
|
||||
return raiseOOM();
|
||||
}
|
||||
if (parseContext_->isFunctionBox()) {
|
||||
parseContext_->functionBox()->length++;
|
||||
if (pc_->isFunctionBox()) {
|
||||
pc_->functionBox()->length++;
|
||||
}
|
||||
|
||||
ReturnStatement:
|
||||
init: |
|
||||
if (!parseContext_->isFunctionBox()) {
|
||||
if (!pc_->isFunctionBox()) {
|
||||
// Return statements are permitted only inside functions.
|
||||
return raiseInvalidKind("Toplevel Statement", kind);
|
||||
}
|
||||
|
||||
parseContext_->functionBox()->usesReturn = true;
|
||||
pc_->functionBox()->usesReturn = true;
|
||||
build: |
|
||||
BINJS_TRY_DECL(result,
|
||||
factory_.newReturnStatement(expression,
|
||||
|
@ -1369,9 +1364,9 @@ Script:
|
|||
fields:
|
||||
directives:
|
||||
after: |
|
||||
forceStrictIfNecessary(parseContext_->sc(), directives);
|
||||
forceStrictIfNecessary(pc_->sc(), directives);
|
||||
build: |
|
||||
MOZ_TRY(checkClosedVars(parseContext_->varScope()));
|
||||
MOZ_TRY(checkClosedVars(pc_->varScope()));
|
||||
MOZ_TRY(prependDirectivesToBody(/* body = */ statements, directives));
|
||||
auto result = statements;
|
||||
|
||||
|
@ -1401,7 +1396,7 @@ SwitchStatement:
|
|||
fields:
|
||||
discriminant:
|
||||
after: |
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::Switch);
|
||||
ParseContext::Statement stmt(pc_, StatementKind::Switch);
|
||||
build: |
|
||||
BINJS_TRY_DECL(scope, factory_.newLexicalScope(nullptr, cases));
|
||||
BINJS_TRY_DECL(result,
|
||||
|
@ -1412,7 +1407,7 @@ SwitchStatementWithDefault:
|
|||
fields:
|
||||
discriminant:
|
||||
after: |
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::Switch);
|
||||
ParseContext::Statement stmt(pc_, StatementKind::Switch);
|
||||
build: |
|
||||
// Concatenate `preDefaultCase`, `defaultCase`, `postDefaultCase`
|
||||
auto cases = preDefaultCases;
|
||||
|
@ -1458,16 +1453,16 @@ StaticMemberExpression:
|
|||
|
||||
ThisExpression:
|
||||
build: |
|
||||
if (parseContext_->isFunctionBox()) {
|
||||
parseContext_->functionBox()->usesThis = true;
|
||||
if (pc_->isFunctionBox()) {
|
||||
pc_->functionBox()->usesThis = true;
|
||||
}
|
||||
|
||||
TokenPos pos = tokenizer_->pos(start);
|
||||
ParseNode* thisName(nullptr);
|
||||
if (parseContext_->sc()->thisBinding() == ThisBinding::Function) {
|
||||
if (pc_->sc()->thisBinding() == ThisBinding::Function) {
|
||||
HandlePropertyName dotThis = cx_->names().dotThis;
|
||||
BINJS_TRY(usedNames_.noteUse(cx_, dotThis, parseContext_->scriptId(),
|
||||
parseContext_->innermostScope()->id()));
|
||||
BINJS_TRY(usedNames_.noteUse(cx_, dotThis, pc_->scriptId(),
|
||||
pc_->innermostScope()->id()));
|
||||
BINJS_TRY_VAR(thisName, factory_.newName(dotThis, pos, cx_));
|
||||
}
|
||||
|
||||
|
@ -1486,9 +1481,9 @@ TryCatchStatement:
|
|||
declare:
|
||||
ParseNode* body;
|
||||
before: |
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::Try);
|
||||
ParseContext::Scope scope(cx_, parseContext_, usedNames_);
|
||||
BINJS_TRY(scope.init(parseContext_));
|
||||
ParseContext::Statement stmt(pc_, StatementKind::Try);
|
||||
ParseContext::Scope scope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(scope.init(pc_));
|
||||
build: |
|
||||
BINJS_TRY_DECL(result,
|
||||
factory_.newTryStatement(start, body, catchClause,
|
||||
|
@ -1501,17 +1496,17 @@ TryFinallyStatement:
|
|||
declare:
|
||||
ParseNode* body;
|
||||
before: |
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::Try);
|
||||
ParseContext::Scope scope(cx_, parseContext_, usedNames_);
|
||||
BINJS_TRY(scope.init(parseContext_));
|
||||
ParseContext::Statement stmt(pc_, StatementKind::Try);
|
||||
ParseContext::Scope scope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(scope.init(pc_));
|
||||
finalizer:
|
||||
block:
|
||||
declare:
|
||||
ParseNode* finalizer;
|
||||
before: |
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::Finally);
|
||||
ParseContext::Scope scope(cx_, parseContext_, usedNames_);
|
||||
BINJS_TRY(scope.init(parseContext_));
|
||||
ParseContext::Statement stmt(pc_, StatementKind::Finally);
|
||||
ParseContext::Scope scope(cx_, pc_, usedNames_);
|
||||
BINJS_TRY(scope.init(pc_));
|
||||
build: |
|
||||
BINJS_TRY_DECL(result,
|
||||
factory_.newTryStatement(start, body, catchClause,
|
||||
|
@ -1550,7 +1545,7 @@ UnaryExpression:
|
|||
operand->setOp(JSOP_DELNAME);
|
||||
pnk = ParseNodeKind::DeleteNameExpr;
|
||||
BINJS_TRY(this->strictModeError(JSMSG_DEPRECATED_DELETE_OPERAND));
|
||||
parseContext_->sc()->setBindingsAccessedDynamically();
|
||||
pc_->sc()->setBindingsAccessedDynamically();
|
||||
break;
|
||||
case ParseNodeKind::DotExpr:
|
||||
pnk = ParseNodeKind::DeletePropExpr;
|
||||
|
@ -1638,7 +1633,7 @@ VariableDeclarator:
|
|||
|
||||
WhileStatement:
|
||||
init:
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::WhileLoop);
|
||||
ParseContext::Statement stmt(pc_, StatementKind::WhileLoop);
|
||||
build:
|
||||
BINJS_TRY_DECL(result, factory_.newWhileStatement(start, test, body));
|
||||
|
||||
|
@ -1646,7 +1641,7 @@ WithStatement:
|
|||
fields:
|
||||
body:
|
||||
before: |
|
||||
ParseContext::Statement stmt(parseContext_, StatementKind::With);
|
||||
ParseContext::Statement stmt(pc_, StatementKind::With);
|
||||
build: |
|
||||
parseContext_->sc()->setBindingsAccessedDynamically();
|
||||
pc_->sc()->setBindingsAccessedDynamically();
|
||||
BINJS_TRY_DECL(result, factory_.newWithStatement(start, object, body));
|
||||
|
|
Загрузка…
Ссылка в новой задаче