diff --git a/js/src/frontend/BinSource-auto.cpp b/js/src/frontend/BinSource-auto.cpp index fafeb68a5437..37d16051d13f 100644 --- a/js/src/frontend/BinSource-auto.cpp +++ b/js/src/frontend/BinSource-auto.cpp @@ -68,11 +68,9 @@ BinASTParser::parseSumArrowExpression(const size_t start, const BinKind kin switch(kind) { case BinKind::EagerArrowExpression: MOZ_TRY_VAR(result, parseInterfaceEagerArrowExpression(start, kind, fields)); - break; case BinKind::SkippableArrowExpression: MOZ_TRY_VAR(result, parseInterfaceSkippableArrowExpression(start, kind, fields)); - break; default: return raiseInvalidKind("ArrowExpression", kind); @@ -110,23 +108,18 @@ BinASTParser::parseSumAssignmentTarget(const size_t start, const BinKind ki switch(kind) { case BinKind::ArrayAssignmentTarget: MOZ_TRY_VAR(result, parseInterfaceArrayAssignmentTarget(start, kind, fields)); - break; case BinKind::AssignmentTargetIdentifier: MOZ_TRY_VAR(result, parseInterfaceAssignmentTargetIdentifier(start, kind, fields)); - break; case BinKind::ComputedMemberAssignmentTarget: MOZ_TRY_VAR(result, parseInterfaceComputedMemberAssignmentTarget(start, kind, fields)); - break; case BinKind::ObjectAssignmentTarget: MOZ_TRY_VAR(result, parseInterfaceObjectAssignmentTarget(start, kind, fields)); - break; case BinKind::StaticMemberAssignmentTarget: MOZ_TRY_VAR(result, parseInterfaceStaticMemberAssignmentTarget(start, kind, fields)); - break; default: return raiseInvalidKind("AssignmentTarget", kind); @@ -165,27 +158,21 @@ BinASTParser::parseSumAssignmentTargetOrAssignmentTargetWithInitializer(con switch(kind) { case BinKind::ArrayAssignmentTarget: MOZ_TRY_VAR(result, parseInterfaceArrayAssignmentTarget(start, kind, fields)); - break; case BinKind::AssignmentTargetIdentifier: MOZ_TRY_VAR(result, parseInterfaceAssignmentTargetIdentifier(start, kind, fields)); - break; case BinKind::AssignmentTargetWithInitializer: MOZ_TRY_VAR(result, parseInterfaceAssignmentTargetWithInitializer(start, kind, fields)); - break; case BinKind::ComputedMemberAssignmentTarget: MOZ_TRY_VAR(result, parseInterfaceComputedMemberAssignmentTarget(start, kind, fields)); - break; case BinKind::ObjectAssignmentTarget: MOZ_TRY_VAR(result, parseInterfaceObjectAssignmentTarget(start, kind, fields)); - break; case BinKind::StaticMemberAssignmentTarget: MOZ_TRY_VAR(result, parseInterfaceStaticMemberAssignmentTarget(start, kind, fields)); - break; default: return raiseInvalidKind("AssignmentTargetOrAssignmentTargetWithInitializer", kind); @@ -220,11 +207,9 @@ BinASTParser::parseSumAssignmentTargetPattern(const size_t start, const Bin switch(kind) { case BinKind::ArrayAssignmentTarget: MOZ_TRY_VAR(result, parseInterfaceArrayAssignmentTarget(start, kind, fields)); - break; case BinKind::ObjectAssignmentTarget: MOZ_TRY_VAR(result, parseInterfaceObjectAssignmentTarget(start, kind, fields)); - break; default: return raiseInvalidKind("AssignmentTargetPattern", kind); @@ -259,11 +244,9 @@ BinASTParser::parseSumAssignmentTargetProperty(const size_t start, const Bi switch(kind) { case BinKind::AssignmentTargetPropertyIdentifier: MOZ_TRY_VAR(result, parseInterfaceAssignmentTargetPropertyIdentifier(start, kind, fields)); - break; case BinKind::AssignmentTargetPropertyProperty: MOZ_TRY_VAR(result, parseInterfaceAssignmentTargetPropertyProperty(start, kind, fields)); - break; default: return raiseInvalidKind("AssignmentTargetProperty", kind); @@ -299,15 +282,12 @@ BinASTParser::parseSumBinding(const size_t start, const BinKind kind, const switch(kind) { case BinKind::ArrayBinding: MOZ_TRY_VAR(result, parseInterfaceArrayBinding(start, kind, fields)); - break; case BinKind::BindingIdentifier: MOZ_TRY_VAR(result, parseInterfaceBindingIdentifier(start, kind, fields)); - break; case BinKind::ObjectBinding: MOZ_TRY_VAR(result, parseInterfaceObjectBinding(start, kind, fields)); - break; default: return raiseInvalidKind("Binding", kind); @@ -344,19 +324,15 @@ BinASTParser::parseSumBindingOrBindingWithInitializer(const size_t start, c switch(kind) { case BinKind::ArrayBinding: MOZ_TRY_VAR(result, parseInterfaceArrayBinding(start, kind, fields)); - break; case BinKind::BindingIdentifier: MOZ_TRY_VAR(result, parseInterfaceBindingIdentifier(start, kind, fields)); - break; case BinKind::BindingWithInitializer: MOZ_TRY_VAR(result, parseInterfaceBindingWithInitializer(start, kind, fields)); - break; case BinKind::ObjectBinding: MOZ_TRY_VAR(result, parseInterfaceObjectBinding(start, kind, fields)); - break; default: return raiseInvalidKind("BindingOrBindingWithInitializer", kind); @@ -391,11 +367,9 @@ BinASTParser::parseSumBindingPattern(const size_t start, const BinKind kind switch(kind) { case BinKind::ArrayBinding: MOZ_TRY_VAR(result, parseInterfaceArrayBinding(start, kind, fields)); - break; case BinKind::ObjectBinding: MOZ_TRY_VAR(result, parseInterfaceObjectBinding(start, kind, fields)); - break; default: return raiseInvalidKind("BindingPattern", kind); @@ -430,11 +404,9 @@ BinASTParser::parseSumBindingProperty(const size_t start, const BinKind kin switch(kind) { case BinKind::BindingPropertyIdentifier: MOZ_TRY_VAR(result, parseInterfaceBindingPropertyIdentifier(start, kind, fields)); - break; case BinKind::BindingPropertyProperty: MOZ_TRY_VAR(result, parseInterfaceBindingPropertyProperty(start, kind, fields)); - break; default: return raiseInvalidKind("BindingProperty", kind); @@ -472,23 +444,18 @@ BinASTParser::parseSumExportDeclaration(const size_t start, const BinKind k switch(kind) { case BinKind::Export: MOZ_TRY_VAR(result, parseInterfaceExport(start, kind, fields)); - break; case BinKind::ExportAllFrom: MOZ_TRY_VAR(result, parseInterfaceExportAllFrom(start, kind, fields)); - break; case BinKind::ExportDefault: MOZ_TRY_VAR(result, parseInterfaceExportDefault(start, kind, fields)); - break; case BinKind::ExportFrom: MOZ_TRY_VAR(result, parseInterfaceExportFrom(start, kind, fields)); - break; case BinKind::ExportLocals: MOZ_TRY_VAR(result, parseInterfaceExportLocals(start, kind, fields)); - break; default: return raiseInvalidKind("ExportDeclaration", kind); @@ -551,123 +518,93 @@ BinASTParser::parseSumExpression(const size_t start, const BinKind kind, co switch(kind) { case BinKind::ArrayExpression: MOZ_TRY_VAR(result, parseInterfaceArrayExpression(start, kind, fields)); - break; case BinKind::AssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceAssignmentExpression(start, kind, fields)); - break; case BinKind::AwaitExpression: MOZ_TRY_VAR(result, parseInterfaceAwaitExpression(start, kind, fields)); - break; case BinKind::BinaryExpression: MOZ_TRY_VAR(result, parseInterfaceBinaryExpression(start, kind, fields)); - break; case BinKind::CallExpression: MOZ_TRY_VAR(result, parseInterfaceCallExpression(start, kind, fields)); - break; case BinKind::ClassExpression: MOZ_TRY_VAR(result, parseInterfaceClassExpression(start, kind, fields)); - break; case BinKind::CompoundAssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceCompoundAssignmentExpression(start, kind, fields)); - break; case BinKind::ComputedMemberExpression: MOZ_TRY_VAR(result, parseInterfaceComputedMemberExpression(start, kind, fields)); - break; case BinKind::ConditionalExpression: MOZ_TRY_VAR(result, parseInterfaceConditionalExpression(start, kind, fields)); - break; case BinKind::EagerArrowExpression: MOZ_TRY_VAR(result, parseInterfaceEagerArrowExpression(start, kind, fields)); - break; case BinKind::EagerFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceEagerFunctionExpression(start, kind, fields)); - break; case BinKind::IdentifierExpression: MOZ_TRY_VAR(result, parseInterfaceIdentifierExpression(start, kind, fields)); - break; case BinKind::LiteralBooleanExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralBooleanExpression(start, kind, fields)); - break; case BinKind::LiteralInfinityExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralInfinityExpression(start, kind, fields)); - break; case BinKind::LiteralNullExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNullExpression(start, kind, fields)); - break; case BinKind::LiteralNumericExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNumericExpression(start, kind, fields)); - break; case BinKind::LiteralRegExpExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralRegExpExpression(start, kind, fields)); - break; case BinKind::LiteralStringExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralStringExpression(start, kind, fields)); - break; case BinKind::NewExpression: MOZ_TRY_VAR(result, parseInterfaceNewExpression(start, kind, fields)); - break; case BinKind::NewTargetExpression: MOZ_TRY_VAR(result, parseInterfaceNewTargetExpression(start, kind, fields)); - break; case BinKind::ObjectExpression: MOZ_TRY_VAR(result, parseInterfaceObjectExpression(start, kind, fields)); - break; case BinKind::SkippableArrowExpression: MOZ_TRY_VAR(result, parseInterfaceSkippableArrowExpression(start, kind, fields)); - break; case BinKind::SkippableFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceSkippableFunctionExpression(start, kind, fields)); - break; case BinKind::StaticMemberExpression: MOZ_TRY_VAR(result, parseInterfaceStaticMemberExpression(start, kind, fields)); - break; case BinKind::TemplateExpression: MOZ_TRY_VAR(result, parseInterfaceTemplateExpression(start, kind, fields)); - break; case BinKind::ThisExpression: MOZ_TRY_VAR(result, parseInterfaceThisExpression(start, kind, fields)); - break; case BinKind::UnaryExpression: MOZ_TRY_VAR(result, parseInterfaceUnaryExpression(start, kind, fields)); - break; case BinKind::UpdateExpression: MOZ_TRY_VAR(result, parseInterfaceUpdateExpression(start, kind, fields)); - break; case BinKind::YieldExpression: MOZ_TRY_VAR(result, parseInterfaceYieldExpression(start, kind, fields)); - break; case BinKind::YieldStarExpression: MOZ_TRY_VAR(result, parseInterfaceYieldStarExpression(start, kind, fields)); - break; default: return raiseInvalidKind("Expression", kind); @@ -731,127 +668,96 @@ BinASTParser::parseSumExpressionOrSuper(const size_t start, const BinKind k switch(kind) { case BinKind::ArrayExpression: MOZ_TRY_VAR(result, parseInterfaceArrayExpression(start, kind, fields)); - break; case BinKind::AssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceAssignmentExpression(start, kind, fields)); - break; case BinKind::AwaitExpression: MOZ_TRY_VAR(result, parseInterfaceAwaitExpression(start, kind, fields)); - break; case BinKind::BinaryExpression: MOZ_TRY_VAR(result, parseInterfaceBinaryExpression(start, kind, fields)); - break; case BinKind::CallExpression: MOZ_TRY_VAR(result, parseInterfaceCallExpression(start, kind, fields)); - break; case BinKind::ClassExpression: MOZ_TRY_VAR(result, parseInterfaceClassExpression(start, kind, fields)); - break; case BinKind::CompoundAssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceCompoundAssignmentExpression(start, kind, fields)); - break; case BinKind::ComputedMemberExpression: MOZ_TRY_VAR(result, parseInterfaceComputedMemberExpression(start, kind, fields)); - break; case BinKind::ConditionalExpression: MOZ_TRY_VAR(result, parseInterfaceConditionalExpression(start, kind, fields)); - break; case BinKind::EagerArrowExpression: MOZ_TRY_VAR(result, parseInterfaceEagerArrowExpression(start, kind, fields)); - break; case BinKind::EagerFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceEagerFunctionExpression(start, kind, fields)); - break; case BinKind::IdentifierExpression: MOZ_TRY_VAR(result, parseInterfaceIdentifierExpression(start, kind, fields)); - break; case BinKind::LiteralBooleanExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralBooleanExpression(start, kind, fields)); - break; case BinKind::LiteralInfinityExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralInfinityExpression(start, kind, fields)); - break; case BinKind::LiteralNullExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNullExpression(start, kind, fields)); - break; case BinKind::LiteralNumericExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNumericExpression(start, kind, fields)); - break; case BinKind::LiteralRegExpExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralRegExpExpression(start, kind, fields)); - break; case BinKind::LiteralStringExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralStringExpression(start, kind, fields)); - break; case BinKind::NewExpression: MOZ_TRY_VAR(result, parseInterfaceNewExpression(start, kind, fields)); - break; case BinKind::NewTargetExpression: MOZ_TRY_VAR(result, parseInterfaceNewTargetExpression(start, kind, fields)); - break; case BinKind::ObjectExpression: MOZ_TRY_VAR(result, parseInterfaceObjectExpression(start, kind, fields)); - break; case BinKind::SkippableArrowExpression: MOZ_TRY_VAR(result, parseInterfaceSkippableArrowExpression(start, kind, fields)); - break; case BinKind::SkippableFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceSkippableFunctionExpression(start, kind, fields)); - break; case BinKind::StaticMemberExpression: MOZ_TRY_VAR(result, parseInterfaceStaticMemberExpression(start, kind, fields)); - break; case BinKind::Super: MOZ_TRY_VAR(result, parseInterfaceSuper(start, kind, fields)); - break; case BinKind::TemplateExpression: MOZ_TRY_VAR(result, parseInterfaceTemplateExpression(start, kind, fields)); - break; case BinKind::ThisExpression: MOZ_TRY_VAR(result, parseInterfaceThisExpression(start, kind, fields)); - break; case BinKind::UnaryExpression: MOZ_TRY_VAR(result, parseInterfaceUnaryExpression(start, kind, fields)); - break; case BinKind::UpdateExpression: MOZ_TRY_VAR(result, parseInterfaceUpdateExpression(start, kind, fields)); - break; case BinKind::YieldExpression: MOZ_TRY_VAR(result, parseInterfaceYieldExpression(start, kind, fields)); - break; case BinKind::YieldStarExpression: MOZ_TRY_VAR(result, parseInterfaceYieldStarExpression(start, kind, fields)); - break; default: return raiseInvalidKind("ExpressionOrSuper", kind); @@ -915,127 +821,96 @@ BinASTParser::parseSumExpressionOrTemplateElement(const size_t start, const switch(kind) { case BinKind::ArrayExpression: MOZ_TRY_VAR(result, parseInterfaceArrayExpression(start, kind, fields)); - break; case BinKind::AssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceAssignmentExpression(start, kind, fields)); - break; case BinKind::AwaitExpression: MOZ_TRY_VAR(result, parseInterfaceAwaitExpression(start, kind, fields)); - break; case BinKind::BinaryExpression: MOZ_TRY_VAR(result, parseInterfaceBinaryExpression(start, kind, fields)); - break; case BinKind::CallExpression: MOZ_TRY_VAR(result, parseInterfaceCallExpression(start, kind, fields)); - break; case BinKind::ClassExpression: MOZ_TRY_VAR(result, parseInterfaceClassExpression(start, kind, fields)); - break; case BinKind::CompoundAssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceCompoundAssignmentExpression(start, kind, fields)); - break; case BinKind::ComputedMemberExpression: MOZ_TRY_VAR(result, parseInterfaceComputedMemberExpression(start, kind, fields)); - break; case BinKind::ConditionalExpression: MOZ_TRY_VAR(result, parseInterfaceConditionalExpression(start, kind, fields)); - break; case BinKind::EagerArrowExpression: MOZ_TRY_VAR(result, parseInterfaceEagerArrowExpression(start, kind, fields)); - break; case BinKind::EagerFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceEagerFunctionExpression(start, kind, fields)); - break; case BinKind::IdentifierExpression: MOZ_TRY_VAR(result, parseInterfaceIdentifierExpression(start, kind, fields)); - break; case BinKind::LiteralBooleanExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralBooleanExpression(start, kind, fields)); - break; case BinKind::LiteralInfinityExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralInfinityExpression(start, kind, fields)); - break; case BinKind::LiteralNullExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNullExpression(start, kind, fields)); - break; case BinKind::LiteralNumericExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNumericExpression(start, kind, fields)); - break; case BinKind::LiteralRegExpExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralRegExpExpression(start, kind, fields)); - break; case BinKind::LiteralStringExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralStringExpression(start, kind, fields)); - break; case BinKind::NewExpression: MOZ_TRY_VAR(result, parseInterfaceNewExpression(start, kind, fields)); - break; case BinKind::NewTargetExpression: MOZ_TRY_VAR(result, parseInterfaceNewTargetExpression(start, kind, fields)); - break; case BinKind::ObjectExpression: MOZ_TRY_VAR(result, parseInterfaceObjectExpression(start, kind, fields)); - break; case BinKind::SkippableArrowExpression: MOZ_TRY_VAR(result, parseInterfaceSkippableArrowExpression(start, kind, fields)); - break; case BinKind::SkippableFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceSkippableFunctionExpression(start, kind, fields)); - break; case BinKind::StaticMemberExpression: MOZ_TRY_VAR(result, parseInterfaceStaticMemberExpression(start, kind, fields)); - break; case BinKind::TemplateElement: MOZ_TRY_VAR(result, parseInterfaceTemplateElement(start, kind, fields)); - break; case BinKind::TemplateExpression: MOZ_TRY_VAR(result, parseInterfaceTemplateExpression(start, kind, fields)); - break; case BinKind::ThisExpression: MOZ_TRY_VAR(result, parseInterfaceThisExpression(start, kind, fields)); - break; case BinKind::UnaryExpression: MOZ_TRY_VAR(result, parseInterfaceUnaryExpression(start, kind, fields)); - break; case BinKind::UpdateExpression: MOZ_TRY_VAR(result, parseInterfaceUpdateExpression(start, kind, fields)); - break; case BinKind::YieldExpression: MOZ_TRY_VAR(result, parseInterfaceYieldExpression(start, kind, fields)); - break; case BinKind::YieldStarExpression: MOZ_TRY_VAR(result, parseInterfaceYieldStarExpression(start, kind, fields)); - break; default: return raiseInvalidKind("ExpressionOrTemplateElement", kind); @@ -1074,27 +949,21 @@ BinASTParser::parseSumForInOfBindingOrAssignmentTarget(const size_t start, switch(kind) { case BinKind::ArrayAssignmentTarget: MOZ_TRY_VAR(result, parseInterfaceArrayAssignmentTarget(start, kind, fields)); - break; case BinKind::AssignmentTargetIdentifier: MOZ_TRY_VAR(result, parseInterfaceAssignmentTargetIdentifier(start, kind, fields)); - break; case BinKind::ComputedMemberAssignmentTarget: MOZ_TRY_VAR(result, parseInterfaceComputedMemberAssignmentTarget(start, kind, fields)); - break; case BinKind::ForInOfBinding: MOZ_TRY_VAR(result, parseInterfaceForInOfBinding(start, kind, fields)); - break; case BinKind::ObjectAssignmentTarget: MOZ_TRY_VAR(result, parseInterfaceObjectAssignmentTarget(start, kind, fields)); - break; case BinKind::StaticMemberAssignmentTarget: MOZ_TRY_VAR(result, parseInterfaceStaticMemberAssignmentTarget(start, kind, fields)); - break; default: return raiseInvalidKind("ForInOfBindingOrAssignmentTarget", kind); @@ -1158,127 +1027,96 @@ BinASTParser::parseSumFunctionBodyOrExpression(const size_t start, const Bi switch(kind) { case BinKind::ArrayExpression: MOZ_TRY_VAR(result, parseInterfaceArrayExpression(start, kind, fields)); - break; case BinKind::AssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceAssignmentExpression(start, kind, fields)); - break; case BinKind::AwaitExpression: MOZ_TRY_VAR(result, parseInterfaceAwaitExpression(start, kind, fields)); - break; case BinKind::BinaryExpression: MOZ_TRY_VAR(result, parseInterfaceBinaryExpression(start, kind, fields)); - break; case BinKind::CallExpression: MOZ_TRY_VAR(result, parseInterfaceCallExpression(start, kind, fields)); - break; case BinKind::ClassExpression: MOZ_TRY_VAR(result, parseInterfaceClassExpression(start, kind, fields)); - break; case BinKind::CompoundAssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceCompoundAssignmentExpression(start, kind, fields)); - break; case BinKind::ComputedMemberExpression: MOZ_TRY_VAR(result, parseInterfaceComputedMemberExpression(start, kind, fields)); - break; case BinKind::ConditionalExpression: MOZ_TRY_VAR(result, parseInterfaceConditionalExpression(start, kind, fields)); - break; case BinKind::EagerArrowExpression: MOZ_TRY_VAR(result, parseInterfaceEagerArrowExpression(start, kind, fields)); - break; case BinKind::EagerFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceEagerFunctionExpression(start, kind, fields)); - break; case BinKind::FunctionBody: MOZ_TRY_VAR(result, parseInterfaceFunctionBody(start, kind, fields)); - break; case BinKind::IdentifierExpression: MOZ_TRY_VAR(result, parseInterfaceIdentifierExpression(start, kind, fields)); - break; case BinKind::LiteralBooleanExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralBooleanExpression(start, kind, fields)); - break; case BinKind::LiteralInfinityExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralInfinityExpression(start, kind, fields)); - break; case BinKind::LiteralNullExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNullExpression(start, kind, fields)); - break; case BinKind::LiteralNumericExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNumericExpression(start, kind, fields)); - break; case BinKind::LiteralRegExpExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralRegExpExpression(start, kind, fields)); - break; case BinKind::LiteralStringExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralStringExpression(start, kind, fields)); - break; case BinKind::NewExpression: MOZ_TRY_VAR(result, parseInterfaceNewExpression(start, kind, fields)); - break; case BinKind::NewTargetExpression: MOZ_TRY_VAR(result, parseInterfaceNewTargetExpression(start, kind, fields)); - break; case BinKind::ObjectExpression: MOZ_TRY_VAR(result, parseInterfaceObjectExpression(start, kind, fields)); - break; case BinKind::SkippableArrowExpression: MOZ_TRY_VAR(result, parseInterfaceSkippableArrowExpression(start, kind, fields)); - break; case BinKind::SkippableFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceSkippableFunctionExpression(start, kind, fields)); - break; case BinKind::StaticMemberExpression: MOZ_TRY_VAR(result, parseInterfaceStaticMemberExpression(start, kind, fields)); - break; case BinKind::TemplateExpression: MOZ_TRY_VAR(result, parseInterfaceTemplateExpression(start, kind, fields)); - break; case BinKind::ThisExpression: MOZ_TRY_VAR(result, parseInterfaceThisExpression(start, kind, fields)); - break; case BinKind::UnaryExpression: MOZ_TRY_VAR(result, parseInterfaceUnaryExpression(start, kind, fields)); - break; case BinKind::UpdateExpression: MOZ_TRY_VAR(result, parseInterfaceUpdateExpression(start, kind, fields)); - break; case BinKind::YieldExpression: MOZ_TRY_VAR(result, parseInterfaceYieldExpression(start, kind, fields)); - break; case BinKind::YieldStarExpression: MOZ_TRY_VAR(result, parseInterfaceYieldStarExpression(start, kind, fields)); - break; default: return raiseInvalidKind("FunctionBodyOrExpression", kind); @@ -1313,11 +1151,9 @@ BinASTParser::parseSumFunctionDeclaration(const size_t start, const BinKind switch(kind) { case BinKind::EagerFunctionDeclaration: MOZ_TRY_VAR(result, parseInterfaceEagerFunctionDeclaration(start, kind, fields)); - break; case BinKind::SkippableFunctionDeclaration: MOZ_TRY_VAR(result, parseInterfaceSkippableFunctionDeclaration(start, kind, fields)); - break; default: return raiseInvalidKind("FunctionDeclaration", kind); @@ -1383,135 +1219,102 @@ BinASTParser::parseSumFunctionDeclarationOrClassDeclarationOrExpression(con switch(kind) { case BinKind::ArrayExpression: MOZ_TRY_VAR(result, parseInterfaceArrayExpression(start, kind, fields)); - break; case BinKind::AssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceAssignmentExpression(start, kind, fields)); - break; case BinKind::AwaitExpression: MOZ_TRY_VAR(result, parseInterfaceAwaitExpression(start, kind, fields)); - break; case BinKind::BinaryExpression: MOZ_TRY_VAR(result, parseInterfaceBinaryExpression(start, kind, fields)); - break; case BinKind::CallExpression: MOZ_TRY_VAR(result, parseInterfaceCallExpression(start, kind, fields)); - break; case BinKind::ClassDeclaration: MOZ_TRY_VAR(result, parseInterfaceClassDeclaration(start, kind, fields)); - break; case BinKind::ClassExpression: MOZ_TRY_VAR(result, parseInterfaceClassExpression(start, kind, fields)); - break; case BinKind::CompoundAssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceCompoundAssignmentExpression(start, kind, fields)); - break; case BinKind::ComputedMemberExpression: MOZ_TRY_VAR(result, parseInterfaceComputedMemberExpression(start, kind, fields)); - break; case BinKind::ConditionalExpression: MOZ_TRY_VAR(result, parseInterfaceConditionalExpression(start, kind, fields)); - break; case BinKind::EagerArrowExpression: MOZ_TRY_VAR(result, parseInterfaceEagerArrowExpression(start, kind, fields)); - break; case BinKind::EagerFunctionDeclaration: MOZ_TRY_VAR(result, parseInterfaceEagerFunctionDeclaration(start, kind, fields)); - break; case BinKind::EagerFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceEagerFunctionExpression(start, kind, fields)); - break; case BinKind::IdentifierExpression: MOZ_TRY_VAR(result, parseInterfaceIdentifierExpression(start, kind, fields)); - break; case BinKind::LiteralBooleanExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralBooleanExpression(start, kind, fields)); - break; case BinKind::LiteralInfinityExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralInfinityExpression(start, kind, fields)); - break; case BinKind::LiteralNullExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNullExpression(start, kind, fields)); - break; case BinKind::LiteralNumericExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNumericExpression(start, kind, fields)); - break; case BinKind::LiteralRegExpExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralRegExpExpression(start, kind, fields)); - break; case BinKind::LiteralStringExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralStringExpression(start, kind, fields)); - break; case BinKind::NewExpression: MOZ_TRY_VAR(result, parseInterfaceNewExpression(start, kind, fields)); - break; case BinKind::NewTargetExpression: MOZ_TRY_VAR(result, parseInterfaceNewTargetExpression(start, kind, fields)); - break; case BinKind::ObjectExpression: MOZ_TRY_VAR(result, parseInterfaceObjectExpression(start, kind, fields)); - break; case BinKind::SkippableArrowExpression: MOZ_TRY_VAR(result, parseInterfaceSkippableArrowExpression(start, kind, fields)); - break; case BinKind::SkippableFunctionDeclaration: MOZ_TRY_VAR(result, parseInterfaceSkippableFunctionDeclaration(start, kind, fields)); - break; case BinKind::SkippableFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceSkippableFunctionExpression(start, kind, fields)); - break; case BinKind::StaticMemberExpression: MOZ_TRY_VAR(result, parseInterfaceStaticMemberExpression(start, kind, fields)); - break; case BinKind::TemplateExpression: MOZ_TRY_VAR(result, parseInterfaceTemplateExpression(start, kind, fields)); - break; case BinKind::ThisExpression: MOZ_TRY_VAR(result, parseInterfaceThisExpression(start, kind, fields)); - break; case BinKind::UnaryExpression: MOZ_TRY_VAR(result, parseInterfaceUnaryExpression(start, kind, fields)); - break; case BinKind::UpdateExpression: MOZ_TRY_VAR(result, parseInterfaceUpdateExpression(start, kind, fields)); - break; case BinKind::YieldExpression: MOZ_TRY_VAR(result, parseInterfaceYieldExpression(start, kind, fields)); - break; case BinKind::YieldStarExpression: MOZ_TRY_VAR(result, parseInterfaceYieldStarExpression(start, kind, fields)); - break; default: return raiseInvalidKind("FunctionDeclarationOrClassDeclarationOrExpression", kind); @@ -1548,19 +1351,15 @@ BinASTParser::parseSumFunctionDeclarationOrClassDeclarationOrVariableDeclar switch(kind) { case BinKind::ClassDeclaration: MOZ_TRY_VAR(result, parseInterfaceClassDeclaration(start, kind, fields)); - break; case BinKind::EagerFunctionDeclaration: MOZ_TRY_VAR(result, parseInterfaceEagerFunctionDeclaration(start, kind, fields)); - break; case BinKind::SkippableFunctionDeclaration: MOZ_TRY_VAR(result, parseInterfaceSkippableFunctionDeclaration(start, kind, fields)); - break; case BinKind::VariableDeclaration: MOZ_TRY_VAR(result, parseInterfaceVariableDeclaration(start, kind, fields)); - break; default: return raiseInvalidKind("FunctionDeclarationOrClassDeclarationOrVariableDeclaration", kind); @@ -1595,11 +1394,9 @@ BinASTParser::parseSumFunctionExpression(const size_t start, const BinKind switch(kind) { case BinKind::EagerFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceEagerFunctionExpression(start, kind, fields)); - break; case BinKind::SkippableFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceSkippableFunctionExpression(start, kind, fields)); - break; default: return raiseInvalidKind("FunctionExpression", kind); @@ -1634,11 +1431,9 @@ BinASTParser::parseSumGetter(const size_t start, const BinKind kind, const switch(kind) { case BinKind::EagerGetter: MOZ_TRY_VAR(result, parseInterfaceEagerGetter(start, kind, fields)); - break; case BinKind::SkippableGetter: MOZ_TRY_VAR(result, parseInterfaceSkippableGetter(start, kind, fields)); - break; default: return raiseInvalidKind("Getter", kind); @@ -1673,11 +1468,9 @@ BinASTParser::parseSumImportDeclaration(const size_t start, const BinKind k switch(kind) { case BinKind::Import: MOZ_TRY_VAR(result, parseInterfaceImport(start, kind, fields)); - break; case BinKind::ImportNamespace: MOZ_TRY_VAR(result, parseInterfaceImportNamespace(start, kind, fields)); - break; default: return raiseInvalidKind("ImportDeclaration", kind); @@ -1741,127 +1534,96 @@ BinASTParser::parseSumImportDeclarationOrExportDeclarationOrStatement(const switch(kind) { case BinKind::Block: MOZ_TRY_VAR(result, parseInterfaceBlock(start, kind, fields)); - break; case BinKind::BreakStatement: MOZ_TRY_VAR(result, parseInterfaceBreakStatement(start, kind, fields)); - break; case BinKind::ClassDeclaration: MOZ_TRY_VAR(result, parseInterfaceClassDeclaration(start, kind, fields)); - break; case BinKind::ContinueStatement: MOZ_TRY_VAR(result, parseInterfaceContinueStatement(start, kind, fields)); - break; case BinKind::DebuggerStatement: MOZ_TRY_VAR(result, parseInterfaceDebuggerStatement(start, kind, fields)); - break; case BinKind::DoWhileStatement: MOZ_TRY_VAR(result, parseInterfaceDoWhileStatement(start, kind, fields)); - break; case BinKind::EagerFunctionDeclaration: MOZ_TRY_VAR(result, parseInterfaceEagerFunctionDeclaration(start, kind, fields)); - break; case BinKind::EmptyStatement: MOZ_TRY_VAR(result, parseInterfaceEmptyStatement(start, kind, fields)); - break; case BinKind::Export: MOZ_TRY_VAR(result, parseInterfaceExport(start, kind, fields)); - break; case BinKind::ExportAllFrom: MOZ_TRY_VAR(result, parseInterfaceExportAllFrom(start, kind, fields)); - break; case BinKind::ExportDefault: MOZ_TRY_VAR(result, parseInterfaceExportDefault(start, kind, fields)); - break; case BinKind::ExportFrom: MOZ_TRY_VAR(result, parseInterfaceExportFrom(start, kind, fields)); - break; case BinKind::ExportLocals: MOZ_TRY_VAR(result, parseInterfaceExportLocals(start, kind, fields)); - break; case BinKind::ExpressionStatement: MOZ_TRY_VAR(result, parseInterfaceExpressionStatement(start, kind, fields)); - break; case BinKind::ForInStatement: MOZ_TRY_VAR(result, parseInterfaceForInStatement(start, kind, fields)); - break; case BinKind::ForOfStatement: MOZ_TRY_VAR(result, parseInterfaceForOfStatement(start, kind, fields)); - break; case BinKind::ForStatement: MOZ_TRY_VAR(result, parseInterfaceForStatement(start, kind, fields)); - break; case BinKind::IfStatement: MOZ_TRY_VAR(result, parseInterfaceIfStatement(start, kind, fields)); - break; case BinKind::Import: MOZ_TRY_VAR(result, parseInterfaceImport(start, kind, fields)); - break; case BinKind::ImportNamespace: MOZ_TRY_VAR(result, parseInterfaceImportNamespace(start, kind, fields)); - break; case BinKind::LabelledStatement: MOZ_TRY_VAR(result, parseInterfaceLabelledStatement(start, kind, fields)); - break; case BinKind::ReturnStatement: MOZ_TRY_VAR(result, parseInterfaceReturnStatement(start, kind, fields)); - break; case BinKind::SkippableFunctionDeclaration: MOZ_TRY_VAR(result, parseInterfaceSkippableFunctionDeclaration(start, kind, fields)); - break; case BinKind::SwitchStatement: MOZ_TRY_VAR(result, parseInterfaceSwitchStatement(start, kind, fields)); - break; case BinKind::SwitchStatementWithDefault: MOZ_TRY_VAR(result, parseInterfaceSwitchStatementWithDefault(start, kind, fields)); - break; case BinKind::ThrowStatement: MOZ_TRY_VAR(result, parseInterfaceThrowStatement(start, kind, fields)); - break; case BinKind::TryCatchStatement: MOZ_TRY_VAR(result, parseInterfaceTryCatchStatement(start, kind, fields)); - break; case BinKind::TryFinallyStatement: MOZ_TRY_VAR(result, parseInterfaceTryFinallyStatement(start, kind, fields)); - break; case BinKind::VariableDeclaration: MOZ_TRY_VAR(result, parseInterfaceVariableDeclaration(start, kind, fields)); - break; case BinKind::WhileStatement: MOZ_TRY_VAR(result, parseInterfaceWhileStatement(start, kind, fields)); - break; case BinKind::WithStatement: MOZ_TRY_VAR(result, parseInterfaceWithStatement(start, kind, fields)); - break; default: return raiseInvalidKind("ImportDeclarationOrExportDeclarationOrStatement", kind); @@ -1899,23 +1661,18 @@ BinASTParser::parseSumIterationStatement(const size_t start, const BinKind switch(kind) { case BinKind::DoWhileStatement: MOZ_TRY_VAR(result, parseInterfaceDoWhileStatement(start, kind, fields)); - break; case BinKind::ForInStatement: MOZ_TRY_VAR(result, parseInterfaceForInStatement(start, kind, fields)); - break; case BinKind::ForOfStatement: MOZ_TRY_VAR(result, parseInterfaceForOfStatement(start, kind, fields)); - break; case BinKind::ForStatement: MOZ_TRY_VAR(result, parseInterfaceForStatement(start, kind, fields)); - break; case BinKind::WhileStatement: MOZ_TRY_VAR(result, parseInterfaceWhileStatement(start, kind, fields)); - break; default: return raiseInvalidKind("IterationStatement", kind); @@ -1953,23 +1710,18 @@ BinASTParser::parseSumLiteral(const size_t start, const BinKind kind, const switch(kind) { case BinKind::LiteralBooleanExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralBooleanExpression(start, kind, fields)); - break; case BinKind::LiteralInfinityExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralInfinityExpression(start, kind, fields)); - break; case BinKind::LiteralNullExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNullExpression(start, kind, fields)); - break; case BinKind::LiteralNumericExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNumericExpression(start, kind, fields)); - break; case BinKind::LiteralStringExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralStringExpression(start, kind, fields)); - break; default: return raiseInvalidKind("Literal", kind); @@ -2004,11 +1756,9 @@ BinASTParser::parseSumMethod(const size_t start, const BinKind kind, const switch(kind) { case BinKind::EagerMethod: MOZ_TRY_VAR(result, parseInterfaceEagerMethod(start, kind, fields)); - break; case BinKind::SkippableMethod: MOZ_TRY_VAR(result, parseInterfaceSkippableMethod(start, kind, fields)); - break; default: return raiseInvalidKind("Method", kind); @@ -2047,27 +1797,21 @@ BinASTParser::parseSumMethodDefinition(const size_t start, const BinKind ki switch(kind) { case BinKind::EagerGetter: MOZ_TRY_VAR(result, parseInterfaceEagerGetter(start, kind, fields)); - break; case BinKind::EagerMethod: MOZ_TRY_VAR(result, parseInterfaceEagerMethod(start, kind, fields)); - break; case BinKind::EagerSetter: MOZ_TRY_VAR(result, parseInterfaceEagerSetter(start, kind, fields)); - break; case BinKind::SkippableGetter: MOZ_TRY_VAR(result, parseInterfaceSkippableGetter(start, kind, fields)); - break; case BinKind::SkippableMethod: MOZ_TRY_VAR(result, parseInterfaceSkippableMethod(start, kind, fields)); - break; case BinKind::SkippableSetter: MOZ_TRY_VAR(result, parseInterfaceSkippableSetter(start, kind, fields)); - break; default: return raiseInvalidKind("MethodDefinition", kind); @@ -2108,35 +1852,27 @@ BinASTParser::parseSumObjectProperty(const size_t start, const BinKind kind switch(kind) { case BinKind::DataProperty: MOZ_TRY_VAR(result, parseInterfaceDataProperty(start, kind, fields)); - break; case BinKind::EagerGetter: MOZ_TRY_VAR(result, parseInterfaceEagerGetter(start, kind, fields)); - break; case BinKind::EagerMethod: MOZ_TRY_VAR(result, parseInterfaceEagerMethod(start, kind, fields)); - break; case BinKind::EagerSetter: MOZ_TRY_VAR(result, parseInterfaceEagerSetter(start, kind, fields)); - break; case BinKind::ShorthandProperty: MOZ_TRY_VAR(result, parseInterfaceShorthandProperty(start, kind, fields)); - break; case BinKind::SkippableGetter: MOZ_TRY_VAR(result, parseInterfaceSkippableGetter(start, kind, fields)); - break; case BinKind::SkippableMethod: MOZ_TRY_VAR(result, parseInterfaceSkippableMethod(start, kind, fields)); - break; case BinKind::SkippableSetter: MOZ_TRY_VAR(result, parseInterfaceSkippableSetter(start, kind, fields)); - break; default: return raiseInvalidKind("ObjectProperty", kind); @@ -2173,7 +1909,6 @@ BinASTParser::parseSumParameter(const size_t start, const BinKind kind, con switch(kind) { case BinKind::ArrayBinding: MOZ_TRY_VAR(result, parseInterfaceArrayBinding(start, kind, fields)); - break; case BinKind::BindingIdentifier: MOZ_TRY_VAR(result, parseInterfaceBindingIdentifier(start, kind, fields)); @@ -2184,11 +1919,9 @@ BinASTParser::parseSumParameter(const size_t start, const BinKind kind, con break; case BinKind::BindingWithInitializer: MOZ_TRY_VAR(result, parseInterfaceBindingWithInitializer(start, kind, fields)); - break; case BinKind::ObjectBinding: MOZ_TRY_VAR(result, parseInterfaceObjectBinding(start, kind, fields)); - break; default: return raiseInvalidKind("Parameter", kind); @@ -2223,11 +1956,9 @@ BinASTParser::parseSumProgram(const size_t start, const BinKind kind, const switch(kind) { case BinKind::Module: MOZ_TRY_VAR(result, parseInterfaceModule(start, kind, fields)); - break; case BinKind::Script: MOZ_TRY_VAR(result, parseInterfaceScript(start, kind, fields)); - break; default: return raiseInvalidKind("Program", kind); @@ -2262,11 +1993,9 @@ BinASTParser::parseSumPropertyName(const size_t start, const BinKind kind, switch(kind) { case BinKind::ComputedPropertyName: MOZ_TRY_VAR(result, parseInterfaceComputedPropertyName(start, kind, fields)); - break; case BinKind::LiteralPropertyName: MOZ_TRY_VAR(result, parseInterfaceLiteralPropertyName(start, kind, fields)); - break; default: return raiseInvalidKind("PropertyName", kind); @@ -2301,11 +2030,9 @@ BinASTParser::parseSumSetter(const size_t start, const BinKind kind, const switch(kind) { case BinKind::EagerSetter: MOZ_TRY_VAR(result, parseInterfaceEagerSetter(start, kind, fields)); - break; case BinKind::SkippableSetter: MOZ_TRY_VAR(result, parseInterfaceSkippableSetter(start, kind, fields)); - break; default: return raiseInvalidKind("Setter", kind); @@ -2341,15 +2068,12 @@ BinASTParser::parseSumSimpleAssignmentTarget(const size_t start, const BinK switch(kind) { case BinKind::AssignmentTargetIdentifier: MOZ_TRY_VAR(result, parseInterfaceAssignmentTargetIdentifier(start, kind, fields)); - break; case BinKind::ComputedMemberAssignmentTarget: MOZ_TRY_VAR(result, parseInterfaceComputedMemberAssignmentTarget(start, kind, fields)); - break; case BinKind::StaticMemberAssignmentTarget: MOZ_TRY_VAR(result, parseInterfaceStaticMemberAssignmentTarget(start, kind, fields)); - break; default: return raiseInvalidKind("SimpleAssignmentTarget", kind); @@ -2413,127 +2137,96 @@ BinASTParser::parseSumSpreadElementOrExpression(const size_t start, const B switch(kind) { case BinKind::ArrayExpression: MOZ_TRY_VAR(result, parseInterfaceArrayExpression(start, kind, fields)); - break; case BinKind::AssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceAssignmentExpression(start, kind, fields)); - break; case BinKind::AwaitExpression: MOZ_TRY_VAR(result, parseInterfaceAwaitExpression(start, kind, fields)); - break; case BinKind::BinaryExpression: MOZ_TRY_VAR(result, parseInterfaceBinaryExpression(start, kind, fields)); - break; case BinKind::CallExpression: MOZ_TRY_VAR(result, parseInterfaceCallExpression(start, kind, fields)); - break; case BinKind::ClassExpression: MOZ_TRY_VAR(result, parseInterfaceClassExpression(start, kind, fields)); - break; case BinKind::CompoundAssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceCompoundAssignmentExpression(start, kind, fields)); - break; case BinKind::ComputedMemberExpression: MOZ_TRY_VAR(result, parseInterfaceComputedMemberExpression(start, kind, fields)); - break; case BinKind::ConditionalExpression: MOZ_TRY_VAR(result, parseInterfaceConditionalExpression(start, kind, fields)); - break; case BinKind::EagerArrowExpression: MOZ_TRY_VAR(result, parseInterfaceEagerArrowExpression(start, kind, fields)); - break; case BinKind::EagerFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceEagerFunctionExpression(start, kind, fields)); - break; case BinKind::IdentifierExpression: MOZ_TRY_VAR(result, parseInterfaceIdentifierExpression(start, kind, fields)); - break; case BinKind::LiteralBooleanExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralBooleanExpression(start, kind, fields)); - break; case BinKind::LiteralInfinityExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralInfinityExpression(start, kind, fields)); - break; case BinKind::LiteralNullExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNullExpression(start, kind, fields)); - break; case BinKind::LiteralNumericExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNumericExpression(start, kind, fields)); - break; case BinKind::LiteralRegExpExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralRegExpExpression(start, kind, fields)); - break; case BinKind::LiteralStringExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralStringExpression(start, kind, fields)); - break; case BinKind::NewExpression: MOZ_TRY_VAR(result, parseInterfaceNewExpression(start, kind, fields)); - break; case BinKind::NewTargetExpression: MOZ_TRY_VAR(result, parseInterfaceNewTargetExpression(start, kind, fields)); - break; case BinKind::ObjectExpression: MOZ_TRY_VAR(result, parseInterfaceObjectExpression(start, kind, fields)); - break; case BinKind::SkippableArrowExpression: MOZ_TRY_VAR(result, parseInterfaceSkippableArrowExpression(start, kind, fields)); - break; case BinKind::SkippableFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceSkippableFunctionExpression(start, kind, fields)); - break; case BinKind::SpreadElement: MOZ_TRY_VAR(result, parseInterfaceSpreadElement(start, kind, fields)); - break; case BinKind::StaticMemberExpression: MOZ_TRY_VAR(result, parseInterfaceStaticMemberExpression(start, kind, fields)); - break; case BinKind::TemplateExpression: MOZ_TRY_VAR(result, parseInterfaceTemplateExpression(start, kind, fields)); - break; case BinKind::ThisExpression: MOZ_TRY_VAR(result, parseInterfaceThisExpression(start, kind, fields)); - break; case BinKind::UnaryExpression: MOZ_TRY_VAR(result, parseInterfaceUnaryExpression(start, kind, fields)); - break; case BinKind::UpdateExpression: MOZ_TRY_VAR(result, parseInterfaceUpdateExpression(start, kind, fields)); - break; case BinKind::YieldExpression: MOZ_TRY_VAR(result, parseInterfaceYieldExpression(start, kind, fields)); - break; case BinKind::YieldStarExpression: MOZ_TRY_VAR(result, parseInterfaceYieldStarExpression(start, kind, fields)); - break; default: return raiseInvalidKind("SpreadElementOrExpression", kind); @@ -2590,99 +2283,75 @@ BinASTParser::parseSumStatement(const size_t start, const BinKind kind, con switch(kind) { case BinKind::Block: MOZ_TRY_VAR(result, parseInterfaceBlock(start, kind, fields)); - break; case BinKind::BreakStatement: MOZ_TRY_VAR(result, parseInterfaceBreakStatement(start, kind, fields)); - break; case BinKind::ClassDeclaration: MOZ_TRY_VAR(result, parseInterfaceClassDeclaration(start, kind, fields)); - break; case BinKind::ContinueStatement: MOZ_TRY_VAR(result, parseInterfaceContinueStatement(start, kind, fields)); - break; case BinKind::DebuggerStatement: MOZ_TRY_VAR(result, parseInterfaceDebuggerStatement(start, kind, fields)); - break; case BinKind::DoWhileStatement: MOZ_TRY_VAR(result, parseInterfaceDoWhileStatement(start, kind, fields)); - break; case BinKind::EagerFunctionDeclaration: MOZ_TRY_VAR(result, parseInterfaceEagerFunctionDeclaration(start, kind, fields)); - break; case BinKind::EmptyStatement: MOZ_TRY_VAR(result, parseInterfaceEmptyStatement(start, kind, fields)); - break; case BinKind::ExpressionStatement: MOZ_TRY_VAR(result, parseInterfaceExpressionStatement(start, kind, fields)); - break; case BinKind::ForInStatement: MOZ_TRY_VAR(result, parseInterfaceForInStatement(start, kind, fields)); - break; case BinKind::ForOfStatement: MOZ_TRY_VAR(result, parseInterfaceForOfStatement(start, kind, fields)); - break; case BinKind::ForStatement: MOZ_TRY_VAR(result, parseInterfaceForStatement(start, kind, fields)); - break; case BinKind::IfStatement: MOZ_TRY_VAR(result, parseInterfaceIfStatement(start, kind, fields)); - break; case BinKind::LabelledStatement: MOZ_TRY_VAR(result, parseInterfaceLabelledStatement(start, kind, fields)); - break; case BinKind::ReturnStatement: MOZ_TRY_VAR(result, parseInterfaceReturnStatement(start, kind, fields)); - break; case BinKind::SkippableFunctionDeclaration: MOZ_TRY_VAR(result, parseInterfaceSkippableFunctionDeclaration(start, kind, fields)); - break; case BinKind::SwitchStatement: MOZ_TRY_VAR(result, parseInterfaceSwitchStatement(start, kind, fields)); - break; case BinKind::SwitchStatementWithDefault: MOZ_TRY_VAR(result, parseInterfaceSwitchStatementWithDefault(start, kind, fields)); - break; case BinKind::ThrowStatement: MOZ_TRY_VAR(result, parseInterfaceThrowStatement(start, kind, fields)); - break; case BinKind::TryCatchStatement: MOZ_TRY_VAR(result, parseInterfaceTryCatchStatement(start, kind, fields)); - break; case BinKind::TryFinallyStatement: MOZ_TRY_VAR(result, parseInterfaceTryFinallyStatement(start, kind, fields)); - break; case BinKind::VariableDeclaration: MOZ_TRY_VAR(result, parseInterfaceVariableDeclaration(start, kind, fields)); - break; case BinKind::WhileStatement: MOZ_TRY_VAR(result, parseInterfaceWhileStatement(start, kind, fields)); - break; case BinKind::WithStatement: MOZ_TRY_VAR(result, parseInterfaceWithStatement(start, kind, fields)); - break; default: return raiseInvalidKind("Statement", kind); @@ -2746,127 +2415,96 @@ BinASTParser::parseSumVariableDeclarationOrExpression(const size_t start, c switch(kind) { case BinKind::ArrayExpression: MOZ_TRY_VAR(result, parseInterfaceArrayExpression(start, kind, fields)); - break; case BinKind::AssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceAssignmentExpression(start, kind, fields)); - break; case BinKind::AwaitExpression: MOZ_TRY_VAR(result, parseInterfaceAwaitExpression(start, kind, fields)); - break; case BinKind::BinaryExpression: MOZ_TRY_VAR(result, parseInterfaceBinaryExpression(start, kind, fields)); - break; case BinKind::CallExpression: MOZ_TRY_VAR(result, parseInterfaceCallExpression(start, kind, fields)); - break; case BinKind::ClassExpression: MOZ_TRY_VAR(result, parseInterfaceClassExpression(start, kind, fields)); - break; case BinKind::CompoundAssignmentExpression: MOZ_TRY_VAR(result, parseInterfaceCompoundAssignmentExpression(start, kind, fields)); - break; case BinKind::ComputedMemberExpression: MOZ_TRY_VAR(result, parseInterfaceComputedMemberExpression(start, kind, fields)); - break; case BinKind::ConditionalExpression: MOZ_TRY_VAR(result, parseInterfaceConditionalExpression(start, kind, fields)); - break; case BinKind::EagerArrowExpression: MOZ_TRY_VAR(result, parseInterfaceEagerArrowExpression(start, kind, fields)); - break; case BinKind::EagerFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceEagerFunctionExpression(start, kind, fields)); - break; case BinKind::IdentifierExpression: MOZ_TRY_VAR(result, parseInterfaceIdentifierExpression(start, kind, fields)); - break; case BinKind::LiteralBooleanExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralBooleanExpression(start, kind, fields)); - break; case BinKind::LiteralInfinityExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralInfinityExpression(start, kind, fields)); - break; case BinKind::LiteralNullExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNullExpression(start, kind, fields)); - break; case BinKind::LiteralNumericExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralNumericExpression(start, kind, fields)); - break; case BinKind::LiteralRegExpExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralRegExpExpression(start, kind, fields)); - break; case BinKind::LiteralStringExpression: MOZ_TRY_VAR(result, parseInterfaceLiteralStringExpression(start, kind, fields)); - break; case BinKind::NewExpression: MOZ_TRY_VAR(result, parseInterfaceNewExpression(start, kind, fields)); - break; case BinKind::NewTargetExpression: MOZ_TRY_VAR(result, parseInterfaceNewTargetExpression(start, kind, fields)); - break; case BinKind::ObjectExpression: MOZ_TRY_VAR(result, parseInterfaceObjectExpression(start, kind, fields)); - break; case BinKind::SkippableArrowExpression: MOZ_TRY_VAR(result, parseInterfaceSkippableArrowExpression(start, kind, fields)); - break; case BinKind::SkippableFunctionExpression: MOZ_TRY_VAR(result, parseInterfaceSkippableFunctionExpression(start, kind, fields)); - break; case BinKind::StaticMemberExpression: MOZ_TRY_VAR(result, parseInterfaceStaticMemberExpression(start, kind, fields)); - break; case BinKind::TemplateExpression: MOZ_TRY_VAR(result, parseInterfaceTemplateExpression(start, kind, fields)); - break; case BinKind::ThisExpression: MOZ_TRY_VAR(result, parseInterfaceThisExpression(start, kind, fields)); - break; case BinKind::UnaryExpression: MOZ_TRY_VAR(result, parseInterfaceUnaryExpression(start, kind, fields)); - break; case BinKind::UpdateExpression: MOZ_TRY_VAR(result, parseInterfaceUpdateExpression(start, kind, fields)); - break; case BinKind::VariableDeclaration: MOZ_TRY_VAR(result, parseInterfaceVariableDeclaration(start, kind, fields)); - break; case BinKind::YieldExpression: MOZ_TRY_VAR(result, parseInterfaceYieldExpression(start, kind, fields)); - break; case BinKind::YieldStarExpression: MOZ_TRY_VAR(result, parseInterfaceYieldStarExpression(start, kind, fields)); - break; default: return raiseInvalidKind("VariableDeclarationOrExpression", kind); @@ -2999,18 +2637,13 @@ BinASTParser::parseInterfaceArrayExpression(const size_t start, const BinKi MOZ_ASSERT(kind == BinKind::ArrayExpression); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[1] = { BinField::Elements }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(elements, parseListOfOptionalSpreadElementOrExpression()); - auto result = elements; return result; } @@ -3047,23 +2680,18 @@ BinASTParser::parseInterfaceAssertedBlockScope(const size_t start, const Bi MOZ_ASSERT(kind == BinKind::AssertedBlockScope); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[3] = { BinField::LexicallyDeclaredNames, BinField::CapturedNames, BinField::HasDirectEval }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - MOZ_TRY(parseAndUpdateScopeNames(*parseContext_->innermostScope(), DeclarationKind::Let)); MOZ_TRY(parseAndUpdateCapturedNames(kind)); - - BINJS_MOZ_TRY_DECL(hasDirectEval, tokenizer_->readBool()); if (hasDirectEval) { parseContext_->sc()->setHasDirectEval(); parseContext_->sc()->setBindingsAccessedDynamically(); } - if (hasDirectEval && parseContext_->isFunctionBox() && !parseContext_->sc()->strict()) { // In non-strict mode code, direct calls to eval can // add variables to the call object. @@ -3105,12 +2733,10 @@ BinASTParser::parseInterfaceAssertedParameterScope(const size_t start, cons MOZ_ASSERT(kind == BinKind::AssertedParameterScope); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[3] = { BinField::ParameterNames, BinField::CapturedNames, BinField::HasDirectEval }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - ParseContext::Statement* inStatement = parseContext_->innermostStatement(); // If we are in a `CatchClause`, the binding is a implicit CatchParameter @@ -3122,14 +2748,11 @@ BinASTParser::parseInterfaceAssertedParameterScope(const size_t start, cons MOZ_TRY(parseAndUpdateScopeNames(parseContext_->functionScope(), DeclarationKind::PositionalFormalParameter)); MOZ_TRY(parseAndUpdateCapturedNames(kind)); - - BINJS_MOZ_TRY_DECL(hasDirectEval, tokenizer_->readBool()); if (hasDirectEval) { parseContext_->sc()->setHasDirectEval(); parseContext_->sc()->setBindingsAccessedDynamically(); } - if (hasDirectEval && parseContext_->isFunctionBox() && !parseContext_->sc()->strict()) { // In non-strict mode code, direct calls to eval can // add variables to the call object. @@ -3172,24 +2795,19 @@ BinASTParser::parseInterfaceAssertedVarScope(const size_t start, const BinK MOZ_ASSERT(kind == BinKind::AssertedVarScope); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[4] = { BinField::LexicallyDeclaredNames, BinField::VarDeclaredNames, BinField::CapturedNames, BinField::HasDirectEval }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - MOZ_TRY(parseAndUpdateScopeNames(*parseContext_->innermostScope(), DeclarationKind::Let)); MOZ_TRY(parseAndUpdateScopeNames(parseContext_->varScope(), DeclarationKind::Var)); MOZ_TRY(parseAndUpdateCapturedNames(kind)); - - BINJS_MOZ_TRY_DECL(hasDirectEval, tokenizer_->readBool()); if (hasDirectEval) { parseContext_->sc()->setHasDirectEval(); parseContext_->sc()->setBindingsAccessedDynamically(); } - if (hasDirectEval && parseContext_->isFunctionBox() && !parseContext_->sc()->strict()) { // In non-strict mode code, direct calls to eval can // add variables to the call object. @@ -3230,23 +2848,15 @@ BinASTParser::parseInterfaceAssignmentExpression(const size_t start, const MOZ_ASSERT(kind == BinKind::AssignmentExpression); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Binding, BinField::Expression }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(binding, parseAssignmentTarget()); - - - BINJS_MOZ_TRY_DECL(expression, parseExpression()); - BINJS_TRY_DECL(result, factory_.newAssignment(ParseNodeKind::Assign, binding, expression)); return result; } @@ -3281,18 +2891,14 @@ BinASTParser::parseInterfaceAssignmentTargetIdentifier(const size_t start, MOZ_ASSERT(kind == BinKind::AssignmentTargetIdentifier); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[1] = { BinField::Name }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - RootedAtom name(cx_); MOZ_TRY_VAR(name, tokenizer_->readAtom()); - if (!IsIdentifier(name)) return raiseError("Invalid identifier"); BINJS_TRY(usedNames_.noteUse(cx_, name, parseContext_->scriptId(), parseContext_->innermostScope()->id())); @@ -3455,28 +3061,17 @@ BinASTParser::parseInterfaceBinaryExpression(const size_t start, const BinK MOZ_ASSERT(kind == BinKind::BinaryExpression); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[3] = { BinField::Operator, BinField::Left, BinField::Right }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(operator_, parseBinaryOperator()); - - - BINJS_MOZ_TRY_DECL(left, parseExpression()); - - - BINJS_MOZ_TRY_DECL(right, parseExpression()); - ParseNodeKind pnk; switch (operator_) { case BinaryOperator::Comma: @@ -3603,18 +3198,14 @@ BinASTParser::parseInterfaceBindingIdentifier(const size_t start, const Bin MOZ_ASSERT(kind == BinKind::BindingIdentifier); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[1] = { BinField::Name }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - RootedAtom name(cx_); MOZ_TRY_VAR(name, tokenizer_->readAtom()); - if (!IsIdentifier(name)) return raiseError("Invalid identifier"); BINJS_TRY_DECL(result, factory_.newName(name->asPropertyName(), tokenizer_->pos(start), cx_)); @@ -3745,25 +3336,18 @@ BinASTParser::parseInterfaceBlock(const size_t start, const BinKind kind, c MOZ_ASSERT(kind == BinKind::Block); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Scope, BinField::Statements }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - ParseContext::Statement stmt(parseContext_, StatementKind::Block); ParseContext::Scope currentScope(cx_, parseContext_, usedNames_); BINJS_TRY(currentScope.init(parseContext_)); - MOZ_TRY(parseOptionalAssertedBlockScope()); - - - BINJS_MOZ_TRY_DECL(statements, parseListOfStatement()); - MOZ_TRY(checkClosedVars(currentScope)); BINJS_TRY_DECL(bindings, NewLexicalScopeData(cx_, currentScope, alloc_, parseContext_)); BINJS_TRY_DECL(result, factory_.newLexicalScope(*bindings, statements)); @@ -3800,12 +3384,10 @@ BinASTParser::parseInterfaceBreakStatement(const size_t start, const BinKin MOZ_ASSERT(kind == BinKind::BreakStatement); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[1] = { BinField::Label }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - RootedAtom label(cx_); MOZ_TRY_VAR(label, tokenizer_->readMaybeAtom()); @@ -3859,23 +3441,15 @@ BinASTParser::parseInterfaceCallExpression(const size_t start, const BinKin MOZ_ASSERT(kind == BinKind::CallExpression); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Callee, BinField::Arguments }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(callee, parseExpressionOrSuper()); - - - BINJS_MOZ_TRY_DECL(arguments, parseArguments()); - auto op = JSOP_CALL; // Check for direct calls to `eval`. if (factory_.isEvalName(callee, cx_)) { @@ -3927,30 +3501,20 @@ BinASTParser::parseInterfaceCatchClause(const size_t start, const BinKind k MOZ_ASSERT(kind == BinKind::CatchClause); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[3] = { BinField::BindingScope, BinField::Binding, BinField::Body }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - ParseContext::Statement stmt(parseContext_, StatementKind::Catch); ParseContext::Scope currentScope(cx_, parseContext_, usedNames_); BINJS_TRY(currentScope.init(parseContext_)); - MOZ_TRY(parseOptionalAssertedParameterScope()); - - - BINJS_MOZ_TRY_DECL(binding, parseBinding()); - - - BINJS_MOZ_TRY_DECL(body, parseBlock()); - BINJS_TRY_DECL(bindings, NewLexicalScopeData(cx_, currentScope, alloc_, parseContext_)); BINJS_TRY_DECL(result, factory_.newLexicalScope(*bindings, body)); BINJS_TRY(factory_.setupCatchScope(result, binding, body)); @@ -4084,28 +3648,17 @@ BinASTParser::parseInterfaceCompoundAssignmentExpression(const size_t start MOZ_ASSERT(kind == BinKind::CompoundAssignmentExpression); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[3] = { BinField::Operator, BinField::Binding, BinField::Expression }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(operator_, parseCompoundAssignmentOperator()); - - - BINJS_MOZ_TRY_DECL(binding, parseSimpleAssignmentTarget()); - - - BINJS_MOZ_TRY_DECL(expression, parseExpression()); - ParseNodeKind pnk; switch (operator_){ case CompoundAssignmentOperator::PlusAssign: @@ -4180,23 +3733,15 @@ BinASTParser::parseInterfaceComputedMemberAssignmentTarget(const size_t sta MOZ_ASSERT(kind == BinKind::ComputedMemberAssignmentTarget); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Object, BinField::Expression }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(object, parseExpressionOrSuper()); - - - BINJS_MOZ_TRY_DECL(expression, parseExpression()); - BINJS_TRY_DECL(result, factory_.newPropertyByValue(object, expression, start)); return result; } @@ -4232,23 +3777,15 @@ BinASTParser::parseInterfaceComputedMemberExpression(const size_t start, co MOZ_ASSERT(kind == BinKind::ComputedMemberExpression); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Object, BinField::Expression }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(object, parseExpressionOrSuper()); - - - BINJS_MOZ_TRY_DECL(expression, parseExpression()); - BINJS_TRY_DECL(result, factory_.newPropertyByValue(object, expression, start)); return result; } @@ -4315,28 +3852,17 @@ BinASTParser::parseInterfaceConditionalExpression(const size_t start, const MOZ_ASSERT(kind == BinKind::ConditionalExpression); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[3] = { BinField::Test, BinField::Consequent, BinField::Alternate }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(test, parseExpression()); - - - BINJS_MOZ_TRY_DECL(consequent, parseExpression()); - - - BINJS_MOZ_TRY_DECL(alternate, parseExpression()); - BINJS_TRY_DECL(result, factory_.newConditional(test, consequent, alternate)); return result; } @@ -4371,12 +3897,10 @@ BinASTParser::parseInterfaceContinueStatement(const size_t start, const Bin MOZ_ASSERT(kind == BinKind::ContinueStatement); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[1] = { BinField::Label }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - RootedAtom label(cx_); MOZ_TRY_VAR(label, tokenizer_->readMaybeAtom()); @@ -4430,23 +3954,15 @@ BinASTParser::parseInterfaceDataProperty(const size_t start, const BinKind MOZ_ASSERT(kind == BinKind::DataProperty); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Name, BinField::Expression }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(name, parsePropertyName()); - - - BINJS_MOZ_TRY_DECL(expression, parseExpression()); - if (!factory_.isUsableAsObjectPropertyName(name)) return raiseError("DataProperty key kind"); @@ -4513,18 +4029,14 @@ BinASTParser::parseInterfaceDirective(const size_t start, const BinKind kin MOZ_ASSERT(kind == BinKind::Directive); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[1] = { BinField::RawValue }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - RootedAtom rawValue(cx_); MOZ_TRY_VAR(rawValue, tokenizer_->readAtom()); - TokenPos pos = tokenizer_->pos(start); BINJS_TRY_DECL(result, factory_.newStringLiteral(rawValue, pos)); return result; @@ -4561,23 +4073,16 @@ BinASTParser::parseInterfaceDoWhileStatement(const size_t start, const BinK MOZ_ASSERT(kind == BinKind::DoWhileStatement); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Test, BinField::Body }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - ParseContext::Statement stmt(parseContext_, StatementKind::DoLoop); - BINJS_MOZ_TRY_DECL(test, parseExpression()); - - - BINJS_MOZ_TRY_DECL(body, parseStatement()); - BINJS_TRY_DECL(result, factory_.newDoWhileStatement(body, test, tokenizer_->pos(start))); return result; } @@ -4652,28 +4157,18 @@ BinASTParser::parseInterfaceEagerFunctionDeclaration(const size_t start, co MOZ_ASSERT(kind == BinKind::EagerFunctionDeclaration); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[7] = { BinField::IsAsync, BinField::IsGenerator, BinField::Name, BinField::ParameterScope, BinField::BodyScope, BinField::Params, BinField::Body }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - const auto syntax = FunctionSyntaxKind::Statement; - BINJS_MOZ_TRY_DECL(isAsync, tokenizer_->readBool()); - - - BINJS_MOZ_TRY_DECL(isGenerator, tokenizer_->readBool()); - - - BINJS_MOZ_TRY_DECL(name, parseBindingIdentifier()); - BINJS_MOZ_TRY_DECL(funbox, buildFunctionBox( isGenerator ? GeneratorKind::Generator : GeneratorKind::NotGenerator, @@ -4689,25 +4184,14 @@ BinASTParser::parseInterfaceEagerFunctionDeclaration(const size_t start, co ParseContext::Scope lexicalScope(cx_, parseContext_, usedNames_); BINJS_TRY(lexicalScope.init(parseContext_)); - MOZ_TRY(parseOptionalAssertedParameterScope()); - - - MOZ_TRY(parseOptionalAssertedVarScope()); - - - BINJS_MOZ_TRY_DECL(params, parseFormalParameters()); - - - BINJS_MOZ_TRY_DECL(body, parseFunctionBody()); - BINJS_TRY_DECL(lexicalScopeData, NewLexicalScopeData(cx_, lexicalScope, alloc_, parseContext_)); BINJS_TRY_VAR(body, factory_.newLexicalScope(*lexicalScopeData, body)); BINJS_MOZ_TRY_DECL(result, buildFunction(start, kind, name, params, body, funbox)); @@ -4750,28 +4234,18 @@ BinASTParser::parseInterfaceEagerFunctionExpression(const size_t start, con MOZ_ASSERT(kind == BinKind::EagerFunctionExpression); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[7] = { BinField::IsAsync, BinField::IsGenerator, BinField::Name, BinField::ParameterScope, BinField::BodyScope, BinField::Params, BinField::Body }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - const auto syntax = FunctionSyntaxKind::Expression; - BINJS_MOZ_TRY_DECL(isAsync, tokenizer_->readBool()); - - - BINJS_MOZ_TRY_DECL(isGenerator, tokenizer_->readBool()); - - - BINJS_MOZ_TRY_DECL(name, parseOptionalBindingIdentifier()); - BINJS_MOZ_TRY_DECL(funbox, buildFunctionBox( isGenerator ? GeneratorKind::Generator : GeneratorKind::NotGenerator, @@ -4787,25 +4261,14 @@ BinASTParser::parseInterfaceEagerFunctionExpression(const size_t start, con ParseContext::Scope lexicalScope(cx_, parseContext_, usedNames_); BINJS_TRY(lexicalScope.init(parseContext_)); - MOZ_TRY(parseOptionalAssertedParameterScope()); - - - MOZ_TRY(parseOptionalAssertedVarScope()); - - - BINJS_MOZ_TRY_DECL(params, parseFormalParameters()); - - - BINJS_MOZ_TRY_DECL(body, parseFunctionBody()); - BINJS_TRY_DECL(lexicalScopeData, NewLexicalScopeData(cx_, lexicalScope, alloc_, parseContext_)); BINJS_TRY_VAR(body, factory_.newLexicalScope(*lexicalScopeData, body)); BINJS_MOZ_TRY_DECL(result, buildFunction(start, kind, name, params, body, funbox)); @@ -4844,15 +4307,11 @@ BinASTParser::parseInterfaceEagerGetter(const size_t start, const BinKind k MOZ_ASSERT(kind == BinKind::EagerGetter); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[3] = { BinField::Name, BinField::BodyScope, BinField::Body }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(name, parsePropertyName()); BINJS_MOZ_TRY_DECL(funbox, buildFunctionBox( GeneratorKind::NotGenerator, @@ -4867,17 +4326,10 @@ BinASTParser::parseInterfaceEagerGetter(const size_t start, const BinKind k ParseContext::Scope lexicalScope(cx_, parseContext_, usedNames_); BINJS_TRY(lexicalScope.init(parseContext_)); - - - MOZ_TRY(parseOptionalAssertedVarScope()); - - - BINJS_MOZ_TRY_DECL(body, parseFunctionBody()); - BINJS_TRY_DECL(params, new_(ParseNodeKind::ParamsBody, tokenizer_->pos(start))); BINJS_MOZ_TRY_DECL(method, buildFunction(start, kind, name, params, body, funbox)); BINJS_TRY_DECL(result, factory_.newObjectMethodOrPropertyDefinition(name, method, AccessorType::Getter)); @@ -4920,28 +4372,18 @@ BinASTParser::parseInterfaceEagerMethod(const size_t start, const BinKind k MOZ_ASSERT(kind == BinKind::EagerMethod); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[7] = { BinField::IsAsync, BinField::IsGenerator, BinField::Name, BinField::ParameterScope, BinField::BodyScope, BinField::Params, BinField::Body }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - const auto syntax = FunctionSyntaxKind::Method; - BINJS_MOZ_TRY_DECL(isAsync, tokenizer_->readBool()); - - - BINJS_MOZ_TRY_DECL(isGenerator, tokenizer_->readBool()); - - - BINJS_MOZ_TRY_DECL(name, parsePropertyName()); - BINJS_MOZ_TRY_DECL(funbox, buildFunctionBox( isGenerator ? GeneratorKind::Generator : GeneratorKind::NotGenerator, @@ -4957,25 +4399,14 @@ BinASTParser::parseInterfaceEagerMethod(const size_t start, const BinKind k ParseContext::Scope lexicalScope(cx_, parseContext_, usedNames_); BINJS_TRY(lexicalScope.init(parseContext_)); - MOZ_TRY(parseOptionalAssertedParameterScope()); - - - MOZ_TRY(parseOptionalAssertedVarScope()); - - - BINJS_MOZ_TRY_DECL(params, parseFormalParameters()); - - - BINJS_MOZ_TRY_DECL(body, parseFunctionBody()); - BINJS_MOZ_TRY_DECL(method, buildFunction(start, kind, name, params, body, funbox)); BINJS_TRY_DECL(result, factory_.newObjectMethodOrPropertyDefinition(name, method, AccessorType::None)); return result; @@ -5015,15 +4446,11 @@ BinASTParser::parseInterfaceEagerSetter(const size_t start, const BinKind k MOZ_ASSERT(kind == BinKind::EagerSetter); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[5] = { BinField::Name, BinField::ParameterScope, BinField::BodyScope, BinField::Param, BinField::Body }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(name, parsePropertyName()); BINJS_MOZ_TRY_DECL(funbox, buildFunctionBox( GeneratorKind::NotGenerator, @@ -5038,27 +4465,14 @@ BinASTParser::parseInterfaceEagerSetter(const size_t start, const BinKind k ParseContext::Scope lexicalScope(cx_, parseContext_, usedNames_); BINJS_TRY(lexicalScope.init(parseContext_)); - - - MOZ_TRY(parseOptionalAssertedParameterScope()); - - - MOZ_TRY(parseOptionalAssertedVarScope()); - - - BINJS_MOZ_TRY_DECL(param, parseParameter()); - - - BINJS_MOZ_TRY_DECL(body, parseFunctionBody()); - BINJS_TRY_DECL(params, new_(ParseNodeKind::ParamsBody, param->pn_pos)); factory_.addList(params, param); BINJS_MOZ_TRY_DECL(method, buildFunction(start, kind, name, params, body, funbox)); @@ -5094,7 +4508,6 @@ BinASTParser::parseInterfaceEmptyStatement(const size_t start, const BinKin { MOZ_ASSERT(kind == BinKind::EmptyStatement); BINJS_TRY(CheckRecursionLimit(cx_)); - MOZ_TRY(tokenizer_->checkFields0(kind, fields)); BINJS_TRY_DECL(result, factory_.newEmptyStatement(tokenizer_->pos(start))); @@ -5344,18 +4757,13 @@ BinASTParser::parseInterfaceExpressionStatement(const size_t start, const B MOZ_ASSERT(kind == BinKind::ExpressionStatement); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[1] = { BinField::Expression }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(expression, parseExpression()); - BINJS_TRY_DECL(result, factory_.newExprStatement(expression, tokenizer_->offset())); return result; } @@ -5391,23 +4799,16 @@ BinASTParser::parseInterfaceForInOfBinding(const size_t start, const BinKin MOZ_ASSERT(kind == BinKind::ForInOfBinding); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Kind, BinField::Binding }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - AutoVariableDeclarationKind kindGuard(this); - BINJS_MOZ_TRY_DECL(kind_, parseVariableDeclarationKind()); - - - BINJS_MOZ_TRY_DECL(binding, parseBinding()); - // Restored by `kindGuard`. variableDeclarationKind_ = kind_; MOZ_TRY(checkBinding(binding->pn_atom->asPropertyName())); @@ -5452,12 +4853,10 @@ BinASTParser::parseInterfaceForInStatement(const size_t start, const BinKin MOZ_ASSERT(kind == BinKind::ForInStatement); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[3] = { BinField::Left, BinField::Right, BinField::Body }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - ParseContext::Statement stmt(parseContext_, StatementKind::ForInLoop); // Implicit scope around the `for`, used to store `for (let x in ...)` @@ -5466,20 +4865,12 @@ BinASTParser::parseInterfaceForInStatement(const size_t start, const BinKin ParseContext::Scope scope(cx_, parseContext_, usedNames_); BINJS_TRY(scope.init(parseContext_)); - BINJS_MOZ_TRY_DECL(left, parseForInOfBindingOrAssignmentTarget()); - - - BINJS_MOZ_TRY_DECL(right, parseExpression()); - - - BINJS_MOZ_TRY_DECL(body, parseStatement()); - BINJS_TRY_DECL(forHead, factory_.newForInOrOfHead(ParseNodeKind::ForIn, left, right, tokenizer_->pos(start))); BINJS_TRY_DECL(result, factory_.newForStatement(start, forHead, body, /*flags*/ 0)); @@ -5555,12 +4946,10 @@ BinASTParser::parseInterfaceForStatement(const size_t start, const BinKind MOZ_ASSERT(kind == BinKind::ForStatement); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[4] = { BinField::Init, BinField::Test, BinField::Update, BinField::Body }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - ParseContext::Statement stmt(parseContext_, StatementKind::ForLoop); // Implicit scope around the `for`, used to store `for (let x; ...; ...)` @@ -5569,25 +4958,14 @@ BinASTParser::parseInterfaceForStatement(const size_t start, const BinKind ParseContext::Scope scope(cx_, parseContext_, usedNames_); BINJS_TRY(scope.init(parseContext_)); - BINJS_MOZ_TRY_DECL(init, parseOptionalVariableDeclarationOrExpression()); - - - BINJS_MOZ_TRY_DECL(test, parseOptionalExpression()); - - - BINJS_MOZ_TRY_DECL(update, parseOptionalExpression()); - - - BINJS_MOZ_TRY_DECL(body, parseStatement()); - BINJS_TRY_DECL(forHead, factory_.newForHead(init, test, update, tokenizer_->pos(start))); BINJS_TRY_DECL(result, factory_.newForStatement(start, forHead, body, /* iflags = */ 0)); @@ -5629,23 +5007,15 @@ BinASTParser::parseInterfaceFormalParameters(const size_t start, const BinK MOZ_ASSERT(kind == BinKind::FormalParameters); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Items, BinField::Rest }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(items, parseListOfParameter()); - - - BINJS_MOZ_TRY_DECL(rest, parseOptionalBinding()); - auto result = items; if (rest) { BINJS_TRY_DECL(spread, factory_.newSpread(start, rest)); @@ -5685,23 +5055,15 @@ BinASTParser::parseInterfaceFunctionBody(const size_t start, const BinKind MOZ_ASSERT(kind == BinKind::FunctionBody); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Directives, BinField::Statements }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(directives, parseListOfDirective()); - - - BINJS_MOZ_TRY_DECL(statements, parseListOfStatement()); - BINJS_MOZ_TRY_DECL(result, appendDirectivesToBody(/* body = */ statements, /* directives = */ directives)); return result; } @@ -5736,18 +5098,14 @@ BinASTParser::parseInterfaceIdentifierExpression(const size_t start, const MOZ_ASSERT(kind == BinKind::IdentifierExpression); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[1] = { BinField::Name }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - RootedAtom name(cx_); MOZ_TRY_VAR(name, tokenizer_->readAtom()); - if (!IsIdentifier(name)) return raiseError("Invalid identifier"); BINJS_TRY(usedNames_.noteUse(cx_, name, parseContext_->scriptId(), parseContext_->innermostScope()->id())); @@ -5787,28 +5145,17 @@ BinASTParser::parseInterfaceIfStatement(const size_t start, const BinKind k MOZ_ASSERT(kind == BinKind::IfStatement); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[3] = { BinField::Test, BinField::Consequent, BinField::Alternate }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(test, parseExpression()); - - - BINJS_MOZ_TRY_DECL(consequent, parseStatement()); - - - BINJS_MOZ_TRY_DECL(alternate, parseOptionalStatement()); - BINJS_TRY_DECL(result, factory_.newIfStatement(start, test, consequent, alternate)); return result; } @@ -5939,25 +5286,18 @@ BinASTParser::parseInterfaceLabelledStatement(const size_t start, const Bin MOZ_ASSERT(kind == BinKind::LabelledStatement); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Label, BinField::Body }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - RootedAtom label(cx_); MOZ_TRY_VAR(label, tokenizer_->readAtom()); if (!IsIdentifier(label)) return raiseError("Invalid identifier"); ParseContext::LabelStatement stmt(parseContext_, label); - - - BINJS_MOZ_TRY_DECL(body, parseStatement()); - BINJS_TRY_DECL(result, factory_.newLabeledStatement(label->asPropertyName(), body, start)); return result; } @@ -5992,18 +5332,13 @@ BinASTParser::parseInterfaceLiteralBooleanExpression(const size_t start, co MOZ_ASSERT(kind == BinKind::LiteralBooleanExpression); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[1] = { BinField::Value }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(value, tokenizer_->readBool()); - BINJS_TRY_DECL(result, factory_.newBooleanLiteral(value, tokenizer_->pos(start))); return result; } @@ -6065,7 +5400,6 @@ BinASTParser::parseInterfaceLiteralNullExpression(const size_t start, const { MOZ_ASSERT(kind == BinKind::LiteralNullExpression); BINJS_TRY(CheckRecursionLimit(cx_)); - MOZ_TRY(tokenizer_->checkFields0(kind, fields)); BINJS_TRY_DECL(result, factory_.newNullLiteral(tokenizer_->pos(start))); @@ -6102,18 +5436,13 @@ BinASTParser::parseInterfaceLiteralNumericExpression(const size_t start, co MOZ_ASSERT(kind == BinKind::LiteralNumericExpression); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[1] = { BinField::Value }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(value, tokenizer_->readDouble()); - BINJS_TRY_DECL(result, factory_.newNumber(value, DecimalPoint::HasDecimal, tokenizer_->pos(start))); return result; } @@ -6148,18 +5477,14 @@ BinASTParser::parseInterfaceLiteralPropertyName(const size_t start, const B MOZ_ASSERT(kind == BinKind::LiteralPropertyName); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[1] = { BinField::Value }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - RootedAtom value(cx_); MOZ_TRY_VAR(value, tokenizer_->readAtom()); - ParseNode* result; uint32_t index; if (value->isIndex(&index)) @@ -6200,17 +5525,13 @@ BinASTParser::parseInterfaceLiteralRegExpExpression(const size_t start, con MOZ_ASSERT(kind == BinKind::LiteralRegExpExpression); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Pattern, BinField::Flags }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - RootedAtom pattern(cx_); MOZ_TRY_VAR(pattern, tokenizer_->readAtom()); - Chars flags(cx_); MOZ_TRY(tokenizer_->readChars(flags)); @@ -6272,18 +5593,14 @@ BinASTParser::parseInterfaceLiteralStringExpression(const size_t start, con MOZ_ASSERT(kind == BinKind::LiteralStringExpression); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[1] = { BinField::Value }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - RootedAtom value(cx_); MOZ_TRY_VAR(value, tokenizer_->readAtom()); - BINJS_TRY_DECL(result, factory_.newStringLiteral(value, tokenizer_->pos(start))); return result; } @@ -6351,23 +5668,15 @@ BinASTParser::parseInterfaceNewExpression(const size_t start, const BinKind MOZ_ASSERT(kind == BinKind::NewExpression); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Callee, BinField::Arguments }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(callee, parseExpression()); - - - BINJS_MOZ_TRY_DECL(arguments, parseArguments()); - auto result = arguments; result->setKind(ParseNodeKind::New); result->prepend(callee); @@ -6494,18 +5803,13 @@ BinASTParser::parseInterfaceObjectExpression(const size_t start, const BinK MOZ_ASSERT(kind == BinKind::ObjectExpression); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[1] = { BinField::Properties }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(properties, parseListOfObjectProperty()); - auto result = properties; return result; } @@ -6540,12 +5844,10 @@ BinASTParser::parseInterfaceReturnStatement(const size_t start, const BinKi MOZ_ASSERT(kind == BinKind::ReturnStatement); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[1] = { BinField::Expression }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - if (!parseContext_->isFunctionBox()) { // Return statements are permitted only inside functions. return raiseInvalidKind("Toplevel Statement", kind); @@ -6553,10 +5855,8 @@ BinASTParser::parseInterfaceReturnStatement(const size_t start, const BinKi parseContext_->functionBox()->usesReturn = true; - BINJS_MOZ_TRY_DECL(expression, parseOptionalExpression()); - BINJS_TRY_DECL(result, factory_.newReturnStatement(expression, tokenizer_->pos(start))); return result; } @@ -6593,28 +5893,17 @@ BinASTParser::parseInterfaceScript(const size_t start, const BinKind kind, MOZ_ASSERT(kind == BinKind::Script); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[3] = { BinField::Scope, BinField::Directives, BinField::Statements }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - MOZ_TRY(parseOptionalAssertedVarScope()); - - - BINJS_MOZ_TRY_DECL(directives, parseListOfDirective()); - - - BINJS_MOZ_TRY_DECL(statements, parseListOfStatement()); - MOZ_TRY(checkClosedVars(parseContext_->varScope())); BINJS_MOZ_TRY_DECL(result, appendDirectivesToBody(/* body = */ statements, /* directives = */ directives)); return result; } @@ -6649,18 +5938,13 @@ BinASTParser::parseInterfaceShorthandProperty(const size_t start, const Bin MOZ_ASSERT(kind == BinKind::ShorthandProperty); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[1] = { BinField::Name }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(name, parseIdentifierExpression()); - if (!factory_.isUsableAsObjectPropertyName(name)) BINJS_TRY_VAR(name, factory_.newObjectLiteralPropertyName(name->name(), tokenizer_->pos(start))); @@ -6909,23 +6193,16 @@ BinASTParser::parseInterfaceStaticMemberAssignmentTarget(const size_t start MOZ_ASSERT(kind == BinKind::StaticMemberAssignmentTarget); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Object, BinField::Property }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(object, parseExpressionOrSuper()); - - RootedAtom property(cx_); MOZ_TRY_VAR(property, tokenizer_->readAtom()); - BINJS_TRY_DECL(result, factory_.newPropertyAccess(object, property->asPropertyName(), start)); return result; } @@ -6961,23 +6238,16 @@ BinASTParser::parseInterfaceStaticMemberExpression(const size_t start, cons MOZ_ASSERT(kind == BinKind::StaticMemberExpression); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Object, BinField::Property }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(object, parseExpressionOrSuper()); - - RootedAtom property(cx_); MOZ_TRY_VAR(property, tokenizer_->readAtom()); - BINJS_TRY_DECL(result, factory_.newPropertyAccess(object, property->asPropertyName(), start)); return result; } @@ -7042,23 +6312,15 @@ BinASTParser::parseInterfaceSwitchCase(const size_t start, const BinKind ki MOZ_ASSERT(kind == BinKind::SwitchCase); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Test, BinField::Consequent }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(test, parseExpression()); - - - BINJS_MOZ_TRY_DECL(consequent, parseListOfStatement()); - BINJS_TRY_DECL(result, factory_.newCaseOrDefault(start, test, consequent)); return result; } @@ -7093,18 +6355,13 @@ BinASTParser::parseInterfaceSwitchDefault(const size_t start, const BinKind MOZ_ASSERT(kind == BinKind::SwitchDefault); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[1] = { BinField::Consequent }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(consequent, parseListOfStatement()); - BINJS_TRY_DECL(result, factory_.newCaseOrDefault(start, nullptr, consequent)); return result; } @@ -7140,23 +6397,15 @@ BinASTParser::parseInterfaceSwitchStatement(const size_t start, const BinKi MOZ_ASSERT(kind == BinKind::SwitchStatement); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Discriminant, BinField::Cases }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(discriminant, parseExpression()); - - - BINJS_MOZ_TRY_DECL(cases, parseListOfSwitchCase()); - BINJS_TRY_DECL(scope, factory_.newLexicalScope(nullptr, cases)); BINJS_TRY_DECL(result, factory_.newSwitchStatement(start, discriminant, scope)); return result; @@ -7195,33 +6444,19 @@ BinASTParser::parseInterfaceSwitchStatementWithDefault(const size_t start, MOZ_ASSERT(kind == BinKind::SwitchStatementWithDefault); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[4] = { BinField::Discriminant, BinField::PreDefaultCases, BinField::DefaultCase, BinField::PostDefaultCases }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(discriminant, parseExpression()); - - - BINJS_MOZ_TRY_DECL(preDefaultCases, parseListOfSwitchCase()); - - - BINJS_MOZ_TRY_DECL(defaultCase, parseSwitchDefault()); - - - BINJS_MOZ_TRY_DECL(postDefaultCases, parseListOfSwitchCase()); - // Concatenate `preDefaultCase`, `defaultCase`, `postDefaultCase` auto cases = preDefaultCases; factory_.addList(cases, defaultCase); @@ -7325,7 +6560,6 @@ BinASTParser::parseInterfaceThisExpression(const size_t start, const BinKin { MOZ_ASSERT(kind == BinKind::ThisExpression); BINJS_TRY(CheckRecursionLimit(cx_)); - MOZ_TRY(tokenizer_->checkFields0(kind, fields)); if (parseContext_->isFunctionBox()) @@ -7373,18 +6607,13 @@ BinASTParser::parseInterfaceThrowStatement(const size_t start, const BinKin MOZ_ASSERT(kind == BinKind::ThrowStatement); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[1] = { BinField::Expression }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(expression, parseExpression()); - BINJS_TRY_DECL(result, factory_.newThrowStatement(expression, tokenizer_->pos(start))); return result; } @@ -7420,13 +6649,10 @@ BinASTParser::parseInterfaceTryCatchStatement(const size_t start, const Bin MOZ_ASSERT(kind == BinKind::TryCatchStatement); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Body, BinField::CatchClause }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - ParseNode* body; { ParseContext::Statement stmt(parseContext_, StatementKind::Try); @@ -7436,11 +6662,8 @@ BinASTParser::parseInterfaceTryCatchStatement(const size_t start, const Bin } - - BINJS_MOZ_TRY_DECL(catchClause, parseCatchClause()); - BINJS_TRY_DECL(result, factory_.newTryStatement(start, body, catchClause, /* finally = */ nullptr)); return result; } @@ -7477,13 +6700,10 @@ BinASTParser::parseInterfaceTryFinallyStatement(const size_t start, const B MOZ_ASSERT(kind == BinKind::TryFinallyStatement); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[3] = { BinField::Body, BinField::CatchClause, BinField::Finalizer }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - ParseNode* body; { ParseContext::Statement stmt(parseContext_, StatementKind::Try); @@ -7493,11 +6713,7 @@ BinASTParser::parseInterfaceTryFinallyStatement(const size_t start, const B } - - BINJS_MOZ_TRY_DECL(catchClause, parseOptionalCatchClause()); - - ParseNode* finalizer; { ParseContext::Statement stmt(parseContext_, StatementKind::Finally); @@ -7542,23 +6758,15 @@ BinASTParser::parseInterfaceUnaryExpression(const size_t start, const BinKi MOZ_ASSERT(kind == BinKind::UnaryExpression); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Operator, BinField::Operand }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(operator_, parseUnaryOperator()); - - - BINJS_MOZ_TRY_DECL(operand, parseExpression()); - ParseNodeKind pnk; switch (operator_) { case UnaryOperator::Minus: @@ -7637,28 +6845,17 @@ BinASTParser::parseInterfaceUpdateExpression(const size_t start, const BinK MOZ_ASSERT(kind == BinKind::UpdateExpression); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[3] = { BinField::IsPrefix, BinField::Operator, BinField::Operand }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(isPrefix, tokenizer_->readBool()); - - - BINJS_MOZ_TRY_DECL(operator_, parseUpdateOperator()); - - - BINJS_MOZ_TRY_DECL(operand, parseSimpleAssignmentTarget()); - ParseNodeKind pnk; switch (operator_) { case UpdateOperator::Incr: @@ -7705,24 +6902,17 @@ BinASTParser::parseInterfaceVariableDeclaration(const size_t start, const B MOZ_ASSERT(kind == BinKind::VariableDeclaration); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Kind, BinField::Declarators }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - AutoVariableDeclarationKind kindGuard(this); - BINJS_MOZ_TRY_DECL(kind_, parseVariableDeclarationKind()); // Restored by `kindGuard`. variableDeclarationKind_ = kind_; - - - BINJS_MOZ_TRY_DECL(declarators, parseListOfVariableDeclarator()); - // By specification, the list may not be empty. if (declarators->pn_count == 0) return raiseEmpty("VariableDeclaration"); @@ -7775,23 +6965,15 @@ BinASTParser::parseInterfaceVariableDeclarator(const size_t start, const Bi MOZ_ASSERT(kind == BinKind::VariableDeclarator); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Binding, BinField::Init }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(binding, parseBinding()); - - - BINJS_MOZ_TRY_DECL(init, parseOptionalExpression()); - ParseNode* result; if (binding->isKind(ParseNodeKind::Name)) { // `var foo [= bar]`` @@ -7844,23 +7026,16 @@ BinASTParser::parseInterfaceWhileStatement(const size_t start, const BinKin MOZ_ASSERT(kind == BinKind::WhileStatement); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Test, BinField::Body }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - ParseContext::Statement stmt(parseContext_, StatementKind::WhileLoop); - BINJS_MOZ_TRY_DECL(test, parseExpression()); - - - BINJS_MOZ_TRY_DECL(body, parseStatement()); - BINJS_TRY_DECL(result, factory_.newWhileStatement(start, test, body)); return result; } @@ -7896,23 +7071,15 @@ BinASTParser::parseInterfaceWithStatement(const size_t start, const BinKind MOZ_ASSERT(kind == BinKind::WithStatement); BINJS_TRY(CheckRecursionLimit(cx_)); - #if defined(DEBUG) const BinField expected_fields[2] = { BinField::Object, BinField::Body }; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); #endif // defined(DEBUG) - - - BINJS_MOZ_TRY_DECL(object, parseExpression()); - - - BINJS_MOZ_TRY_DECL(body, parseStatement()); - BINJS_TRY_DECL(result, factory_.newWithStatement(start, object, body)); return result; } diff --git a/js/src/frontend/binsource/src/main.rs b/js/src/frontend/binsource/src/main.rs index 8198c15c0a4b..a0de4e7fdc5b 100644 --- a/js/src/frontend/binsource/src/main.rs +++ b/js/src/frontend/binsource/src/main.rs @@ -19,6 +19,22 @@ use clap::{ App, Arg }; use itertools::Itertools; +/// A string or string-like construction that can be appended newline. +trait NewLineIfNotEmpty { + /// Append newline if the string is not empty. + fn newline_if_not_empty(&self) -> String; +} +impl NewLineIfNotEmpty for T where T: ToStr { + fn newline_if_not_empty(&self) -> String { + let str = self.to_str(); + if str.len() == 0 { + "".to_string() + } else { + format!("{}\n", str) + } + } +} + /// Rules for generating the code for parsing a single field /// of a node. /// @@ -735,13 +751,13 @@ impl CPPExporter { buffer_cases.push_str(&format!(" case BinKind::{variant_name}: MOZ_TRY_VAR(result, parseInterface{class_name}(start, kind, fields)); -{arm_after} - break;", +{arm_after} break;", class_name = node.to_class_cases(), variant_name = node.to_cpp_enum_case(), arm_after = rules_for_this_sum.by_sum.get(&node) .cloned() - .unwrap_or_default().after_arm.reindent(" "))); + .unwrap_or_default().after_arm.reindent(" ") + .newline_if_not_empty())); } buffer.push_str(&format!("\n{first_line} {{ @@ -1120,32 +1136,24 @@ impl CPPExporter { }; if needs_block { let parse_var = parse_var.reindent(" "); - format!("{before_field} -{decl_var} - {{ -{block_before_field} -{parse_var} -{block_after_field} + format!("{before_field}{decl_var} {{ +{block_before_field}{parse_var}{block_after_field} }} {after_field}", - before_field = before_field.reindent(" "), - decl_var = decl_var.reindent(" "), - parse_var = parse_var.reindent(" "), - after_field = after_field.reindent(" "), - block_before_field = rules_for_this_field.block_before_field.reindent(" "), - block_after_field = rules_for_this_field.block_after_field.reindent(" ")) + before_field = before_field.reindent(" ").newline_if_not_empty(), + decl_var = decl_var.reindent(" ").newline_if_not_empty(), + block_before_field = rules_for_this_field.block_before_field.reindent(" ").newline_if_not_empty(), + parse_var = parse_var.reindent(" ").newline_if_not_empty(), + block_after_field = rules_for_this_field.block_after_field.reindent(" "), + after_field = after_field.reindent(" ")) } else { // We have a before_field and an after_field. This will create newlines // for them. format!(" -{before_field} -{decl_var} -{parse_var} -{after_field} -", - before_field = before_field.reindent(" "), - decl_var = decl_var.reindent(" "), - parse_var = parse_var.reindent(" "), +{before_field}{decl_var}{parse_var}{after_field}", + before_field = before_field.reindent(" ").newline_if_not_empty(), + decl_var = decl_var.reindent(" ").newline_if_not_empty(), + parse_var = parse_var.reindent(" ").newline_if_not_empty(), after_field = after_field.reindent(" ")) } } @@ -1175,8 +1183,7 @@ impl CPPExporter { #if defined(DEBUG) const BinField expected_fields[{number_of_fields}] = {fields_type_list}; MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields)); -#endif // defined(DEBUG) -", +#endif // defined(DEBUG)", fields_type_list = fields_type_list, number_of_fields = number_of_fields) }; @@ -1184,18 +1191,16 @@ impl CPPExporter { {{ MOZ_ASSERT(kind == BinKind::{kind}); BINJS_TRY(CheckRecursionLimit(cx_)); - {check_fields} {pre}{fields_implem} -{post} - return result; +{post} return result; }} ", check_fields = check_fields, fields_implem = fields_implem, - pre = init, - post = build_result, + pre = init.newline_if_not_empty(), + post = build_result.newline_if_not_empty(), kind = name.to_cpp_enum_case(), first_line = first_line, ));