Bug 1456416 - Make EagerGetter/EagerSetter create their scope earlier;r?arai,efaust
MozReview-Commit-ID: 2RlO4wUp5F2
--- a/js/src/frontend/BinSource-auto.cpp
+++ b/js/src/frontend/BinSource-auto.cpp
@@ -4721,18 +4721,18 @@ BinASTParser<Tok>::parseInterfaceEagerFu
BINJS_TRY_VAR(body, factory_.newLexicalScope(*lexicalScopeData, body));
BINJS_MOZ_TRY_DECL(result, buildFunction(start, kind, name, params, body, funbox));
return result;
}
/*
interface EagerGetter : Node {
+ PropertyName name;
AssertedVarScope? bodyScope;
- PropertyName name;
FunctionBody body;
}
*/
template<typename Tok> JS::Result<ParseNode*>
BinASTParser<Tok>::parseEagerGetter()
{
BinKind kind;
BinFields fields(cx_);
@@ -4750,45 +4750,45 @@ BinASTParser<Tok>::parseEagerGetter()
template<typename Tok> JS::Result<ParseNode*>
BinASTParser<Tok>::parseInterfaceEagerGetter(const size_t start, const BinKind kind, const BinFields& fields)
{
MOZ_ASSERT(kind == BinKind::EagerGetter);
CheckRecursionLimit(cx_);
#if defined(DEBUG)
- const BinField expected_fields[3] = { BinField::BodyScope, BinField::Name, BinField::Body };
+ const BinField expected_fields[3] = { BinField::Name, BinField::BodyScope, BinField::Body };
MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields));
#endif // defined(DEBUG)
- MOZ_TRY(parseOptionalAssertedVarScope());
-
-
-
-
BINJS_MOZ_TRY_DECL(name, parsePropertyName());
-
-
BINJS_MOZ_TRY_DECL(funbox, buildFunctionBox(
GeneratorKind::NotGenerator,
FunctionAsyncKind::SyncFunction,
- FunctionSyntaxKind::Getter, name));
+ FunctionSyntaxKind::Getter, /* name = */ nullptr));
// Push a new ParseContext. It will be used to parse `scope`, the arguments, the function.
BinParseContext funpc(cx_, this, funbox, /* newDirectives = */ nullptr);
BINJS_TRY(funpc.init());
parseContext_->functionScope().useAsVarScope(parseContext_);
MOZ_ASSERT(parseContext_->isFunctionBox());
ParseContext::Scope lexicalScope(cx_, parseContext_, usedNames_);
BINJS_TRY(lexicalScope.init(parseContext_));
+
+
+ MOZ_TRY(parseOptionalAssertedVarScope());
+
+
+
+
BINJS_MOZ_TRY_DECL(body, parseFunctionBody());
ParseNode* params = new_<ListNode>(ParseNodeKind::ParamsBody, tokenizer_->pos(start));
BINJS_MOZ_TRY_DECL(method, buildFunction(start, kind, name, params, body, funbox));
BINJS_TRY_DECL(result, factory_.newObjectMethodOrPropertyDefinition(name, method, AccessorType::Getter));
return result;
}
@@ -4925,46 +4925,46 @@ BinASTParser<Tok>::parseInterfaceEagerSe
const BinField expected_fields[5] = { BinField::Name, BinField::ParameterScope, BinField::BodyScope, BinField::Param, BinField::Body };
MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields));
#endif // defined(DEBUG)
BINJS_MOZ_TRY_DECL(name, parsePropertyName());
-
+ BINJS_MOZ_TRY_DECL(funbox, buildFunctionBox(
+ GeneratorKind::NotGenerator,
+ FunctionAsyncKind::SyncFunction,
+ FunctionSyntaxKind::Setter, /* name = */ nullptr));
+
+ // Push a new ParseContext. It will be used to parse `scope`, the arguments, the function.
+ BinParseContext funpc(cx_, this, funbox, /* newDirectives = */ nullptr);
+ BINJS_TRY(funpc.init());
+ parseContext_->functionScope().useAsVarScope(parseContext_);
+ MOZ_ASSERT(parseContext_->isFunctionBox());
+
+ ParseContext::Scope lexicalScope(cx_, parseContext_, usedNames_);
+ BINJS_TRY(lexicalScope.init(parseContext_));
MOZ_TRY(parseOptionalAssertedParameterScope());
MOZ_TRY(parseOptionalAssertedVarScope());
BINJS_MOZ_TRY_DECL(param, parseParameter());
- BINJS_MOZ_TRY_DECL(funbox, buildFunctionBox(
- GeneratorKind::NotGenerator,
- FunctionAsyncKind::SyncFunction,
- FunctionSyntaxKind::Setter, name));
-
- // Push a new ParseContext. It will be used to parse `scope`, the arguments, the function.
- BinParseContext funpc(cx_, this, funbox, /* newDirectives = */ nullptr);
- BINJS_TRY(funpc.init());
- parseContext_->functionScope().useAsVarScope(parseContext_);
- MOZ_ASSERT(parseContext_->isFunctionBox());
-
- ParseContext::Scope lexicalScope(cx_, parseContext_, usedNames_);
- BINJS_TRY(lexicalScope.init(parseContext_));
+
BINJS_MOZ_TRY_DECL(body, parseFunctionBody());
ParseNode* params = new_<ListNode>(ParseNodeKind::ParamsBody, param->pn_pos);
factory_.addList(params, param);
BINJS_MOZ_TRY_DECL(method, buildFunction(start, kind, name, params, body, funbox));
BINJS_TRY_DECL(result, factory_.newObjectMethodOrPropertyDefinition(name, method, AccessorType::Setter));
--- a/js/src/frontend/BinSource.webidl_
+++ b/js/src/frontend/BinSource.webidl_
@@ -437,18 +437,18 @@ interface EagerMethod : Node {
};
[Skippable] interface SkippableMethod : Node {
attribute EagerMethod skipped;
};
// `get PropertyName ( ) { FunctionBody }`
interface EagerGetter : Node {
+ attribute PropertyName name;
attribute AssertedVarScope? bodyScope;
- attribute PropertyName name;
attribute FunctionBody body;
};
[Skippable] interface SkippableGetter : Node {
attribute EagerGetter skipped;
};
// `set PropertyName ( PropertySetParameterList ) { FunctionBody }`
--- a/js/src/frontend/BinSource.yaml
+++ b/js/src/frontend/BinSource.yaml
@@ -554,22 +554,22 @@ EagerFunctionExpression:
BINJS_TRY(lexicalScope.init(parseContext_));
build: |
BINJS_TRY_DECL(lexicalScopeData, NewLexicalScopeData(cx_, lexicalScope, alloc_, parseContext_));
BINJS_TRY_VAR(body, factory_.newLexicalScope(*lexicalScopeData, body));
BINJS_MOZ_TRY_DECL(result, buildFunction(start, kind, name, params, body, funbox));
EagerGetter:
fields:
- body:
- before: |
+ name:
+ after: |
BINJS_MOZ_TRY_DECL(funbox, buildFunctionBox(
GeneratorKind::NotGenerator,
FunctionAsyncKind::SyncFunction,
- FunctionSyntaxKind::Getter, name));
+ FunctionSyntaxKind::Getter, /* name = */ nullptr));
// Push a new ParseContext. It will be used to parse `scope`, the arguments, the function.
BinParseContext funpc(cx_, this, funbox, /* newDirectives = */ nullptr);
BINJS_TRY(funpc.init());
parseContext_->functionScope().useAsVarScope(parseContext_);
MOZ_ASSERT(parseContext_->isFunctionBox());
ParseContext::Scope lexicalScope(cx_, parseContext_, usedNames_);
@@ -584,22 +584,22 @@ EagerMethod:
const auto syntax = FunctionSyntaxKind::Method;
inherits: EagerFunctionExpression
build: |
BINJS_MOZ_TRY_DECL(method, buildFunction(start, kind, name, params, body, funbox));
BINJS_TRY_DECL(result, factory_.newObjectMethodOrPropertyDefinition(name, method, AccessorType::None));
EagerSetter:
fields:
- body:
- before: |
+ name:
+ after: |
BINJS_MOZ_TRY_DECL(funbox, buildFunctionBox(
GeneratorKind::NotGenerator,
FunctionAsyncKind::SyncFunction,
- FunctionSyntaxKind::Setter, name));
+ FunctionSyntaxKind::Setter, /* name = */ nullptr));
// Push a new ParseContext. It will be used to parse `scope`, the arguments, the function.
BinParseContext funpc(cx_, this, funbox, /* newDirectives = */ nullptr);
BINJS_TRY(funpc.init());
parseContext_->functionScope().useAsVarScope(parseContext_);
MOZ_ASSERT(parseContext_->isFunctionBox());
ParseContext::Scope lexicalScope(cx_, parseContext_, usedNames_);