зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1524507 - Remove sum interface and typedef from BinToken.h. r=Yoric
Differential Revision: https://phabricator.services.mozilla.com/D19726 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
ba67293ef7
Коммит
6dd524af5b
|
@ -61,11 +61,9 @@ namespace frontend {
|
|||
*/
|
||||
#define FOR_EACH_BIN_KIND(F) \
|
||||
F(_Null, "") \
|
||||
F(Arguments, "Arguments") \
|
||||
F(ArrayAssignmentTarget, "ArrayAssignmentTarget") \
|
||||
F(ArrayBinding, "ArrayBinding") \
|
||||
F(ArrayExpression, "ArrayExpression") \
|
||||
F(ArrowExpression, "ArrowExpression") \
|
||||
F(ArrowExpressionContentsWithExpression, \
|
||||
"ArrowExpressionContentsWithExpression") \
|
||||
F(ArrowExpressionContentsWithFunctionBody, \
|
||||
|
@ -73,10 +71,7 @@ namespace frontend {
|
|||
F(AssertedBlockScope, "AssertedBlockScope") \
|
||||
F(AssertedBoundName, "AssertedBoundName") \
|
||||
F(AssertedBoundNamesScope, "AssertedBoundNamesScope") \
|
||||
F(AssertedDeclaredKind, "AssertedDeclaredKind") \
|
||||
F(AssertedDeclaredName, "AssertedDeclaredName") \
|
||||
F(AssertedMaybePositionalParameterName, \
|
||||
"AssertedMaybePositionalParameterName") \
|
||||
F(AssertedParameterName, "AssertedParameterName") \
|
||||
F(AssertedParameterScope, "AssertedParameterScope") \
|
||||
F(AssertedPositionalParameterName, "AssertedPositionalParameterName") \
|
||||
|
@ -84,23 +79,13 @@ namespace frontend {
|
|||
F(AssertedScriptGlobalScope, "AssertedScriptGlobalScope") \
|
||||
F(AssertedVarScope, "AssertedVarScope") \
|
||||
F(AssignmentExpression, "AssignmentExpression") \
|
||||
F(AssignmentTarget, "AssignmentTarget") \
|
||||
F(AssignmentTargetIdentifier, "AssignmentTargetIdentifier") \
|
||||
F(AssignmentTargetOrAssignmentTargetWithInitializer, \
|
||||
"AssignmentTargetOrAssignmentTargetWithInitializer") \
|
||||
F(AssignmentTargetPattern, "AssignmentTargetPattern") \
|
||||
F(AssignmentTargetProperty, "AssignmentTargetProperty") \
|
||||
F(AssignmentTargetPropertyIdentifier, "AssignmentTargetPropertyIdentifier") \
|
||||
F(AssignmentTargetPropertyProperty, "AssignmentTargetPropertyProperty") \
|
||||
F(AssignmentTargetWithInitializer, "AssignmentTargetWithInitializer") \
|
||||
F(AwaitExpression, "AwaitExpression") \
|
||||
F(BinaryExpression, "BinaryExpression") \
|
||||
F(BinaryOperator, "BinaryOperator") \
|
||||
F(Binding, "Binding") \
|
||||
F(BindingIdentifier, "BindingIdentifier") \
|
||||
F(BindingOrBindingWithInitializer, "BindingOrBindingWithInitializer") \
|
||||
F(BindingPattern, "BindingPattern") \
|
||||
F(BindingProperty, "BindingProperty") \
|
||||
F(BindingPropertyIdentifier, "BindingPropertyIdentifier") \
|
||||
F(BindingPropertyProperty, "BindingPropertyProperty") \
|
||||
F(BindingWithInitializer, "BindingWithInitializer") \
|
||||
|
@ -112,7 +97,6 @@ namespace frontend {
|
|||
F(ClassElement, "ClassElement") \
|
||||
F(ClassExpression, "ClassExpression") \
|
||||
F(CompoundAssignmentExpression, "CompoundAssignmentExpression") \
|
||||
F(CompoundAssignmentOperator, "CompoundAssignmentOperator") \
|
||||
F(ComputedMemberAssignmentTarget, "ComputedMemberAssignmentTarget") \
|
||||
F(ComputedMemberExpression, "ComputedMemberExpression") \
|
||||
F(ComputedPropertyName, "ComputedPropertyName") \
|
||||
|
@ -133,45 +117,25 @@ namespace frontend {
|
|||
F(EmptyStatement, "EmptyStatement") \
|
||||
F(Export, "Export") \
|
||||
F(ExportAllFrom, "ExportAllFrom") \
|
||||
F(ExportDeclaration, "ExportDeclaration") \
|
||||
F(ExportDefault, "ExportDefault") \
|
||||
F(ExportFrom, "ExportFrom") \
|
||||
F(ExportFromSpecifier, "ExportFromSpecifier") \
|
||||
F(ExportLocalSpecifier, "ExportLocalSpecifier") \
|
||||
F(ExportLocals, "ExportLocals") \
|
||||
F(Expression, "Expression") \
|
||||
F(ExpressionOrSuper, "ExpressionOrSuper") \
|
||||
F(ExpressionOrTemplateElement, "ExpressionOrTemplateElement") \
|
||||
F(ExpressionStatement, "ExpressionStatement") \
|
||||
F(ForInOfBinding, "ForInOfBinding") \
|
||||
F(ForInOfBindingOrAssignmentTarget, "ForInOfBindingOrAssignmentTarget") \
|
||||
F(ForInStatement, "ForInStatement") \
|
||||
F(ForOfStatement, "ForOfStatement") \
|
||||
F(ForStatement, "ForStatement") \
|
||||
F(FormalParameters, "FormalParameters") \
|
||||
F(FunctionBody, "FunctionBody") \
|
||||
F(FunctionDeclaration, "FunctionDeclaration") \
|
||||
F(FunctionDeclarationOrClassDeclarationOrExpression, \
|
||||
"FunctionDeclarationOrClassDeclarationOrExpression") \
|
||||
F(FunctionDeclarationOrClassDeclarationOrVariableDeclaration, \
|
||||
"FunctionDeclarationOrClassDeclarationOrVariableDeclaration") \
|
||||
F(FunctionExpression, "FunctionExpression") \
|
||||
F(FunctionExpressionContents, "FunctionExpressionContents") \
|
||||
F(FunctionOrMethodContents, "FunctionOrMethodContents") \
|
||||
F(Getter, "Getter") \
|
||||
F(GetterContents, "GetterContents") \
|
||||
F(Identifier, "Identifier") \
|
||||
F(IdentifierExpression, "IdentifierExpression") \
|
||||
F(IdentifierName, "IdentifierName") \
|
||||
F(IfStatement, "IfStatement") \
|
||||
F(Import, "Import") \
|
||||
F(ImportDeclaration, "ImportDeclaration") \
|
||||
F(ImportDeclarationOrExportDeclarationOrStatement, \
|
||||
"ImportDeclarationOrExportDeclarationOrStatement") \
|
||||
F(ImportNamespace, "ImportNamespace") \
|
||||
F(ImportSpecifier, "ImportSpecifier") \
|
||||
F(IterationStatement, "IterationStatement") \
|
||||
F(Label, "Label") \
|
||||
F(LabelledStatement, "LabelledStatement") \
|
||||
F(LazyArrowExpressionWithExpression, "LazyArrowExpressionWithExpression") \
|
||||
F(LazyArrowExpressionWithFunctionBody, \
|
||||
|
@ -181,32 +145,6 @@ namespace frontend {
|
|||
F(LazyGetter, "LazyGetter") \
|
||||
F(LazyMethod, "LazyMethod") \
|
||||
F(LazySetter, "LazySetter") \
|
||||
F(ListOfAssertedBoundName, "ListOfAssertedBoundName") \
|
||||
F(ListOfAssertedDeclaredName, "ListOfAssertedDeclaredName") \
|
||||
F(ListOfAssertedMaybePositionalParameterName, \
|
||||
"ListOfAssertedMaybePositionalParameterName") \
|
||||
F(ListOfAssignmentTargetOrAssignmentTargetWithInitializer, \
|
||||
"ListOfAssignmentTargetOrAssignmentTargetWithInitializer") \
|
||||
F(ListOfAssignmentTargetProperty, "ListOfAssignmentTargetProperty") \
|
||||
F(ListOfBindingProperty, "ListOfBindingProperty") \
|
||||
F(ListOfClassElement, "ListOfClassElement") \
|
||||
F(ListOfDirective, "ListOfDirective") \
|
||||
F(ListOfExportFromSpecifier, "ListOfExportFromSpecifier") \
|
||||
F(ListOfExportLocalSpecifier, "ListOfExportLocalSpecifier") \
|
||||
F(ListOfExpressionOrTemplateElement, "ListOfExpressionOrTemplateElement") \
|
||||
F(ListOfImportDeclarationOrExportDeclarationOrStatement, \
|
||||
"ListOfImportDeclarationOrExportDeclarationOrStatement") \
|
||||
F(ListOfImportSpecifier, "ListOfImportSpecifier") \
|
||||
F(ListOfObjectProperty, "ListOfObjectProperty") \
|
||||
F(ListOfOptionalBindingOrBindingWithInitializer, \
|
||||
"ListOfOptionalBindingOrBindingWithInitializer") \
|
||||
F(ListOfOptionalSpreadElementOrExpression, \
|
||||
"ListOfOptionalSpreadElementOrExpression") \
|
||||
F(ListOfParameter, "ListOfParameter") \
|
||||
F(ListOfStatement, "ListOfStatement") \
|
||||
F(ListOfSwitchCase, "ListOfSwitchCase") \
|
||||
F(ListOfVariableDeclarator, "ListOfVariableDeclarator") \
|
||||
F(Literal, "Literal") \
|
||||
F(LiteralBooleanExpression, "LiteralBooleanExpression") \
|
||||
F(LiteralInfinityExpression, "LiteralInfinityExpression") \
|
||||
F(LiteralNullExpression, "LiteralNullExpression") \
|
||||
|
@ -214,42 +152,17 @@ namespace frontend {
|
|||
F(LiteralPropertyName, "LiteralPropertyName") \
|
||||
F(LiteralRegExpExpression, "LiteralRegExpExpression") \
|
||||
F(LiteralStringExpression, "LiteralStringExpression") \
|
||||
F(Method, "Method") \
|
||||
F(MethodDefinition, "MethodDefinition") \
|
||||
F(Module, "Module") \
|
||||
F(NewExpression, "NewExpression") \
|
||||
F(NewTargetExpression, "NewTargetExpression") \
|
||||
F(ObjectAssignmentTarget, "ObjectAssignmentTarget") \
|
||||
F(ObjectBinding, "ObjectBinding") \
|
||||
F(ObjectExpression, "ObjectExpression") \
|
||||
F(ObjectProperty, "ObjectProperty") \
|
||||
F(OptionalAssignmentTarget, "OptionalAssignmentTarget") \
|
||||
F(OptionalBinding, "OptionalBinding") \
|
||||
F(OptionalBindingIdentifier, "OptionalBindingIdentifier") \
|
||||
F(OptionalBindingOrBindingWithInitializer, \
|
||||
"OptionalBindingOrBindingWithInitializer") \
|
||||
F(OptionalCatchClause, "OptionalCatchClause") \
|
||||
F(OptionalExpression, "OptionalExpression") \
|
||||
F(OptionalIdentifierName, "OptionalIdentifierName") \
|
||||
F(OptionalLabel, "OptionalLabel") \
|
||||
F(OptionalPropertyKey, "OptionalPropertyKey") \
|
||||
F(OptionalSpreadElementOrExpression, "OptionalSpreadElementOrExpression") \
|
||||
F(OptionalStatement, "OptionalStatement") \
|
||||
F(OptionalVariableDeclarationOrExpression, \
|
||||
"OptionalVariableDeclarationOrExpression") \
|
||||
F(Parameter, "Parameter") \
|
||||
F(Program, "Program") \
|
||||
F(PropertyKey, "PropertyKey") \
|
||||
F(PropertyName, "PropertyName") \
|
||||
F(ReturnStatement, "ReturnStatement") \
|
||||
F(Script, "Script") \
|
||||
F(Setter, "Setter") \
|
||||
F(SetterContents, "SetterContents") \
|
||||
F(ShorthandProperty, "ShorthandProperty") \
|
||||
F(SimpleAssignmentTarget, "SimpleAssignmentTarget") \
|
||||
F(SpreadElement, "SpreadElement") \
|
||||
F(SpreadElementOrExpression, "SpreadElementOrExpression") \
|
||||
F(Statement, "Statement") \
|
||||
F(StaticMemberAssignmentTarget, "StaticMemberAssignmentTarget") \
|
||||
F(StaticMemberExpression, "StaticMemberExpression") \
|
||||
F(Super, "Super") \
|
||||
|
@ -264,18 +177,13 @@ namespace frontend {
|
|||
F(TryCatchStatement, "TryCatchStatement") \
|
||||
F(TryFinallyStatement, "TryFinallyStatement") \
|
||||
F(UnaryExpression, "UnaryExpression") \
|
||||
F(UnaryOperator, "UnaryOperator") \
|
||||
F(UpdateExpression, "UpdateExpression") \
|
||||
F(UpdateOperator, "UpdateOperator") \
|
||||
F(VariableDeclaration, "VariableDeclaration") \
|
||||
F(VariableDeclarationKind, "VariableDeclarationKind") \
|
||||
F(VariableDeclarationOrExpression, "VariableDeclarationOrExpression") \
|
||||
F(VariableDeclarator, "VariableDeclarator") \
|
||||
F(WhileStatement, "WhileStatement") \
|
||||
F(WithStatement, "WithStatement") \
|
||||
F(YieldExpression, "YieldExpression") \
|
||||
F(YieldStarExpression, "YieldStarExpression") \
|
||||
F(String, "string")
|
||||
F(YieldStarExpression, "YieldStarExpression")
|
||||
|
||||
enum class BinKind {
|
||||
#define EMIT_ENUM(name, _) name,
|
||||
|
@ -284,7 +192,7 @@ enum class BinKind {
|
|||
};
|
||||
|
||||
// The number of distinct values of BinKind.
|
||||
const size_t BINKIND_LIMIT = 200;
|
||||
const size_t BINKIND_LIMIT = 120;
|
||||
|
||||
/**
|
||||
* The different fields of Binary AST nodes, as per the specifications of
|
||||
|
|
|
@ -933,9 +933,11 @@ impl CPPExporter {
|
|||
buffer.push_str(&self.rules.hpp_tokens_kind_doc.reindent(""));
|
||||
}
|
||||
|
||||
let node_names = self.syntax.node_names()
|
||||
let node_names = self.syntax.interfaces_by_name()
|
||||
.keys()
|
||||
.map(|n| n.to_string())
|
||||
.sorted();
|
||||
let kind_limit = node_names.len();
|
||||
buffer.push_str(&format!("\n#define FOR_EACH_BIN_KIND(F) \\\n{nodes}\n",
|
||||
nodes = node_names.iter()
|
||||
.map(|name| format!(" F({enum_name}, \"{spec_name}\")",
|
||||
|
@ -950,7 +952,7 @@ enum class BinKind {
|
|||
};
|
||||
");
|
||||
|
||||
buffer.push_str(&format!("\n// The number of distinct values of BinKind.\nconst size_t BINKIND_LIMIT = {};\n\n\n", self.syntax.node_names().len()));
|
||||
buffer.push_str(&format!("\n// The number of distinct values of BinKind.\nconst size_t BINKIND_LIMIT = {};\n\n\n", kind_limit));
|
||||
buffer.push_str("\n\n");
|
||||
if self.rules.hpp_tokens_field_doc.is_some() {
|
||||
buffer.push_str(&self.rules.hpp_tokens_field_doc.reindent(""));
|
||||
|
@ -959,6 +961,7 @@ enum class BinKind {
|
|||
let field_names = self.syntax.field_names()
|
||||
.keys()
|
||||
.sorted();
|
||||
let field_limit = field_names.len();
|
||||
buffer.push_str(&format!("\n#define FOR_EACH_BIN_FIELD(F) \\\n{nodes}\n",
|
||||
nodes = field_names.iter()
|
||||
.map(|name| format!(" F({enum_name}, \"{spec_name}\")",
|
||||
|
@ -972,7 +975,7 @@ enum class BinField {
|
|||
#undef EMIT_ENUM
|
||||
};
|
||||
");
|
||||
buffer.push_str(&format!("\n// The number of distinct values of BinField.\nconst size_t BINFIELD_LIMIT = {};\n\n\n", self.syntax.field_names().len()));
|
||||
buffer.push_str(&format!("\n// The number of distinct values of BinField.\nconst size_t BINFIELD_LIMIT = {};\n\n\n", field_limit));
|
||||
|
||||
if self.rules.hpp_tokens_variants_doc.is_some() {
|
||||
buffer.push_str(&self.rules.hpp_tokens_variants_doc.reindent(""));
|
||||
|
@ -983,6 +986,7 @@ enum class BinField {
|
|||
Ord::cmp(name_1, name_2)
|
||||
.then_with(|| Ord::cmp(symbol_1, symbol_2))
|
||||
});
|
||||
let variants_limit = enum_variants.len();
|
||||
|
||||
buffer.push_str(&format!("\n#define FOR_EACH_BIN_VARIANT(F) \\\n{nodes}\n",
|
||||
nodes = enum_variants.into_iter()
|
||||
|
@ -999,7 +1003,7 @@ enum class BinVariant {
|
|||
};
|
||||
");
|
||||
buffer.push_str(&format!("\n// The number of distinct values of BinVariant.\nconst size_t BINVARIANT_LIMIT = {};\n\n\n",
|
||||
self.variants_by_symbol.len()));
|
||||
variants_limit));
|
||||
|
||||
buffer.push_str(&self.rules.hpp_tokens_footer.reindent(""));
|
||||
buffer.push_str("\n");
|
||||
|
|
Загрузка…
Ссылка в новой задаче