diff --git a/js/src/frontend/BinAST.yaml b/js/src/frontend/BinAST.yaml index 51ce7aa46220..40e35f5d3cb2 100644 --- a/js/src/frontend/BinAST.yaml +++ b/js/src/frontend/BinAST.yaml @@ -977,7 +977,7 @@ EagerFunctionExpression: NewLexicalScopeData(cx_, lexicalScope, alloc_, pc_)); BINJS_TRY_DECL(bodyScope, handler_.newLexicalScope(*lexicalScopeData, body)); - BINJS_MOZ_TRY_DECL(result, makeEmptyFunctionNode(start, kind, funbox)); + BINJS_MOZ_TRY_DECL(result, makeEmptyFunctionNode(start, syntax, funbox)); MOZ_TRY(setFunctionParametersAndBody(result, params, bodyScope)); MOZ_TRY(finishEagerFunction(funbox, nargs)); @@ -1012,7 +1012,7 @@ LazyFunctionExpression: forceStrictIfNecessary(funbox, directives); - BINJS_MOZ_TRY_DECL(result, makeEmptyFunctionNode(start, kind, funbox)); + BINJS_MOZ_TRY_DECL(result, makeEmptyFunctionNode(start, syntax, funbox)); auto skipStart = contentsSkip.startOffset(); auto skipEnd = skipStart + contentsSkip.length(); @@ -1039,7 +1039,7 @@ EagerMethod: NewLexicalScopeData(cx_, lexicalScope, alloc_, pc_)); BINJS_TRY_DECL(bodyScope, handler_.newLexicalScope(*lexicalScopeData, body)); - BINJS_MOZ_TRY_DECL(method, makeEmptyFunctionNode(start, kind, funbox)); + BINJS_MOZ_TRY_DECL(method, makeEmptyFunctionNode(start, syntax, funbox)); MOZ_TRY(setFunctionParametersAndBody(method, params, bodyScope)); BINJS_TRY_DECL(result, handler_.newObjectMethodOrPropertyDefinition(name, method, @@ -1369,7 +1369,7 @@ ReturnStatement: init: | if (!pc_->isFunctionBox()) { // Return statements are permitted only inside functions. - return raiseInvalidKind("Toplevel Statement", kind); + return raiseInvalidKind("Toplevel Statement", BinASTKind::ReturnStatement); } pc_->functionBox()->usesReturn = true; diff --git a/js/src/frontend/BinASTParser.cpp b/js/src/frontend/BinASTParser.cpp index 59089b154413..7060c74da9ee 100644 --- a/js/src/frontend/BinASTParser.cpp +++ b/js/src/frontend/BinASTParser.cpp @@ -82,9 +82,8 @@ JS::Result BinASTParser::parseSumAssertedMaybePositionalParameterName( "FIXME: Not implemented yet in this preview release " "(AssertedParameterName)"); case BinASTKind::AssertedPositionalParameterName: - MOZ_TRY_VAR(result, - parseInterfaceAssertedPositionalParameterName( - start, kind, scopeKind, positionalParams, context)); + MOZ_TRY_VAR(result, parseInterfaceAssertedPositionalParameterName( + start, scopeKind, positionalParams, context)); break; case BinASTKind::AssertedRestParameterName: return raiseError( @@ -125,24 +124,22 @@ JS::Result BinASTParser::parseSumAssignmentTarget( ParseNode* result; switch (kind) { case BinASTKind::ArrayAssignmentTarget: - MOZ_TRY_VAR(result, - parseInterfaceArrayAssignmentTarget(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceArrayAssignmentTarget(start, context)); break; case BinASTKind::AssignmentTargetIdentifier: - MOZ_TRY_VAR(result, parseInterfaceAssignmentTargetIdentifier(start, kind, - context)); + MOZ_TRY_VAR(result, + parseInterfaceAssignmentTargetIdentifier(start, context)); break; case BinASTKind::ComputedMemberAssignmentTarget: - MOZ_TRY_VAR(result, parseInterfaceComputedMemberAssignmentTarget( - start, kind, context)); + MOZ_TRY_VAR(result, + parseInterfaceComputedMemberAssignmentTarget(start, context)); break; case BinASTKind::ObjectAssignmentTarget: - MOZ_TRY_VAR(result, - parseInterfaceObjectAssignmentTarget(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceObjectAssignmentTarget(start, context)); break; case BinASTKind::StaticMemberAssignmentTarget: - MOZ_TRY_VAR(result, parseInterfaceStaticMemberAssignmentTarget( - start, kind, context)); + MOZ_TRY_VAR(result, + parseInterfaceStaticMemberAssignmentTarget(start, context)); break; default: return raiseInvalidKind("AssignmentTarget", kind); @@ -182,27 +179,25 @@ BinASTParser::parseSumAssignmentTargetOrForInOfBinding( ParseNode* result; switch (kind) { case BinASTKind::ArrayAssignmentTarget: - MOZ_TRY_VAR(result, - parseInterfaceArrayAssignmentTarget(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceArrayAssignmentTarget(start, context)); break; case BinASTKind::AssignmentTargetIdentifier: - MOZ_TRY_VAR(result, parseInterfaceAssignmentTargetIdentifier(start, kind, - context)); + MOZ_TRY_VAR(result, + parseInterfaceAssignmentTargetIdentifier(start, context)); break; case BinASTKind::ComputedMemberAssignmentTarget: - MOZ_TRY_VAR(result, parseInterfaceComputedMemberAssignmentTarget( - start, kind, context)); + MOZ_TRY_VAR(result, + parseInterfaceComputedMemberAssignmentTarget(start, context)); break; case BinASTKind::ForInOfBinding: - MOZ_TRY_VAR(result, parseInterfaceForInOfBinding(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceForInOfBinding(start, context)); break; case BinASTKind::ObjectAssignmentTarget: - MOZ_TRY_VAR(result, - parseInterfaceObjectAssignmentTarget(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceObjectAssignmentTarget(start, context)); break; case BinASTKind::StaticMemberAssignmentTarget: - MOZ_TRY_VAR(result, parseInterfaceStaticMemberAssignmentTarget( - start, kind, context)); + MOZ_TRY_VAR(result, + parseInterfaceStaticMemberAssignmentTarget(start, context)); break; default: return raiseInvalidKind("AssignmentTargetOrForInOfBinding", kind); @@ -238,15 +233,15 @@ JS::Result BinASTParser::parseSumBinding( switch (kind) { case BinASTKind::ArrayBinding: MOZ_TRY_VAR(result, parseInterfaceArrayBinding( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::BindingIdentifier: MOZ_TRY_VAR(result, parseInterfaceBindingIdentifier( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::ObjectBinding: MOZ_TRY_VAR(result, parseInterfaceObjectBinding( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; default: return raiseInvalidKind("Binding", kind); @@ -311,131 +306,131 @@ JS::Result BinASTParser::parseSumExpression( switch (kind) { case BinASTKind::ArrayExpression: MOZ_TRY_VAR(result, parseInterfaceArrayExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::AssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceAssignmentExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::AwaitExpression: MOZ_TRY_VAR(result, parseInterfaceAwaitExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::BinaryExpression: MOZ_TRY_VAR(result, parseInterfaceBinaryExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::CallExpression: MOZ_TRY_VAR(result, parseInterfaceCallExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::ClassExpression: MOZ_TRY_VAR(result, parseInterfaceClassExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::CompoundAssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceCompoundAssignmentExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::ComputedMemberExpression: MOZ_TRY_VAR(result, parseInterfaceComputedMemberExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::ConditionalExpression: MOZ_TRY_VAR(result, parseInterfaceConditionalExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::EagerArrowExpressionWithExpression: MOZ_TRY_VAR(result, parseInterfaceEagerArrowExpressionWithExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::EagerArrowExpressionWithFunctionBody: MOZ_TRY_VAR(result, parseInterfaceEagerArrowExpressionWithFunctionBody( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::EagerFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceEagerFunctionExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::IdentifierExpression: MOZ_TRY_VAR(result, parseInterfaceIdentifierExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LazyArrowExpressionWithExpression: MOZ_TRY_VAR(result, parseInterfaceLazyArrowExpressionWithExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LazyArrowExpressionWithFunctionBody: MOZ_TRY_VAR(result, parseInterfaceLazyArrowExpressionWithFunctionBody( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LazyFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceLazyFunctionExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralBooleanExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralBooleanExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralInfinityExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralInfinityExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralNullExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNullExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralNumericExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNumericExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralRegExpExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralRegExpExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralStringExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralStringExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::NewExpression: MOZ_TRY_VAR(result, parseInterfaceNewExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::NewTargetExpression: MOZ_TRY_VAR(result, parseInterfaceNewTargetExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::ObjectExpression: MOZ_TRY_VAR(result, parseInterfaceObjectExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::StaticMemberExpression: MOZ_TRY_VAR(result, parseInterfaceStaticMemberExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::TemplateExpression: MOZ_TRY_VAR(result, parseInterfaceTemplateExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::ThisExpression: MOZ_TRY_VAR(result, parseInterfaceThisExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::UnaryExpression: MOZ_TRY_VAR(result, parseInterfaceUnaryExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::UpdateExpression: MOZ_TRY_VAR(result, parseInterfaceUpdateExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::YieldExpression: MOZ_TRY_VAR(result, parseInterfaceYieldExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::YieldStarExpression: MOZ_TRY_VAR(result, parseInterfaceYieldStarExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; default: return raiseInvalidKind("Expression", kind); @@ -502,134 +497,134 @@ JS::Result BinASTParser::parseSumExpressionOrSpreadElement( switch (kind) { case BinASTKind::ArrayExpression: MOZ_TRY_VAR(result, parseInterfaceArrayExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::AssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceAssignmentExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::AwaitExpression: MOZ_TRY_VAR(result, parseInterfaceAwaitExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::BinaryExpression: MOZ_TRY_VAR(result, parseInterfaceBinaryExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::CallExpression: MOZ_TRY_VAR(result, parseInterfaceCallExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::ClassExpression: MOZ_TRY_VAR(result, parseInterfaceClassExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::CompoundAssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceCompoundAssignmentExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::ComputedMemberExpression: MOZ_TRY_VAR(result, parseInterfaceComputedMemberExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::ConditionalExpression: MOZ_TRY_VAR(result, parseInterfaceConditionalExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::EagerArrowExpressionWithExpression: MOZ_TRY_VAR(result, parseInterfaceEagerArrowExpressionWithExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::EagerArrowExpressionWithFunctionBody: MOZ_TRY_VAR(result, parseInterfaceEagerArrowExpressionWithFunctionBody( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::EagerFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceEagerFunctionExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::IdentifierExpression: MOZ_TRY_VAR(result, parseInterfaceIdentifierExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LazyArrowExpressionWithExpression: MOZ_TRY_VAR(result, parseInterfaceLazyArrowExpressionWithExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LazyArrowExpressionWithFunctionBody: MOZ_TRY_VAR(result, parseInterfaceLazyArrowExpressionWithFunctionBody( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LazyFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceLazyFunctionExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralBooleanExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralBooleanExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralInfinityExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralInfinityExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralNullExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNullExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralNumericExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNumericExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralRegExpExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralRegExpExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralStringExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralStringExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::NewExpression: MOZ_TRY_VAR(result, parseInterfaceNewExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::NewTargetExpression: MOZ_TRY_VAR(result, parseInterfaceNewTargetExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::ObjectExpression: MOZ_TRY_VAR(result, parseInterfaceObjectExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::SpreadElement: - MOZ_TRY_VAR(result, parseInterfaceSpreadElement(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceSpreadElement(start, context)); break; case BinASTKind::StaticMemberExpression: MOZ_TRY_VAR(result, parseInterfaceStaticMemberExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::TemplateExpression: MOZ_TRY_VAR(result, parseInterfaceTemplateExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::ThisExpression: MOZ_TRY_VAR(result, parseInterfaceThisExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::UnaryExpression: MOZ_TRY_VAR(result, parseInterfaceUnaryExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::UpdateExpression: MOZ_TRY_VAR(result, parseInterfaceUpdateExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::YieldExpression: MOZ_TRY_VAR(result, parseInterfaceYieldExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::YieldStarExpression: MOZ_TRY_VAR(result, parseInterfaceYieldStarExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; default: return raiseInvalidKind("ExpressionOrSpreadElement", kind); @@ -695,134 +690,134 @@ JS::Result BinASTParser::parseSumExpressionOrSuper( switch (kind) { case BinASTKind::ArrayExpression: MOZ_TRY_VAR(result, parseInterfaceArrayExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::AssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceAssignmentExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::AwaitExpression: MOZ_TRY_VAR(result, parseInterfaceAwaitExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::BinaryExpression: MOZ_TRY_VAR(result, parseInterfaceBinaryExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::CallExpression: MOZ_TRY_VAR(result, parseInterfaceCallExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::ClassExpression: MOZ_TRY_VAR(result, parseInterfaceClassExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::CompoundAssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceCompoundAssignmentExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::ComputedMemberExpression: MOZ_TRY_VAR(result, parseInterfaceComputedMemberExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::ConditionalExpression: MOZ_TRY_VAR(result, parseInterfaceConditionalExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::EagerArrowExpressionWithExpression: MOZ_TRY_VAR(result, parseInterfaceEagerArrowExpressionWithExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::EagerArrowExpressionWithFunctionBody: MOZ_TRY_VAR(result, parseInterfaceEagerArrowExpressionWithFunctionBody( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::EagerFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceEagerFunctionExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::IdentifierExpression: MOZ_TRY_VAR(result, parseInterfaceIdentifierExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LazyArrowExpressionWithExpression: MOZ_TRY_VAR(result, parseInterfaceLazyArrowExpressionWithExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LazyArrowExpressionWithFunctionBody: MOZ_TRY_VAR(result, parseInterfaceLazyArrowExpressionWithFunctionBody( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LazyFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceLazyFunctionExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralBooleanExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralBooleanExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralInfinityExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralInfinityExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralNullExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNullExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralNumericExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNumericExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralRegExpExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralRegExpExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralStringExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralStringExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::NewExpression: MOZ_TRY_VAR(result, parseInterfaceNewExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::NewTargetExpression: MOZ_TRY_VAR(result, parseInterfaceNewTargetExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::ObjectExpression: MOZ_TRY_VAR(result, parseInterfaceObjectExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::StaticMemberExpression: MOZ_TRY_VAR(result, parseInterfaceStaticMemberExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::Super: - MOZ_TRY_VAR(result, parseInterfaceSuper(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceSuper(start, context)); break; case BinASTKind::TemplateExpression: MOZ_TRY_VAR(result, parseInterfaceTemplateExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::ThisExpression: MOZ_TRY_VAR(result, parseInterfaceThisExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::UnaryExpression: MOZ_TRY_VAR(result, parseInterfaceUnaryExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::UpdateExpression: MOZ_TRY_VAR(result, parseInterfaceUpdateExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::YieldExpression: MOZ_TRY_VAR(result, parseInterfaceYieldExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::YieldStarExpression: MOZ_TRY_VAR(result, parseInterfaceYieldStarExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; default: return raiseInvalidKind("ExpressionOrSuper", kind); @@ -838,135 +833,135 @@ BinASTParser::parseSumExpressionOrVariableDeclaration( switch (kind) { case BinASTKind::ArrayExpression: MOZ_TRY_VAR(result, parseInterfaceArrayExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::AssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceAssignmentExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::AwaitExpression: MOZ_TRY_VAR(result, parseInterfaceAwaitExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::BinaryExpression: MOZ_TRY_VAR(result, parseInterfaceBinaryExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::CallExpression: MOZ_TRY_VAR(result, parseInterfaceCallExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::ClassExpression: MOZ_TRY_VAR(result, parseInterfaceClassExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::CompoundAssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceCompoundAssignmentExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::ComputedMemberExpression: MOZ_TRY_VAR(result, parseInterfaceComputedMemberExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::ConditionalExpression: MOZ_TRY_VAR(result, parseInterfaceConditionalExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::EagerArrowExpressionWithExpression: MOZ_TRY_VAR(result, parseInterfaceEagerArrowExpressionWithExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::EagerArrowExpressionWithFunctionBody: MOZ_TRY_VAR(result, parseInterfaceEagerArrowExpressionWithFunctionBody( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::EagerFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceEagerFunctionExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::IdentifierExpression: MOZ_TRY_VAR(result, parseInterfaceIdentifierExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LazyArrowExpressionWithExpression: MOZ_TRY_VAR(result, parseInterfaceLazyArrowExpressionWithExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LazyArrowExpressionWithFunctionBody: MOZ_TRY_VAR(result, parseInterfaceLazyArrowExpressionWithFunctionBody( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LazyFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceLazyFunctionExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralBooleanExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralBooleanExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralInfinityExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralInfinityExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralNullExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNullExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralNumericExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNumericExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralRegExpExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralRegExpExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::LiteralStringExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralStringExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::NewExpression: MOZ_TRY_VAR(result, parseInterfaceNewExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::NewTargetExpression: MOZ_TRY_VAR(result, parseInterfaceNewTargetExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::ObjectExpression: MOZ_TRY_VAR(result, parseInterfaceObjectExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::StaticMemberExpression: MOZ_TRY_VAR(result, parseInterfaceStaticMemberExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::TemplateExpression: MOZ_TRY_VAR(result, parseInterfaceTemplateExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::ThisExpression: MOZ_TRY_VAR(result, parseInterfaceThisExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::UnaryExpression: MOZ_TRY_VAR(result, parseInterfaceUnaryExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::UpdateExpression: MOZ_TRY_VAR(result, parseInterfaceUpdateExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::VariableDeclaration: MOZ_TRY_VAR(result, parseInterfaceVariableDeclaration( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::YieldExpression: MOZ_TRY_VAR(result, parseInterfaceYieldExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; case BinASTKind::YieldStarExpression: MOZ_TRY_VAR(result, parseInterfaceYieldStarExpression( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); break; default: return raiseInvalidKind("ExpressionOrVariableDeclaration", kind); @@ -1006,29 +1001,28 @@ JS::Result BinASTParser::parseSumObjectProperty( ParseNode* result; switch (kind) { case BinASTKind::DataProperty: - MOZ_TRY_VAR(result, parseInterfaceDataProperty(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceDataProperty(start, context)); break; case BinASTKind::EagerGetter: - MOZ_TRY_VAR(result, parseInterfaceEagerGetter(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceEagerGetter(start, context)); break; case BinASTKind::EagerMethod: - MOZ_TRY_VAR(result, parseInterfaceEagerMethod(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceEagerMethod(start, context)); break; case BinASTKind::EagerSetter: - MOZ_TRY_VAR(result, parseInterfaceEagerSetter(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceEagerSetter(start, context)); break; case BinASTKind::LazyGetter: - MOZ_TRY_VAR(result, parseInterfaceLazyGetter(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceLazyGetter(start, context)); break; case BinASTKind::LazyMethod: - MOZ_TRY_VAR(result, parseInterfaceLazyMethod(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceLazyMethod(start, context)); break; case BinASTKind::LazySetter: - MOZ_TRY_VAR(result, parseInterfaceLazySetter(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceLazySetter(start, context)); break; case BinASTKind::ShorthandProperty: - MOZ_TRY_VAR(result, - parseInterfaceShorthandProperty(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceShorthandProperty(start, context)); break; default: return raiseInvalidKind("ObjectProperty", kind); @@ -1065,11 +1059,10 @@ JS::Result BinASTParser::parseSumParameter( ParseNode* result; switch (kind) { case BinASTKind::ArrayBinding: - MOZ_TRY_VAR(result, parseInterfaceArrayBinding(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceArrayBinding(start, context)); break; case BinASTKind::BindingIdentifier: - MOZ_TRY_VAR(result, - parseInterfaceBindingIdentifier(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceBindingIdentifier(start, context)); if (!pc_->positionalFormalParameterNames().append( result->template as().atom())) { return raiseOOM(); @@ -1079,11 +1072,10 @@ JS::Result BinASTParser::parseSumParameter( } break; case BinASTKind::BindingWithInitializer: - MOZ_TRY_VAR(result, - parseInterfaceBindingWithInitializer(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceBindingWithInitializer(start, context)); break; case BinASTKind::ObjectBinding: - MOZ_TRY_VAR(result, parseInterfaceObjectBinding(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceObjectBinding(start, context)); break; default: return raiseInvalidKind("Parameter", kind); @@ -1117,10 +1109,10 @@ JS::Result BinASTParser::parseSumProgram( ParseNode* result; switch (kind) { case BinASTKind::Module: - MOZ_TRY_VAR(result, parseInterfaceModule(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceModule(start, context)); break; case BinASTKind::Script: - MOZ_TRY_VAR(result, parseInterfaceScript(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceScript(start, context)); break; default: return raiseInvalidKind("Program", kind); @@ -1154,12 +1146,10 @@ JS::Result BinASTParser::parseSumPropertyName( ParseNode* result; switch (kind) { case BinASTKind::ComputedPropertyName: - MOZ_TRY_VAR(result, - parseInterfaceComputedPropertyName(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceComputedPropertyName(start, context)); break; case BinASTKind::LiteralPropertyName: - MOZ_TRY_VAR(result, - parseInterfaceLiteralPropertyName(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceLiteralPropertyName(start, context)); break; default: return raiseInvalidKind("PropertyName", kind); @@ -1195,16 +1185,16 @@ JS::Result BinASTParser::parseSumSimpleAssignmentTarget( ParseNode* result; switch (kind) { case BinASTKind::AssignmentTargetIdentifier: - MOZ_TRY_VAR(result, parseInterfaceAssignmentTargetIdentifier(start, kind, - context)); + MOZ_TRY_VAR(result, + parseInterfaceAssignmentTargetIdentifier(start, context)); break; case BinASTKind::ComputedMemberAssignmentTarget: - MOZ_TRY_VAR(result, parseInterfaceComputedMemberAssignmentTarget( - start, kind, context)); + MOZ_TRY_VAR(result, + parseInterfaceComputedMemberAssignmentTarget(start, context)); break; case BinASTKind::StaticMemberAssignmentTarget: - MOZ_TRY_VAR(result, parseInterfaceStaticMemberAssignmentTarget( - start, kind, context)); + MOZ_TRY_VAR(result, + parseInterfaceStaticMemberAssignmentTarget(start, context)); break; default: return raiseInvalidKind("SimpleAssignmentTarget", kind); @@ -1261,86 +1251,79 @@ JS::Result BinASTParser::parseSumStatement( ParseNode* result; switch (kind) { case BinASTKind::Block: - MOZ_TRY_VAR(result, parseInterfaceBlock(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceBlock(start, context)); break; case BinASTKind::BreakStatement: - MOZ_TRY_VAR(result, parseInterfaceBreakStatement(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceBreakStatement(start, context)); break; case BinASTKind::ClassDeclaration: - MOZ_TRY_VAR(result, parseInterfaceClassDeclaration(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceClassDeclaration(start, context)); break; case BinASTKind::ContinueStatement: - MOZ_TRY_VAR(result, - parseInterfaceContinueStatement(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceContinueStatement(start, context)); break; case BinASTKind::DebuggerStatement: - MOZ_TRY_VAR(result, - parseInterfaceDebuggerStatement(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceDebuggerStatement(start, context)); break; case BinASTKind::DoWhileStatement: - MOZ_TRY_VAR(result, parseInterfaceDoWhileStatement(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceDoWhileStatement(start, context)); break; case BinASTKind::EagerFunctionDeclaration: MOZ_TRY_VAR(result, - parseInterfaceEagerFunctionDeclaration(start, kind, context)); + parseInterfaceEagerFunctionDeclaration(start, context)); break; case BinASTKind::EmptyStatement: - MOZ_TRY_VAR(result, parseInterfaceEmptyStatement(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceEmptyStatement(start, context)); break; case BinASTKind::ExpressionStatement: - MOZ_TRY_VAR(result, - parseInterfaceExpressionStatement(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceExpressionStatement(start, context)); break; case BinASTKind::ForInStatement: - MOZ_TRY_VAR(result, parseInterfaceForInStatement(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceForInStatement(start, context)); break; case BinASTKind::ForOfStatement: - MOZ_TRY_VAR(result, parseInterfaceForOfStatement(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceForOfStatement(start, context)); break; case BinASTKind::ForStatement: - MOZ_TRY_VAR(result, parseInterfaceForStatement(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceForStatement(start, context)); break; case BinASTKind::IfStatement: - MOZ_TRY_VAR(result, parseInterfaceIfStatement(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceIfStatement(start, context)); break; case BinASTKind::LabelledStatement: - MOZ_TRY_VAR(result, - parseInterfaceLabelledStatement(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceLabelledStatement(start, context)); break; case BinASTKind::LazyFunctionDeclaration: MOZ_TRY_VAR(result, - parseInterfaceLazyFunctionDeclaration(start, kind, context)); + parseInterfaceLazyFunctionDeclaration(start, context)); break; case BinASTKind::ReturnStatement: - MOZ_TRY_VAR(result, parseInterfaceReturnStatement(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceReturnStatement(start, context)); break; case BinASTKind::SwitchStatement: - MOZ_TRY_VAR(result, parseInterfaceSwitchStatement(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceSwitchStatement(start, context)); break; case BinASTKind::SwitchStatementWithDefault: - MOZ_TRY_VAR(result, parseInterfaceSwitchStatementWithDefault(start, kind, - context)); + MOZ_TRY_VAR(result, + parseInterfaceSwitchStatementWithDefault(start, context)); break; case BinASTKind::ThrowStatement: - MOZ_TRY_VAR(result, parseInterfaceThrowStatement(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceThrowStatement(start, context)); break; case BinASTKind::TryCatchStatement: - MOZ_TRY_VAR(result, - parseInterfaceTryCatchStatement(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceTryCatchStatement(start, context)); break; case BinASTKind::TryFinallyStatement: - MOZ_TRY_VAR(result, - parseInterfaceTryFinallyStatement(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceTryFinallyStatement(start, context)); break; case BinASTKind::VariableDeclaration: - MOZ_TRY_VAR(result, - parseInterfaceVariableDeclaration(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceVariableDeclaration(start, context)); break; case BinASTKind::WhileStatement: - MOZ_TRY_VAR(result, parseInterfaceWhileStatement(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceWhileStatement(start, context)); break; case BinASTKind::WithStatement: - MOZ_TRY_VAR(result, parseInterfaceWithStatement(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceWithStatement(start, context)); break; default: return raiseInvalidKind("Statement", kind); @@ -1353,7 +1336,7 @@ JS::Result BinASTParser::parseSumStatement( // delegated to another parser. template JS::Result BinASTParser::parseInterfaceArrayAssignmentTarget( - const size_t start, const BinASTKind kind, const FieldContext& context) { + const size_t start, const FieldContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release " "(ArrayAssignmentTarget)"); @@ -1361,17 +1344,14 @@ JS::Result BinASTParser::parseInterfaceArrayAssignmentTarget( template JS::Result BinASTParser::parseInterfaceArrayBinding( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { + const size_t start, const FieldOrListContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release (ArrayBinding)"); } template JS::Result BinASTParser::parseInterfaceArrayExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::ArrayExpression); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL(elements, @@ -1400,8 +1380,7 @@ JS::Result BinASTParser::parseAssertedBlockScope( guard.init(); MOZ_TRY(tokenizer_->enterInterface(kind, context)); const auto start = tokenizer_->offset(); - BINJS_MOZ_TRY_DECL(result, - parseInterfaceAssertedBlockScope(start, kind, context)); + BINJS_MOZ_TRY_DECL(result, parseInterfaceAssertedBlockScope(start, context)); MOZ_TRY(guard.done()); return result; @@ -1409,8 +1388,7 @@ JS::Result BinASTParser::parseAssertedBlockScope( template JS::Result BinASTParser::parseInterfaceAssertedBlockScope( - const size_t start, const BinASTKind kind, const FieldContext& context) { - MOZ_ASSERT(kind == BinASTKind::AssertedBlockScope); + const size_t start, const FieldContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); const auto scopeKind = AssertedScopeKind::Block; @@ -1452,7 +1430,7 @@ JS::Result BinASTParser::parseAssertedBoundName( MOZ_TRY(tokenizer_->enterInterface(kind, context)); const auto start = tokenizer_->offset(); BINJS_MOZ_TRY_DECL( - result, parseInterfaceAssertedBoundName(start, kind, scopeKind, context)); + result, parseInterfaceAssertedBoundName(start, scopeKind, context)); MOZ_TRY(guard.done()); return result; @@ -1460,9 +1438,8 @@ JS::Result BinASTParser::parseAssertedBoundName( template JS::Result BinASTParser::parseInterfaceAssertedBoundName( - const size_t start, const BinASTKind kind, AssertedScopeKind scopeKind, + const size_t start, AssertedScopeKind scopeKind, const ListContext& context) { - MOZ_ASSERT(kind == BinASTKind::AssertedBoundName); BINJS_TRY(CheckRecursionLimit(cx_)); const bool allowDuplicateName = false; @@ -1497,8 +1474,8 @@ JS::Result BinASTParser::parseAssertedBoundNamesScope( guard.init(); MOZ_TRY(tokenizer_->enterInterface(kind, context)); const auto start = tokenizer_->offset(); - BINJS_MOZ_TRY_DECL( - result, parseInterfaceAssertedBoundNamesScope(start, kind, context)); + BINJS_MOZ_TRY_DECL(result, + parseInterfaceAssertedBoundNamesScope(start, context)); MOZ_TRY(guard.done()); return result; @@ -1506,8 +1483,7 @@ JS::Result BinASTParser::parseAssertedBoundNamesScope( template JS::Result BinASTParser::parseInterfaceAssertedBoundNamesScope( - const size_t start, const BinASTKind kind, const FieldContext& context) { - MOZ_ASSERT(kind == BinASTKind::AssertedBoundNamesScope); + const size_t start, const FieldContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); const auto scopeKind = AssertedScopeKind::Catch; @@ -1549,8 +1525,8 @@ JS::Result BinASTParser::parseAssertedDeclaredName( guard.init(); MOZ_TRY(tokenizer_->enterInterface(kind, context)); const auto start = tokenizer_->offset(); - BINJS_MOZ_TRY_DECL(result, parseInterfaceAssertedDeclaredName( - start, kind, scopeKind, context)); + BINJS_MOZ_TRY_DECL( + result, parseInterfaceAssertedDeclaredName(start, scopeKind, context)); MOZ_TRY(guard.done()); return result; @@ -1558,9 +1534,8 @@ JS::Result BinASTParser::parseAssertedDeclaredName( template JS::Result BinASTParser::parseInterfaceAssertedDeclaredName( - const size_t start, const BinASTKind kind, AssertedScopeKind scopeKind, + const size_t start, AssertedScopeKind scopeKind, const ListContext& context) { - MOZ_ASSERT(kind == BinASTKind::AssertedDeclaredName); BINJS_TRY(CheckRecursionLimit(cx_)); const bool allowDuplicateName = false; @@ -1608,7 +1583,7 @@ JS::Result BinASTParser::parseAssertedParameterScope( MOZ_TRY(tokenizer_->enterInterface(kind, context)); const auto start = tokenizer_->offset(); BINJS_MOZ_TRY_DECL(result, parseInterfaceAssertedParameterScope( - start, kind, positionalParams, context)); + start, positionalParams, context)); MOZ_TRY(guard.done()); return result; @@ -1616,10 +1591,8 @@ JS::Result BinASTParser::parseAssertedParameterScope( template JS::Result BinASTParser::parseInterfaceAssertedParameterScope( - const size_t start, const BinASTKind kind, - MutableHandle> positionalParams, + const size_t start, MutableHandle> positionalParams, const FieldContext& context) { - MOZ_ASSERT(kind == BinASTKind::AssertedParameterScope); BINJS_TRY(CheckRecursionLimit(cx_)); const auto scopeKind = AssertedScopeKind::Parameter; @@ -1652,10 +1625,9 @@ JS::Result BinASTParser::parseInterfaceAssertedParameterScope( template JS::Result BinASTParser::parseInterfaceAssertedPositionalParameterName( - const size_t start, const BinASTKind kind, AssertedScopeKind scopeKind, + const size_t start, AssertedScopeKind scopeKind, MutableHandle> positionalParams, const ListContext& context) { - MOZ_ASSERT(kind == BinASTKind::AssertedPositionalParameterName); BINJS_TRY(CheckRecursionLimit(cx_)); bool allowDuplicateName = !pc_->sc()->strict(); @@ -1719,8 +1691,8 @@ JS::Result BinASTParser::parseAssertedScriptGlobalScope( guard.init(); MOZ_TRY(tokenizer_->enterInterface(kind, context)); const auto start = tokenizer_->offset(); - BINJS_MOZ_TRY_DECL( - result, parseInterfaceAssertedScriptGlobalScope(start, kind, context)); + BINJS_MOZ_TRY_DECL(result, + parseInterfaceAssertedScriptGlobalScope(start, context)); MOZ_TRY(guard.done()); return result; @@ -1728,8 +1700,7 @@ JS::Result BinASTParser::parseAssertedScriptGlobalScope( template JS::Result BinASTParser::parseInterfaceAssertedScriptGlobalScope( - const size_t start, const BinASTKind kind, const FieldContext& context) { - MOZ_ASSERT(kind == BinASTKind::AssertedScriptGlobalScope); + const size_t start, const FieldContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); const auto scopeKind = AssertedScopeKind::Global; @@ -1770,8 +1741,7 @@ JS::Result BinASTParser::parseAssertedVarScope( guard.init(); MOZ_TRY(tokenizer_->enterInterface(kind, context)); const auto start = tokenizer_->offset(); - BINJS_MOZ_TRY_DECL(result, - parseInterfaceAssertedVarScope(start, kind, context)); + BINJS_MOZ_TRY_DECL(result, parseInterfaceAssertedVarScope(start, context)); MOZ_TRY(guard.done()); return result; @@ -1779,8 +1749,7 @@ JS::Result BinASTParser::parseAssertedVarScope( template JS::Result BinASTParser::parseInterfaceAssertedVarScope( - const size_t start, const BinASTKind kind, const FieldContext& context) { - MOZ_ASSERT(kind == BinASTKind::AssertedVarScope); + const size_t start, const FieldContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); const auto scopeKind = AssertedScopeKind::Var; @@ -1807,9 +1776,7 @@ JS::Result BinASTParser::parseInterfaceAssertedVarScope( template JS::Result BinASTParser::parseInterfaceAssignmentExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::AssignmentExpression); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL( @@ -1829,8 +1796,7 @@ JS::Result BinASTParser::parseInterfaceAssignmentExpression( template JS::Result BinASTParser::parseInterfaceAssignmentTargetIdentifier( - const size_t start, const BinASTKind kind, const FieldContext& context) { - MOZ_ASSERT(kind == BinASTKind::AssignmentTargetIdentifier); + const size_t start, const FieldContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); RootedAtom name(cx_); @@ -1847,17 +1813,14 @@ BinASTParser::parseInterfaceAssignmentTargetIdentifier( template JS::Result BinASTParser::parseInterfaceAwaitExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { + const size_t start, const FieldOrListContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release (AwaitExpression)"); } template JS::Result BinASTParser::parseInterfaceBinaryExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::BinaryExpression); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL(operator_, @@ -1981,8 +1944,7 @@ JS::Result BinASTParser::parseBindingIdentifier( guard.init(); MOZ_TRY(tokenizer_->enterInterface(kind, context)); const auto start = tokenizer_->offset(); - BINJS_MOZ_TRY_DECL(result, - parseInterfaceBindingIdentifier(start, kind, context)); + BINJS_MOZ_TRY_DECL(result, parseInterfaceBindingIdentifier(start, context)); MOZ_TRY(guard.done()); return result; @@ -1990,9 +1952,7 @@ JS::Result BinASTParser::parseBindingIdentifier( template JS::Result BinASTParser::parseInterfaceBindingIdentifier( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::BindingIdentifier); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); RootedAtom name(cx_); @@ -2006,8 +1966,7 @@ JS::Result BinASTParser::parseInterfaceBindingIdentifier( template JS::Result BinASTParser::parseInterfaceBindingWithInitializer( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { + const size_t start, const FieldOrListContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release " "(BindingWithInitializer)"); @@ -2028,7 +1987,7 @@ JS::Result BinASTParser::parseBlock( guard.init(); MOZ_TRY(tokenizer_->enterInterface(kind, context)); const auto start = tokenizer_->offset(); - BINJS_MOZ_TRY_DECL(result, parseInterfaceBlock(start, kind, context)); + BINJS_MOZ_TRY_DECL(result, parseInterfaceBlock(start, context)); MOZ_TRY(guard.done()); return result; @@ -2036,9 +1995,7 @@ JS::Result BinASTParser::parseBlock( template JS::Result BinASTParser::parseInterfaceBlock( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::Block); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); ParseContext::Statement stmt(pc_, StatementKind::Block); ParseContext::Scope currentScope(cx_, pc_, usedNames_); @@ -2059,9 +2016,7 @@ JS::Result BinASTParser::parseInterfaceBlock( template JS::Result BinASTParser::parseInterfaceBreakStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::BreakStatement); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); RootedAtom label(cx_); MOZ_TRY_VAR(label, tokenizer_->readMaybeAtom(FieldContext( @@ -2094,9 +2049,7 @@ JS::Result BinASTParser::parseInterfaceBreakStatement( template JS::Result BinASTParser::parseInterfaceCallExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::CallExpression); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL(callee, @@ -2154,7 +2107,7 @@ JS::Result BinASTParser::parseCatchClause( guard.init(); MOZ_TRY(tokenizer_->enterInterface(kind, context)); const auto start = tokenizer_->offset(); - BINJS_MOZ_TRY_DECL(result, parseInterfaceCatchClause(start, kind, context)); + BINJS_MOZ_TRY_DECL(result, parseInterfaceCatchClause(start, context)); MOZ_TRY(guard.done()); return result; @@ -2162,8 +2115,7 @@ JS::Result BinASTParser::parseCatchClause( template JS::Result BinASTParser::parseInterfaceCatchClause( - const size_t start, const BinASTKind kind, const FieldContext& context) { - MOZ_ASSERT(kind == BinASTKind::CatchClause); + const size_t start, const FieldContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); ParseContext::Statement stmt(pc_, StatementKind::Catch); ParseContext::Scope currentScope(cx_, pc_, usedNames_); @@ -2191,16 +2143,14 @@ JS::Result BinASTParser::parseInterfaceCatchClause( template JS::Result BinASTParser::parseInterfaceClassDeclaration( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { + const size_t start, const FieldOrListContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release (ClassDeclaration)"); } template JS::Result BinASTParser::parseInterfaceClassExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { + const size_t start, const FieldOrListContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release (ClassExpression)"); } @@ -2208,9 +2158,7 @@ JS::Result BinASTParser::parseInterfaceClassExpression( template JS::Result BinASTParser::parseInterfaceCompoundAssignmentExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::CompoundAssignmentExpression); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL( @@ -2274,8 +2222,7 @@ BinASTParser::parseInterfaceCompoundAssignmentExpression( template JS::Result BinASTParser::parseInterfaceComputedMemberAssignmentTarget( - const size_t start, const BinASTKind kind, const FieldContext& context) { - MOZ_ASSERT(kind == BinASTKind::ComputedMemberAssignmentTarget); + const size_t start, const FieldContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL( @@ -2296,9 +2243,7 @@ BinASTParser::parseInterfaceComputedMemberAssignmentTarget( template JS::Result BinASTParser::parseInterfaceComputedMemberExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::ComputedMemberExpression); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL( @@ -2317,7 +2262,7 @@ BinASTParser::parseInterfaceComputedMemberExpression( template JS::Result BinASTParser::parseInterfaceComputedPropertyName( - const size_t start, const BinASTKind kind, const FieldContext& context) { + const size_t start, const FieldContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release " "(ComputedPropertyName)"); @@ -2325,9 +2270,7 @@ JS::Result BinASTParser::parseInterfaceComputedPropertyName( template JS::Result BinASTParser::parseInterfaceConditionalExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::ConditionalExpression); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL( @@ -2350,9 +2293,7 @@ JS::Result BinASTParser::parseInterfaceConditionalExpression( template JS::Result BinASTParser::parseInterfaceContinueStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::ContinueStatement); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); RootedAtom label(cx_); MOZ_TRY_VAR(label, tokenizer_->readMaybeAtom(FieldContext( @@ -2385,8 +2326,7 @@ JS::Result BinASTParser::parseInterfaceContinueStatement( template JS::Result BinASTParser::parseInterfaceDataProperty( - const size_t start, const BinASTKind kind, const ListContext& context) { - MOZ_ASSERT(kind == BinASTKind::DataProperty); + const size_t start, const ListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL(name, parsePropertyName(FieldContext( @@ -2414,8 +2354,7 @@ JS::Result BinASTParser::parseInterfaceDataProperty( template JS::Result BinASTParser::parseInterfaceDebuggerStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { + const size_t start, const FieldOrListContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release (DebuggerStatement)"); } @@ -2434,7 +2373,7 @@ JS::Result BinASTParser::parseDirective( guard.init(); MOZ_TRY(tokenizer_->enterInterface(kind, context)); const auto start = tokenizer_->offset(); - BINJS_MOZ_TRY_DECL(result, parseInterfaceDirective(start, kind, context)); + BINJS_MOZ_TRY_DECL(result, parseInterfaceDirective(start, context)); MOZ_TRY(guard.done()); return result; @@ -2442,8 +2381,7 @@ JS::Result BinASTParser::parseDirective( template JS::Result BinASTParser::parseInterfaceDirective( - const size_t start, const BinASTKind kind, const ListContext& context) { - MOZ_ASSERT(kind == BinASTKind::Directive); + const size_t start, const ListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); RootedAtom rawValue(cx_); @@ -2457,9 +2395,7 @@ JS::Result BinASTParser::parseInterfaceDirective( template JS::Result BinASTParser::parseInterfaceDoWhileStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::DoWhileStatement); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); ParseContext::Statement stmt(pc_, StatementKind::DoLoop); @@ -2479,8 +2415,7 @@ JS::Result BinASTParser::parseInterfaceDoWhileStatement( template JS::Result BinASTParser::parseInterfaceEagerArrowExpressionWithExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { + const size_t start, const FieldOrListContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release " "(EagerArrowExpressionWithExpression)"); @@ -2489,8 +2424,7 @@ BinASTParser::parseInterfaceEagerArrowExpressionWithExpression( template JS::Result BinASTParser::parseInterfaceEagerArrowExpressionWithFunctionBody( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { + const size_t start, const FieldOrListContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release " "(EagerArrowExpressionWithFunctionBody)"); @@ -2499,9 +2433,7 @@ BinASTParser::parseInterfaceEagerArrowExpressionWithFunctionBody( template JS::Result BinASTParser::parseInterfaceEagerFunctionDeclaration( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::EagerFunctionDeclaration); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); const auto syntax = FunctionSyntaxKind::Statement; @@ -2567,7 +2499,7 @@ BinASTParser::parseInterfaceEagerFunctionDeclaration( BINJS_TRY_DECL(lexicalScopeData, NewLexicalScopeData(cx_, lexicalScope, alloc_, pc_)); BINJS_TRY_DECL(bodyScope, handler_.newLexicalScope(*lexicalScopeData, body)); - BINJS_MOZ_TRY_DECL(result, makeEmptyFunctionNode(start, kind, funbox)); + BINJS_MOZ_TRY_DECL(result, makeEmptyFunctionNode(start, syntax, funbox)); MOZ_TRY(setFunctionParametersAndBody(result, params, bodyScope)); MOZ_TRY(finishEagerFunction(funbox, nargs)); return result; @@ -2575,9 +2507,7 @@ BinASTParser::parseInterfaceEagerFunctionDeclaration( template JS::Result BinASTParser::parseInterfaceEagerFunctionExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::EagerFunctionExpression); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); const auto syntax = FunctionSyntaxKind::Expression; @@ -2642,7 +2572,7 @@ JS::Result BinASTParser::parseInterfaceEagerFunctionExpression( BINJS_TRY_DECL(lexicalScopeData, NewLexicalScopeData(cx_, lexicalScope, alloc_, pc_)); BINJS_TRY_DECL(bodyScope, handler_.newLexicalScope(*lexicalScopeData, body)); - BINJS_MOZ_TRY_DECL(result, makeEmptyFunctionNode(start, kind, funbox)); + BINJS_MOZ_TRY_DECL(result, makeEmptyFunctionNode(start, syntax, funbox)); MOZ_TRY(setFunctionParametersAndBody(result, params, bodyScope)); MOZ_TRY(finishEagerFunction(funbox, nargs)); return result; @@ -2650,8 +2580,7 @@ JS::Result BinASTParser::parseInterfaceEagerFunctionExpression( template JS::Result BinASTParser::parseInterfaceEagerGetter( - const size_t start, const BinASTKind kind, const ListContext& context) { - MOZ_ASSERT(kind == BinASTKind::EagerGetter); + const size_t start, const ListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); const auto syntax = FunctionSyntaxKind::Setter; const bool isGenerator = false; @@ -2699,7 +2628,7 @@ JS::Result BinASTParser::parseInterfaceEagerGetter( BINJS_TRY_DECL(lexicalScopeData, NewLexicalScopeData(cx_, lexicalScope, alloc_, pc_)); BINJS_TRY_DECL(bodyScope, handler_.newLexicalScope(*lexicalScopeData, body)); - BINJS_MOZ_TRY_DECL(method, makeEmptyFunctionNode(start, kind, funbox)); + BINJS_MOZ_TRY_DECL(method, makeEmptyFunctionNode(start, syntax, funbox)); MOZ_TRY(setFunctionParametersAndBody(method, params, bodyScope)); BINJS_TRY_DECL(result, handler_.newObjectMethodOrPropertyDefinition( name, method, accessorType)); @@ -2709,8 +2638,7 @@ JS::Result BinASTParser::parseInterfaceEagerGetter( template JS::Result BinASTParser::parseInterfaceEagerMethod( - const size_t start, const BinASTKind kind, const ListContext& context) { - MOZ_ASSERT(kind == BinASTKind::EagerMethod); + const size_t start, const ListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); const auto syntax = FunctionSyntaxKind::Method; const auto accessorType = AccessorType::None; @@ -2773,7 +2701,7 @@ JS::Result BinASTParser::parseInterfaceEagerMethod( BINJS_TRY_DECL(lexicalScopeData, NewLexicalScopeData(cx_, lexicalScope, alloc_, pc_)); BINJS_TRY_DECL(bodyScope, handler_.newLexicalScope(*lexicalScopeData, body)); - BINJS_MOZ_TRY_DECL(method, makeEmptyFunctionNode(start, kind, funbox)); + BINJS_MOZ_TRY_DECL(method, makeEmptyFunctionNode(start, syntax, funbox)); MOZ_TRY(setFunctionParametersAndBody(method, params, bodyScope)); BINJS_TRY_DECL(result, handler_.newObjectMethodOrPropertyDefinition( name, method, accessorType)); @@ -2783,8 +2711,7 @@ JS::Result BinASTParser::parseInterfaceEagerMethod( template JS::Result BinASTParser::parseInterfaceEagerSetter( - const size_t start, const BinASTKind kind, const ListContext& context) { - MOZ_ASSERT(kind == BinASTKind::EagerSetter); + const size_t start, const ListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); const auto syntax = FunctionSyntaxKind::Setter; const bool isGenerator = false; @@ -2835,7 +2762,7 @@ JS::Result BinASTParser::parseInterfaceEagerSetter( BINJS_TRY_DECL(lexicalScopeData, NewLexicalScopeData(cx_, lexicalScope, alloc_, pc_)); BINJS_TRY_DECL(bodyScope, handler_.newLexicalScope(*lexicalScopeData, body)); - BINJS_MOZ_TRY_DECL(method, makeEmptyFunctionNode(start, kind, funbox)); + BINJS_MOZ_TRY_DECL(method, makeEmptyFunctionNode(start, syntax, funbox)); MOZ_TRY(setFunctionParametersAndBody(method, params, bodyScope)); BINJS_TRY_DECL(result, handler_.newObjectMethodOrPropertyDefinition( name, method, accessorType)); @@ -2845,9 +2772,7 @@ JS::Result BinASTParser::parseInterfaceEagerSetter( template JS::Result BinASTParser::parseInterfaceEmptyStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::EmptyStatement); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_TRY_DECL(result, handler_.newEmptyStatement(tokenizer_->pos(start))); @@ -2856,9 +2781,7 @@ JS::Result BinASTParser::parseInterfaceEmptyStatement( template JS::Result BinASTParser::parseInterfaceExpressionStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::ExpressionStatement); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL( @@ -2872,8 +2795,7 @@ JS::Result BinASTParser::parseInterfaceExpressionStatement( template JS::Result BinASTParser::parseInterfaceForInOfBinding( - const size_t start, const BinASTKind kind, const FieldContext& context) { - MOZ_ASSERT(kind == BinASTKind::ForInOfBinding); + const size_t start, const FieldContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); AutoVariableDeclarationKind kindGuard(this); @@ -2907,9 +2829,7 @@ JS::Result BinASTParser::parseInterfaceForInOfBinding( template JS::Result BinASTParser::parseInterfaceForInStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::ForInStatement); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); ParseContext::Statement stmt(pc_, StatementKind::ForInLoop); @@ -2946,17 +2866,14 @@ JS::Result BinASTParser::parseInterfaceForInStatement( template JS::Result BinASTParser::parseInterfaceForOfStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { + const size_t start, const FieldOrListContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release (ForOfStatement)"); } template JS::Result BinASTParser::parseInterfaceForStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::ForStatement); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); ParseContext::Statement stmt(pc_, StatementKind::ForLoop); @@ -3008,8 +2925,7 @@ JS::Result BinASTParser::parseFormalParameters( guard.init(); MOZ_TRY(tokenizer_->enterInterface(kind, context)); const auto start = tokenizer_->offset(); - BINJS_MOZ_TRY_DECL(result, - parseInterfaceFormalParameters(start, kind, context)); + BINJS_MOZ_TRY_DECL(result, parseInterfaceFormalParameters(start, context)); MOZ_TRY(guard.done()); return result; @@ -3017,8 +2933,7 @@ JS::Result BinASTParser::parseFormalParameters( template JS::Result BinASTParser::parseInterfaceFormalParameters( - const size_t start, const BinASTKind kind, const FieldContext& context) { - MOZ_ASSERT(kind == BinASTKind::FormalParameters); + const size_t start, const FieldContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL(items, @@ -3059,7 +2974,7 @@ JS::Result BinASTParser::parseFunctionExpressionContents( const auto start = tokenizer_->offset(); BINJS_MOZ_TRY_DECL(result, parseInterfaceFunctionExpressionContents( - start, kind, funLength, paramsOut, bodyOut, context)); + start, funLength, paramsOut, bodyOut, context)); MOZ_TRY(guard.done()); return result; @@ -3067,10 +2982,8 @@ JS::Result BinASTParser::parseFunctionExpressionContents( template JS::Result BinASTParser::parseInterfaceFunctionExpressionContents( - const size_t start, const BinASTKind kind, uint32_t funLength, - ListNode** paramsOut, ListNode** bodyOut, - const FieldOrRootContext& context) { - MOZ_ASSERT(kind == BinASTKind::FunctionExpressionContents); + const size_t start, uint32_t funLength, ListNode** paramsOut, + ListNode** bodyOut, const FieldOrRootContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL( @@ -3136,7 +3049,7 @@ JS::Result BinASTParser::parseFunctionOrMethodContents( const auto start = tokenizer_->offset(); BINJS_MOZ_TRY_DECL(result, parseInterfaceFunctionOrMethodContents( - start, kind, funLength, paramsOut, bodyOut, context)); + start, funLength, paramsOut, bodyOut, context)); MOZ_TRY(guard.done()); return result; @@ -3144,10 +3057,8 @@ JS::Result BinASTParser::parseFunctionOrMethodContents( template JS::Result BinASTParser::parseInterfaceFunctionOrMethodContents( - const size_t start, const BinASTKind kind, uint32_t funLength, - ListNode** paramsOut, ListNode** bodyOut, - const FieldOrRootContext& context) { - MOZ_ASSERT(kind == BinASTKind::FunctionOrMethodContents); + const size_t start, uint32_t funLength, ListNode** paramsOut, + ListNode** bodyOut, const FieldOrRootContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL( @@ -3198,8 +3109,8 @@ JS::Result BinASTParser::parseGetterContents( MOZ_TRY(tokenizer_->enterInterface(kind, context)); const auto start = tokenizer_->offset(); BINJS_MOZ_TRY_DECL( - result, parseInterfaceGetterContents(start, kind, funLength, paramsOut, - bodyOut, context)); + result, parseInterfaceGetterContents(start, funLength, paramsOut, bodyOut, + context)); MOZ_TRY(guard.done()); return result; @@ -3207,9 +3118,8 @@ JS::Result BinASTParser::parseGetterContents( template JS::Result BinASTParser::parseInterfaceGetterContents( - const size_t start, const BinASTKind kind, uint32_t funLength, - ListNode** paramsOut, ListNode** bodyOut, const FieldContext& context) { - MOZ_ASSERT(kind == BinASTKind::GetterContents); + const size_t start, uint32_t funLength, ListNode** paramsOut, + ListNode** bodyOut, const FieldContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL( @@ -3246,7 +3156,7 @@ JS::Result BinASTParser::parseIdentifierExpression( MOZ_TRY(tokenizer_->enterInterface(kind, context)); const auto start = tokenizer_->offset(); BINJS_MOZ_TRY_DECL(result, - parseInterfaceIdentifierExpression(start, kind, context)); + parseInterfaceIdentifierExpression(start, context)); MOZ_TRY(guard.done()); return result; @@ -3254,9 +3164,7 @@ JS::Result BinASTParser::parseIdentifierExpression( template JS::Result BinASTParser::parseInterfaceIdentifierExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::IdentifierExpression); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); RootedAtom name(cx_); @@ -3272,9 +3180,7 @@ JS::Result BinASTParser::parseInterfaceIdentifierExpression( template JS::Result BinASTParser::parseInterfaceIfStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::IfStatement); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL(test, parseExpression(FieldContext( @@ -3295,9 +3201,7 @@ JS::Result BinASTParser::parseInterfaceIfStatement( template JS::Result BinASTParser::parseInterfaceLabelledStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::LabelledStatement); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); RootedAtom label(cx_); @@ -3319,8 +3223,7 @@ JS::Result BinASTParser::parseInterfaceLabelledStatement( template JS::Result BinASTParser::parseInterfaceLazyArrowExpressionWithExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { + const size_t start, const FieldOrListContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release " "(LazyArrowExpressionWithExpression)"); @@ -3329,8 +3232,7 @@ BinASTParser::parseInterfaceLazyArrowExpressionWithExpression( template JS::Result BinASTParser::parseInterfaceLazyArrowExpressionWithFunctionBody( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { + const size_t start, const FieldOrListContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release " "(LazyArrowExpressionWithFunctionBody)"); @@ -3338,9 +3240,7 @@ BinASTParser::parseInterfaceLazyArrowExpressionWithFunctionBody( template JS::Result BinASTParser::parseInterfaceLazyFunctionDeclaration( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::LazyFunctionDeclaration); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); const auto syntax = FunctionSyntaxKind::Statement; @@ -3389,7 +3289,7 @@ JS::Result BinASTParser::parseInterfaceLazyFunctionDeclaration( forceStrictIfNecessary(funbox, directives); - BINJS_MOZ_TRY_DECL(result, makeEmptyFunctionNode(start, kind, funbox)); + BINJS_MOZ_TRY_DECL(result, makeEmptyFunctionNode(start, syntax, funbox)); auto skipStart = contentsSkip.startOffset(); auto skipEnd = skipStart + contentsSkip.length(); @@ -3399,9 +3299,7 @@ JS::Result BinASTParser::parseInterfaceLazyFunctionDeclaration( template JS::Result BinASTParser::parseInterfaceLazyFunctionExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::LazyFunctionExpression); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); const auto syntax = FunctionSyntaxKind::Expression; @@ -3450,7 +3348,7 @@ JS::Result BinASTParser::parseInterfaceLazyFunctionExpression( forceStrictIfNecessary(funbox, directives); - BINJS_MOZ_TRY_DECL(result, makeEmptyFunctionNode(start, kind, funbox)); + BINJS_MOZ_TRY_DECL(result, makeEmptyFunctionNode(start, syntax, funbox)); auto skipStart = contentsSkip.startOffset(); auto skipEnd = skipStart + contentsSkip.length(); @@ -3460,21 +3358,21 @@ JS::Result BinASTParser::parseInterfaceLazyFunctionExpression( template JS::Result BinASTParser::parseInterfaceLazyGetter( - const size_t start, const BinASTKind kind, const ListContext& context) { + const size_t start, const ListContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release (LazyGetter)"); } template JS::Result BinASTParser::parseInterfaceLazyMethod( - const size_t start, const BinASTKind kind, const ListContext& context) { + const size_t start, const ListContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release (LazyMethod)"); } template JS::Result BinASTParser::parseInterfaceLazySetter( - const size_t start, const BinASTKind kind, const ListContext& context) { + const size_t start, const ListContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release (LazySetter)"); } @@ -3482,9 +3380,7 @@ JS::Result BinASTParser::parseInterfaceLazySetter( template JS::Result BinASTParser::parseInterfaceLiteralBooleanExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::LiteralBooleanExpression); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL( @@ -3499,8 +3395,7 @@ BinASTParser::parseInterfaceLiteralBooleanExpression( template JS::Result BinASTParser::parseInterfaceLiteralInfinityExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { + const size_t start, const FieldOrListContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release " "(LiteralInfinityExpression)"); @@ -3508,9 +3403,7 @@ BinASTParser::parseInterfaceLiteralInfinityExpression( template JS::Result BinASTParser::parseInterfaceLiteralNullExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::LiteralNullExpression); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_TRY_DECL(result, handler_.newNullLiteral(tokenizer_->pos(start))); @@ -3520,9 +3413,7 @@ JS::Result BinASTParser::parseInterfaceLiteralNullExpression( template JS::Result BinASTParser::parseInterfaceLiteralNumericExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::LiteralNumericExpression); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL( @@ -3536,8 +3427,7 @@ BinASTParser::parseInterfaceLiteralNumericExpression( template JS::Result BinASTParser::parseInterfaceLiteralPropertyName( - const size_t start, const BinASTKind kind, const FieldContext& context) { - MOZ_ASSERT(kind == BinASTKind::LiteralPropertyName); + const size_t start, const FieldContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); RootedAtom value(cx_); @@ -3559,9 +3449,7 @@ JS::Result BinASTParser::parseInterfaceLiteralPropertyName( template JS::Result BinASTParser::parseInterfaceLiteralRegExpExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::LiteralRegExpExpression); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); RootedAtom pattern(cx_); @@ -3598,9 +3486,7 @@ JS::Result BinASTParser::parseInterfaceLiteralRegExpExpression( template JS::Result BinASTParser::parseInterfaceLiteralStringExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::LiteralStringExpression); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); RootedAtom value(cx_); @@ -3615,16 +3501,14 @@ JS::Result BinASTParser::parseInterfaceLiteralStringExpression( template JS::Result BinASTParser::parseInterfaceModule( - const size_t start, const BinASTKind kind, const RootContext& context) { + const size_t start, const RootContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release (Module)"); } template JS::Result BinASTParser::parseInterfaceNewExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::NewExpression); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL(callee, @@ -3643,8 +3527,7 @@ JS::Result BinASTParser::parseInterfaceNewExpression( template JS::Result BinASTParser::parseInterfaceNewTargetExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { + const size_t start, const FieldOrListContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release " "(NewTargetExpression)"); @@ -3652,7 +3535,7 @@ JS::Result BinASTParser::parseInterfaceNewTargetExpression( template JS::Result BinASTParser::parseInterfaceObjectAssignmentTarget( - const size_t start, const BinASTKind kind, const FieldContext& context) { + const size_t start, const FieldContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release " "(ObjectAssignmentTarget)"); @@ -3660,17 +3543,14 @@ JS::Result BinASTParser::parseInterfaceObjectAssignmentTarget( template JS::Result BinASTParser::parseInterfaceObjectBinding( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { + const size_t start, const FieldOrListContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release (ObjectBinding)"); } template JS::Result BinASTParser::parseInterfaceObjectExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::ObjectExpression); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL( @@ -3683,13 +3563,11 @@ JS::Result BinASTParser::parseInterfaceObjectExpression( template JS::Result BinASTParser::parseInterfaceReturnStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::ReturnStatement); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); if (!pc_->isFunctionBox()) { // Return statements are permitted only inside functions. - return raiseInvalidKind("Toplevel Statement", kind); + return raiseInvalidKind("Toplevel Statement", BinASTKind::ReturnStatement); } pc_->functionBox()->usesReturn = true; @@ -3705,8 +3583,7 @@ JS::Result BinASTParser::parseInterfaceReturnStatement( template JS::Result BinASTParser::parseInterfaceScript( - const size_t start, const BinASTKind kind, const RootContext& context) { - MOZ_ASSERT(kind == BinASTKind::Script); + const size_t start, const RootContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); MOZ_TRY(parseAssertedScriptGlobalScope( @@ -3746,8 +3623,8 @@ JS::Result BinASTParser::parseSetterContents( MOZ_TRY(tokenizer_->enterInterface(kind, context)); const auto start = tokenizer_->offset(); BINJS_MOZ_TRY_DECL( - result, parseInterfaceSetterContents(start, kind, funLength, paramsOut, - bodyOut, context)); + result, parseInterfaceSetterContents(start, funLength, paramsOut, bodyOut, + context)); MOZ_TRY(guard.done()); return result; @@ -3755,9 +3632,8 @@ JS::Result BinASTParser::parseSetterContents( template JS::Result BinASTParser::parseInterfaceSetterContents( - const size_t start, const BinASTKind kind, uint32_t funLength, - ListNode** paramsOut, ListNode** bodyOut, const FieldContext& context) { - MOZ_ASSERT(kind == BinASTKind::SetterContents); + const size_t start, uint32_t funLength, ListNode** paramsOut, + ListNode** bodyOut, const FieldContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL( @@ -3791,8 +3667,7 @@ JS::Result BinASTParser::parseInterfaceSetterContents( template JS::Result BinASTParser::parseInterfaceShorthandProperty( - const size_t start, const BinASTKind kind, const ListContext& context) { - MOZ_ASSERT(kind == BinASTKind::ShorthandProperty); + const size_t start, const ListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL(name, @@ -3812,7 +3687,7 @@ JS::Result BinASTParser::parseInterfaceShorthandProperty( template JS::Result BinASTParser::parseInterfaceSpreadElement( - const size_t start, const BinASTKind kind, const ListContext& context) { + const size_t start, const ListContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release (SpreadElement)"); } @@ -3820,8 +3695,7 @@ JS::Result BinASTParser::parseInterfaceSpreadElement( template JS::Result BinASTParser::parseInterfaceStaticMemberAssignmentTarget( - const size_t start, const BinASTKind kind, const FieldContext& context) { - MOZ_ASSERT(kind == BinASTKind::StaticMemberAssignmentTarget); + const size_t start, const FieldContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); size_t nameStart; @@ -3847,9 +3721,7 @@ BinASTParser::parseInterfaceStaticMemberAssignmentTarget( template JS::Result BinASTParser::parseInterfaceStaticMemberExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::StaticMemberExpression); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); size_t nameStart; @@ -3874,7 +3746,7 @@ JS::Result BinASTParser::parseInterfaceStaticMemberExpression( template JS::Result BinASTParser::parseInterfaceSuper( - const size_t start, const BinASTKind kind, const FieldContext& context) { + const size_t start, const FieldContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release (Super)"); } @@ -3894,7 +3766,7 @@ JS::Result BinASTParser::parseSwitchCase( guard.init(); MOZ_TRY(tokenizer_->enterInterface(kind, context)); const auto start = tokenizer_->offset(); - BINJS_MOZ_TRY_DECL(result, parseInterfaceSwitchCase(start, kind, context)); + BINJS_MOZ_TRY_DECL(result, parseInterfaceSwitchCase(start, context)); MOZ_TRY(guard.done()); return result; @@ -3902,8 +3774,7 @@ JS::Result BinASTParser::parseSwitchCase( template JS::Result BinASTParser::parseInterfaceSwitchCase( - const size_t start, const BinASTKind kind, const ListContext& context) { - MOZ_ASSERT(kind == BinASTKind::SwitchCase); + const size_t start, const ListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL( @@ -3932,7 +3803,7 @@ JS::Result BinASTParser::parseSwitchDefault( guard.init(); MOZ_TRY(tokenizer_->enterInterface(kind, context)); const auto start = tokenizer_->offset(); - BINJS_MOZ_TRY_DECL(result, parseInterfaceSwitchDefault(start, kind, context)); + BINJS_MOZ_TRY_DECL(result, parseInterfaceSwitchDefault(start, context)); MOZ_TRY(guard.done()); return result; @@ -3940,8 +3811,7 @@ JS::Result BinASTParser::parseSwitchDefault( template JS::Result BinASTParser::parseInterfaceSwitchDefault( - const size_t start, const BinASTKind kind, const FieldContext& context) { - MOZ_ASSERT(kind == BinASTKind::SwitchDefault); + const size_t start, const FieldContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL(consequent, @@ -3954,9 +3824,7 @@ JS::Result BinASTParser::parseInterfaceSwitchDefault( template JS::Result BinASTParser::parseInterfaceSwitchStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::SwitchStatement); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL( @@ -3977,9 +3845,7 @@ JS::Result BinASTParser::parseInterfaceSwitchStatement( template JS::Result BinASTParser::parseInterfaceSwitchStatementWithDefault( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::SwitchStatementWithDefault); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL( @@ -4019,8 +3885,7 @@ BinASTParser::parseInterfaceSwitchStatementWithDefault( template JS::Result BinASTParser::parseInterfaceTemplateExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { + const size_t start, const FieldOrListContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release " "(TemplateExpression)"); @@ -4028,9 +3893,7 @@ JS::Result BinASTParser::parseInterfaceTemplateExpression( template JS::Result BinASTParser::parseInterfaceThisExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::ThisExpression); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); if (pc_->isFunctionBox()) { @@ -4052,9 +3915,7 @@ JS::Result BinASTParser::parseInterfaceThisExpression( template JS::Result BinASTParser::parseInterfaceThrowStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::ThrowStatement); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL(expression, @@ -4068,9 +3929,7 @@ JS::Result BinASTParser::parseInterfaceThrowStatement( template JS::Result BinASTParser::parseInterfaceTryCatchStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::TryCatchStatement); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); ParseNode* body; @@ -4095,9 +3954,7 @@ JS::Result BinASTParser::parseInterfaceTryCatchStatement( template JS::Result BinASTParser::parseInterfaceTryFinallyStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::TryFinallyStatement); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); ParseNode* body; @@ -4132,9 +3989,7 @@ JS::Result BinASTParser::parseInterfaceTryFinallyStatement( template JS::Result BinASTParser::parseInterfaceUnaryExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::UnaryExpression); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL(operator_, @@ -4195,9 +4050,7 @@ JS::Result BinASTParser::parseInterfaceUnaryExpression( template JS::Result BinASTParser::parseInterfaceUpdateExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::UpdateExpression); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL(isPrefix, @@ -4229,9 +4082,7 @@ JS::Result BinASTParser::parseInterfaceUpdateExpression( template JS::Result BinASTParser::parseInterfaceVariableDeclaration( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::VariableDeclaration); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); AutoVariableDeclarationKind kindGuard(this); @@ -4281,8 +4132,7 @@ JS::Result BinASTParser::parseVariableDeclarator( guard.init(); MOZ_TRY(tokenizer_->enterInterface(kind, context)); const auto start = tokenizer_->offset(); - BINJS_MOZ_TRY_DECL(result, - parseInterfaceVariableDeclarator(start, kind, context)); + BINJS_MOZ_TRY_DECL(result, parseInterfaceVariableDeclarator(start, context)); MOZ_TRY(guard.done()); return result; @@ -4290,8 +4140,7 @@ JS::Result BinASTParser::parseVariableDeclarator( template JS::Result BinASTParser::parseInterfaceVariableDeclarator( - const size_t start, const BinASTKind kind, const ListContext& context) { - MOZ_ASSERT(kind == BinASTKind::VariableDeclarator); + const size_t start, const ListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL( @@ -4332,9 +4181,7 @@ JS::Result BinASTParser::parseInterfaceVariableDeclarator( template JS::Result BinASTParser::parseInterfaceWhileStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::WhileStatement); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); ParseContext::Statement stmt(pc_, StatementKind::WhileLoop); @@ -4351,9 +4198,7 @@ JS::Result BinASTParser::parseInterfaceWhileStatement( template JS::Result BinASTParser::parseInterfaceWithStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { - MOZ_ASSERT(kind == BinASTKind::WithStatement); + const size_t start, const FieldOrListContext& context) { BINJS_TRY(CheckRecursionLimit(cx_)); BINJS_MOZ_TRY_DECL(object, @@ -4371,16 +4216,14 @@ JS::Result BinASTParser::parseInterfaceWithStatement( template JS::Result BinASTParser::parseInterfaceYieldExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { + const size_t start, const FieldOrListContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release (YieldExpression)"); } template JS::Result BinASTParser::parseInterfaceYieldStarExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context) { + const size_t start, const FieldOrListContext& context) { return raiseError( "FIXME: Not implemented yet in this preview release " "(YieldStarExpression)"); @@ -4960,7 +4803,7 @@ JS::Result BinASTParser::parseOptionalBindingIdentifier( } else if (kind == BinASTKind::BindingIdentifier) { const auto start = tokenizer_->offset(); MOZ_TRY_VAR(result, parseInterfaceBindingIdentifier( - start, kind, FieldOrListContext(context))); + start, FieldOrListContext(context))); } else { return raiseInvalidKind("BindingIdentifier", kind); } @@ -4982,7 +4825,7 @@ JS::Result BinASTParser::parseOptionalCatchClause( result = nullptr; } else if (kind == BinASTKind::CatchClause) { const auto start = tokenizer_->offset(); - MOZ_TRY_VAR(result, parseInterfaceCatchClause(start, kind, context)); + MOZ_TRY_VAR(result, parseInterfaceCatchClause(start, context)); } else { return raiseInvalidKind("CatchClause", kind); } diff --git a/js/src/frontend/BinASTParser.h b/js/src/frontend/BinASTParser.h index 6d028862de18..f0702d494d7f 100644 --- a/js/src/frontend/BinASTParser.h +++ b/js/src/frontend/BinASTParser.h @@ -224,289 +224,214 @@ class BinASTParser : public BinASTParserPerTokenizer { JS::Result parseSwitchDefault(const FieldContext& context); JS::Result parseVariableDeclarator(const ListContext& context); JS::Result parseInterfaceArrayAssignmentTarget( - const size_t start, const BinASTKind kind, const FieldContext& context); + const size_t start, const FieldContext& context); JS::Result parseInterfaceArrayBinding( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceArrayExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceAssertedBlockScope(const size_t start, - const BinASTKind kind, const FieldContext& context); JS::Result parseInterfaceAssertedBoundName(const size_t start, - const BinASTKind kind, AssertedScopeKind scopeKind, const ListContext& context); JS::Result parseInterfaceAssertedBoundNamesScope( - const size_t start, const BinASTKind kind, const FieldContext& context); + const size_t start, const FieldContext& context); JS::Result parseInterfaceAssertedDeclaredName(const size_t start, - const BinASTKind kind, AssertedScopeKind scopeKind, const ListContext& context); JS::Result parseInterfaceAssertedParameterScope( - const size_t start, const BinASTKind kind, - MutableHandle> positionalParams, + const size_t start, MutableHandle> positionalParams, const FieldContext& context); JS::Result parseInterfaceAssertedPositionalParameterName( - const size_t start, const BinASTKind kind, AssertedScopeKind scopeKind, + const size_t start, AssertedScopeKind scopeKind, MutableHandle> positionalParams, const ListContext& context); JS::Result parseInterfaceAssertedScriptGlobalScope( - const size_t start, const BinASTKind kind, const FieldContext& context); + const size_t start, const FieldContext& context); JS::Result parseInterfaceAssertedVarScope(const size_t start, - const BinASTKind kind, const FieldContext& context); JS::Result parseInterfaceAssignmentExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceAssignmentTargetIdentifier( - const size_t start, const BinASTKind kind, const FieldContext& context); + const size_t start, const FieldContext& context); JS::Result parseInterfaceAwaitExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceBinaryExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceBindingIdentifier( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceBindingWithInitializer( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceBlock(const size_t start, - const BinASTKind kind, const FieldOrListContext& context); JS::Result parseInterfaceBreakStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceCallExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceCatchClause( - const size_t start, const BinASTKind kind, const FieldContext& context); + const size_t start, const FieldContext& context); JS::Result parseInterfaceClassDeclaration( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceClassExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceCompoundAssignmentExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceComputedMemberAssignmentTarget( - const size_t start, const BinASTKind kind, const FieldContext& context); + const size_t start, const FieldContext& context); JS::Result parseInterfaceComputedMemberExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceComputedPropertyName( - const size_t start, const BinASTKind kind, const FieldContext& context); + const size_t start, const FieldContext& context); JS::Result parseInterfaceConditionalExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceContinueStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceDataProperty(const size_t start, - const BinASTKind kind, const ListContext& context); JS::Result parseInterfaceDebuggerStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceDirective(const size_t start, - const BinASTKind kind, const ListContext& context); JS::Result parseInterfaceDoWhileStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceEagerArrowExpressionWithExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceEagerArrowExpressionWithFunctionBody( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceEagerFunctionDeclaration( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceEagerFunctionExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceEagerGetter(const size_t start, - const BinASTKind kind, const ListContext& context); JS::Result parseInterfaceEagerMethod(const size_t start, - const BinASTKind kind, const ListContext& context); JS::Result parseInterfaceEagerSetter(const size_t start, - const BinASTKind kind, const ListContext& context); JS::Result parseInterfaceEmptyStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceExpressionStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceForInOfBinding( - const size_t start, const BinASTKind kind, const FieldContext& context); + const size_t start, const FieldContext& context); JS::Result parseInterfaceForInStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceForOfStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceForStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceFormalParameters( - const size_t start, const BinASTKind kind, const FieldContext& context); + const size_t start, const FieldContext& context); JS::Result parseInterfaceFunctionExpressionContents( - const size_t start, const BinASTKind kind, uint32_t funLength, - ListNode** paramsOut, ListNode** bodyOut, - const FieldOrRootContext& context); + const size_t start, uint32_t funLength, ListNode** paramsOut, + ListNode** bodyOut, const FieldOrRootContext& context); JS::Result parseInterfaceFunctionOrMethodContents( - const size_t start, const BinASTKind kind, uint32_t funLength, - ListNode** paramsOut, ListNode** bodyOut, - const FieldOrRootContext& context); - JS::Result parseInterfaceGetterContents( - const size_t start, const BinASTKind kind, uint32_t funLength, - ListNode** paramsOut, ListNode** bodyOut, const FieldContext& context); + const size_t start, uint32_t funLength, ListNode** paramsOut, + ListNode** bodyOut, const FieldOrRootContext& context); + JS::Result parseInterfaceGetterContents(const size_t start, + uint32_t funLength, + ListNode** paramsOut, + ListNode** bodyOut, + const FieldContext& context); JS::Result parseInterfaceIdentifierExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceIfStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceLabelledStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceLazyArrowExpressionWithExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceLazyArrowExpressionWithFunctionBody( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceLazyFunctionDeclaration( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceLazyFunctionExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceLazyGetter(const size_t start, - const BinASTKind kind, const ListContext& context); JS::Result parseInterfaceLazyMethod(const size_t start, - const BinASTKind kind, const ListContext& context); JS::Result parseInterfaceLazySetter(const size_t start, - const BinASTKind kind, const ListContext& context); JS::Result parseInterfaceLiteralBooleanExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceLiteralInfinityExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceLiteralNullExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceLiteralNumericExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceLiteralPropertyName( - const size_t start, const BinASTKind kind, const FieldContext& context); + const size_t start, const FieldContext& context); JS::Result parseInterfaceLiteralRegExpExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceLiteralStringExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceModule(const size_t start, - const BinASTKind kind, const RootContext& context); JS::Result parseInterfaceNewExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceNewTargetExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceObjectAssignmentTarget( - const size_t start, const BinASTKind kind, const FieldContext& context); + const size_t start, const FieldContext& context); JS::Result parseInterfaceObjectBinding( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceObjectExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceReturnStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceScript(const size_t start, - const BinASTKind kind, const RootContext& context); - JS::Result parseInterfaceSetterContents( - const size_t start, const BinASTKind kind, uint32_t funLength, - ListNode** paramsOut, ListNode** bodyOut, const FieldContext& context); + JS::Result parseInterfaceSetterContents(const size_t start, + uint32_t funLength, + ListNode** paramsOut, + ListNode** bodyOut, + const FieldContext& context); JS::Result parseInterfaceShorthandProperty( - const size_t start, const BinASTKind kind, const ListContext& context); + const size_t start, const ListContext& context); JS::Result parseInterfaceSpreadElement( - const size_t start, const BinASTKind kind, const ListContext& context); + const size_t start, const ListContext& context); JS::Result parseInterfaceStaticMemberAssignmentTarget( - const size_t start, const BinASTKind kind, const FieldContext& context); + const size_t start, const FieldContext& context); JS::Result parseInterfaceStaticMemberExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceSuper(const size_t start, - const BinASTKind kind, const FieldContext& context); JS::Result parseInterfaceSwitchCase(const size_t start, - const BinASTKind kind, const ListContext& context); JS::Result parseInterfaceSwitchDefault( - const size_t start, const BinASTKind kind, const FieldContext& context); + const size_t start, const FieldContext& context); JS::Result parseInterfaceSwitchStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceSwitchStatementWithDefault( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceTemplateExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceThisExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceThrowStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceTryCatchStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceTryFinallyStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceUnaryExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceUpdateExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceVariableDeclaration( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceVariableDeclarator( - const size_t start, const BinASTKind kind, const ListContext& context); + const size_t start, const ListContext& context); JS::Result parseInterfaceWhileStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceWithStatement( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceYieldExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); JS::Result parseInterfaceYieldStarExpression( - const size_t start, const BinASTKind kind, - const FieldOrListContext& context); + const size_t start, const FieldOrListContext& context); // ----- String enums (by lexicographical order) JS::Result::AssertedDeclaredKind> diff --git a/js/src/frontend/BinASTParserPerTokenizer.cpp b/js/src/frontend/BinASTParserPerTokenizer.cpp index 69fb5ea58b80..62af242a77bc 100644 --- a/js/src/frontend/BinASTParserPerTokenizer.cpp +++ b/js/src/frontend/BinASTParserPerTokenizer.cpp @@ -207,11 +207,8 @@ JS::Result BinASTParserPerTokenizer::parseLazyFunction( NewLexicalScopeData(cx_, lexicalScope, alloc_, pc_)); BINJS_TRY_DECL(body, handler_.newLexicalScope(*lexicalScopeData, tmpBody)); - auto binASTKind = isExpr ? BinASTKind::LazyFunctionExpression - : BinASTKind::LazyFunctionDeclaration; - BINJS_MOZ_TRY_DECL(result, - makeEmptyFunctionNode(firstOffset, binASTKind, funbox)); + makeEmptyFunctionNode(firstOffset, syntaxKind, funbox)); MOZ_TRY(setFunctionParametersAndBody(result, params, body)); MOZ_TRY(finishEagerFunction(funbox, nargs)); return result; @@ -295,41 +292,12 @@ JS::Result BinASTParserPerTokenizer::buildFunctionBox( return funbox; } -FunctionSyntaxKind BinASTKindToFunctionSyntaxKind(const BinASTKind kind) { - // FIXME: this doesn't cover FunctionSyntaxKind::ClassConstructor and - // FunctionSyntaxKind::DerivedClassConstructor. - switch (kind) { - case BinASTKind::EagerFunctionDeclaration: - case BinASTKind::LazyFunctionDeclaration: - return FunctionSyntaxKind::Statement; - case BinASTKind::EagerFunctionExpression: - case BinASTKind::LazyFunctionExpression: - return FunctionSyntaxKind::Expression; - case BinASTKind::EagerArrowExpressionWithFunctionBody: - case BinASTKind::LazyArrowExpressionWithFunctionBody: - case BinASTKind::EagerArrowExpressionWithExpression: - case BinASTKind::LazyArrowExpressionWithExpression: - return FunctionSyntaxKind::Arrow; - case BinASTKind::EagerMethod: - case BinASTKind::LazyMethod: - return FunctionSyntaxKind::Method; - case BinASTKind::EagerGetter: - case BinASTKind::LazyGetter: - return FunctionSyntaxKind::Getter; - case BinASTKind::EagerSetter: - case BinASTKind::LazySetter: - return FunctionSyntaxKind::Setter; - default: - MOZ_CRASH("Invalid/ kind"); - } -} - template JS::Result BinASTParserPerTokenizer::makeEmptyFunctionNode( - const size_t start, const BinASTKind kind, FunctionBox* funbox) { + const size_t start, const FunctionSyntaxKind syntaxKind, + FunctionBox* funbox) { // LazyScript compilation requires basically none of the fields filled out. TokenPos pos = tokenizer_->pos(start); - FunctionSyntaxKind syntaxKind = BinASTKindToFunctionSyntaxKind(kind); BINJS_TRY_DECL(result, handler_.newFunction(syntaxKind, pos)); diff --git a/js/src/frontend/BinASTParserPerTokenizer.h b/js/src/frontend/BinASTParserPerTokenizer.h index 1eaacd3b9dce..900dee003b35 100644 --- a/js/src/frontend/BinASTParserPerTokenizer.h +++ b/js/src/frontend/BinASTParserPerTokenizer.h @@ -141,9 +141,9 @@ class BinASTParserPerTokenizer : public BinASTParserBase, FunctionSyntaxKind syntax, ParseNode* name); - JS::Result makeEmptyFunctionNode(const size_t start, - const BinASTKind kind, - FunctionBox* funbox); + JS::Result makeEmptyFunctionNode( + const size_t start, const FunctionSyntaxKind syntaxKind, + FunctionBox* funbox); MOZ_MUST_USE JS::Result setFunctionParametersAndBody(FunctionNode* fun, ListNode* params, ParseNode* body); diff --git a/js/src/frontend/binast/src/main.rs b/js/src/frontend/binast/src/main.rs index 784383ea0d51..b7abdcc4ecdc 100644 --- a/js/src/frontend/binast/src/main.rs +++ b/js/src/frontend/binast/src/main.rs @@ -548,10 +548,18 @@ enum MethodCallKind { /// Fixed parameter of interface method. const INTERFACE_PARAMS: &str = - "const size_t start, const BinASTKind kind"; + "const size_t start"; /// Fixed arguments of interface method. const INTERFACE_ARGS: &str = + "start"; + +/// Fixed parameter of sum interface method. +const SUM_INTERFACE_PARAMS: &str = + "const size_t start, const BinASTKind kind"; + +/// Fixed arguments of sum interface method. +const SUM_INTERFACE_ARGS: &str = "start, kind"; /// The name of the toplevel interface for the script. @@ -1916,7 +1924,7 @@ enum class {name} {{ let rules_for_this_sum = self.rules.get(name); let extra_params = rules_for_this_sum.extra_params; let rendered = self.get_method_signature(name, prefix, - INTERFACE_PARAMS, + SUM_INTERFACE_PARAMS, &extra_params); buffer.push_str(&rendered.reindent(" ") .newline_if_not_empty()); @@ -2114,7 +2122,7 @@ impl CPPExporter { ", bnf = rendered_bnf, call = self.get_method_call("result", name, - "Sum", INTERFACE_ARGS, + "Sum", SUM_INTERFACE_ARGS, &extra_args, "context".to_string(), MethodCallKind::AlwaysDecl) @@ -2175,7 +2183,7 @@ impl CPPExporter { kind = kind, cases = buffer_cases, first_line = self.get_method_definition_start(name, inner_prefix, - INTERFACE_PARAMS, + SUM_INTERFACE_PARAMS, &extra_params), type_ok = self.get_type_ok(name) )); @@ -2410,7 +2418,7 @@ impl CPPExporter { first_line = self.get_method_definition_start(&parser.name, "", "", &extra_params), call = self.get_method_call("result", &parser.elements, - "Sum", INTERFACE_ARGS, + "Sum", SUM_INTERFACE_ARGS, &extra_args, self.get_context_param_for_optional( &parser.name, @@ -2775,7 +2783,6 @@ impl CPPExporter { } else { buffer.push_str(&format!("{first_line} {{ - MOZ_ASSERT(kind == BinASTKind::{kind}); BINJS_TRY(CheckRecursionLimit(cx_)); {pre}{fields_implem} {post} return result; @@ -2785,7 +2792,6 @@ impl CPPExporter { fields_implem = fields_implem, pre = init.newline_if_not_empty(), post = build_result.newline_if_not_empty(), - kind = name.to_cpp_enum_case(), first_line = first_line, )); }