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