Bug 1437004 - Porting BinAST to AST v3;r=arai,jorendorff

This patch is a nearly complete reimplementation of BinASTReader, with the following changes:

- Files BinToken.h, BinSource-auto.h (new), BinSource-auto.cpp (new) are now autogenerated by the generator in js/src/frontend/binsouce from the webidl specifications of BinAST and a small
configuration file.
- Optional fields have been removed. Rather, some specific fields may, if so marked in the specifications, contain a Null constant.
- `hasDirectEval` is now checked for consistency (NOT completeness).
- `varDeclaredNames` is now checked for consistency (NOT completeness).
- `lexicallyDeclaredNames` is now checked for consistency (NOT completeness).
- `parameterNames` is now checked for consistency (NOT completeness).
- `capturedNames` is NOT checked.
- Atoms read are now properly expected to be UTF8.

This patch does not implement the entire specifications, but should implement most of ES5. In particular, it is sufficient to parse the source code of:
- Facebook;
- jQuery;
- mootools;
- Underscore;
- Backbone;
- Angular.

MozReview-Commit-ID: HwkVB5dliZv

--HG--
extra : rebase_source : fd7e068343e2af8926c5185e7199ea110a5149bc
This commit is contained in:
David Teller 2018-02-21 17:07:03 +01:00
parent f4523820b7
commit 14b9afe8c3
9 changed files with 10022 additions and 2251 deletions

View File

@ -113,6 +113,7 @@ included_inclnames_to_ignore = set([
# ignore #includes of them when checking #include ordering.
oddly_ordered_inclnames = set([
'ctypes/typedefs.h', # Included multiple times in the body of ctypes/CTypes.h
'frontend/BinSource-auto.h', # Included in the body of frontend/BinSource.h
'frontend/ReservedWordsGenerated.h', # Included in the body of frontend/TokenStream.h
'gc/StatsPhasesGenerated.h', # Included in the body of gc/Statistics.h
'gc/StatsPhasesGenerated.cpp', # Included in the body of gc/Statistics.cpp

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -39,9 +39,10 @@ class BinASTParser;
*/
class BinASTParser : private JS::AutoGCRooter, public ErrorReporter
{
using Names = JS::GCVector<JSString*, 8>;
using Tokenizer = BinTokenReaderTester;
using BinFields = Tokenizer::BinFields;
using Chars = Tokenizer::Chars;
using Names = JS::GCVector<JSString*, 8>;
public:
BinASTParser(JSContext* cx, LifoAlloc& alloc, UsedNameTracker& usedNames, const JS::ReadOnlyCompileOptions& options)
@ -92,87 +93,63 @@ class BinASTParser : private JS::AutoGCRooter, public ErrorReporter
//
// These methods return a (failed) JS::Result for convenience.
MOZ_MUST_USE mozilla::GenericErrorResult<JS::Error&> raiseInvalidKind(const char* superKind, const BinKind kind);
MOZ_MUST_USE mozilla::GenericErrorResult<JS::Error&> raiseInvalidField(const char* kind, const BinField field);
MOZ_MUST_USE mozilla::GenericErrorResult<JS::Error&> raiseInvalidEnum(const char* kind, const Chars& value);
MOZ_MUST_USE mozilla::GenericErrorResult<JS::Error&> raiseMissingField(const char* kind, const BinField field);
MOZ_MUST_USE mozilla::GenericErrorResult<JS::Error&> raiseMissingVariableInAssertedScope(JSAtom* name);
MOZ_MUST_USE mozilla::GenericErrorResult<JS::Error&> raiseMissingDirectEvalInAssertedScope();
MOZ_MUST_USE mozilla::GenericErrorResult<JS::Error&> raiseInvalidKind(const char* superKind,
const BinKind kind);
MOZ_MUST_USE mozilla::GenericErrorResult<JS::Error&> raiseInvalidField(const char* kind,
const BinField field);
MOZ_MUST_USE mozilla::GenericErrorResult<JS::Error&> raiseInvalidNumberOfFields(
const BinKind kind, const uint32_t expected, const uint32_t got);
MOZ_MUST_USE mozilla::GenericErrorResult<JS::Error&> raiseInvalidEnum(const char* kind,
const Chars& value);
MOZ_MUST_USE mozilla::GenericErrorResult<JS::Error&> raiseMissingField(const char* kind,
const BinField field);
MOZ_MUST_USE mozilla::GenericErrorResult<JS::Error&> raiseEmpty(const char* description);
MOZ_MUST_USE mozilla::GenericErrorResult<JS::Error&> raiseOOM();
MOZ_MUST_USE mozilla::GenericErrorResult<JS::Error&> raiseError(const char* description);
MOZ_MUST_USE mozilla::GenericErrorResult<JS::Error&> raiseError(BinKind kind, const char* description);
MOZ_MUST_USE mozilla::GenericErrorResult<JS::Error&> raiseError(BinKind kind,
const char* description);
// Ensure that this parser will never be used again.
void poison();
// --- Parse full nodes (methods are sorted by alphabetical order)
//
// These method may NEVER return `nullptr`. // FIXME: We can probably optimize Result<> based on this.
// Auto-generated methods
#include "frontend/BinSource-auto.h"
MOZ_MUST_USE JS::Result<ParseNode*> parseBlockStatement();
MOZ_MUST_USE JS::Result<ParseNode*> parseCatchClause();
MOZ_MUST_USE JS::Result<ParseNode*> parseExpression();
MOZ_MUST_USE JS::Result<ParseNode*> parseForInit();
MOZ_MUST_USE JS::Result<ParseNode*> parseForInInit();
MOZ_MUST_USE JS::Result<ParseNode*> parseIdentifier();
MOZ_MUST_USE JS::Result<ParseNode*> parseObjectPropertyName();
MOZ_MUST_USE JS::Result<ParseNode*> parseObjectMember();
MOZ_MUST_USE JS::Result<ParseNode*> parsePattern(); // Parse a *binding* pattern.
MOZ_MUST_USE JS::Result<ParseNode*> parsePropertyName();
MOZ_MUST_USE JS::Result<ParseNode*> parseProgram();
MOZ_MUST_USE JS::Result<ParseNode*> parseStatement();
MOZ_MUST_USE JS::Result<ParseNode*> parseSwitchCase();
MOZ_MUST_USE JS::Result<ParseNode*> parseVariableDeclarator();
// --- Auxiliary parsing functions
template<size_t N>
JS::Result<Ok, JS::Error&>
checkFields(const BinKind kind, const BinFields& actual, const BinField (&expected)[N]);
JS::Result<Ok, JS::Error&>
checkFields0(const BinKind kind, const BinFields& actual);
JS::Result<ParseNode*>
buildFunction(const size_t start, const BinKind kind, ParseNode* name, ParseNode* params,
ParseNode* body, FunctionBox* funbox);
JS::Result<FunctionBox*>
buildFunctionBox(GeneratorKind generatorKind, FunctionAsyncKind functionAsyncKind);
// --- Parse lists of nodes (methods are sorted by alphabetical order)
MOZ_MUST_USE JS::Result<ParseNode*> parseArgumentList();
MOZ_MUST_USE JS::Result<ParseNode*> parseDirectiveList();
MOZ_MUST_USE JS::Result<ParseNode*> parseExpressionList(bool acceptElisions);
// Returns a list of PNK_COLON.
MOZ_MUST_USE JS::Result<ParseNode*> parseObjectMemberList();
MOZ_MUST_USE JS::Result<ParseNode*> parseStatementList();
MOZ_MUST_USE JS::Result<ParseNode*> parseSwitchCaseList();
// --- Parse the contents of a node whose kind has already been determined.
MOZ_MUST_USE JS::Result<ParseNode*> parseArrayExpressionAux(const BinKind kind, const Tokenizer::BinFields& fields);
MOZ_MUST_USE JS::Result<ParseNode*> parseBreakOrContinueStatementAux(const BinKind kind, const Tokenizer::BinFields& fields);
MOZ_MUST_USE JS::Result<ParseNode*> parseBlockStatementAux(const BinKind kind, const Tokenizer::BinFields& fields);
MOZ_MUST_USE JS::Result<ParseNode*> parseExpressionStatementAux(const BinKind kind, const Tokenizer::BinFields& fields);
MOZ_MUST_USE JS::Result<ParseNode*> parseExpressionAux(const BinKind kind, const Tokenizer::BinFields& fields);
MOZ_MUST_USE JS::Result<ParseNode*> parseFunctionAux(const BinKind kind, const Tokenizer::BinFields& fields);
MOZ_MUST_USE JS::Result<ParseNode*> parseIdentifierAux(const BinKind, const Tokenizer::BinFields& fields, const bool expectObjectPropertyName = false);
MOZ_MUST_USE JS::Result<ParseNode*> parseMemberExpressionAux(const BinKind kind, const Tokenizer::BinFields& fields);
MOZ_MUST_USE JS::Result<ParseNode*> parseNumericLiteralAux(const BinKind kind, const Tokenizer::BinFields& fields);
MOZ_MUST_USE JS::Result<ParseNode*> parseObjectExpressionAux(const BinKind kind, const Tokenizer::BinFields& fields);
MOZ_MUST_USE JS::Result<ParseNode*> parsePatternAux(const BinKind kind, const Tokenizer::BinFields& fields);
MOZ_MUST_USE JS::Result<ParseNode*> parseStringLiteralAux(const BinKind kind, const Tokenizer::BinFields& fields);
MOZ_MUST_USE JS::Result<ParseNode*> parseStatementAux(const BinKind kind, const Tokenizer::BinFields& fields);
MOZ_MUST_USE JS::Result<ParseNode*> parseVariableDeclarationAux(const BinKind kind, const Tokenizer::BinFields& fields);
// --- Auxiliary parsing functions that may have a side-effect on the parser but do not return a node.
MOZ_MUST_USE JS::Result<Ok> checkEmptyTuple(const BinKind kind, const Tokenizer::BinFields& fields);
MOZ_MUST_USE JS::Result<Ok> parseElisionAux(const BinKind kind, const Tokenizer::BinFields& fields);
// Parse full scope information to the current innermost scope.
MOZ_MUST_USE JS::Result<Ok> parseAndUpdateCurrentScope();
// Parse full scope information to a specific var scope / let scope combination.
MOZ_MUST_USE JS::Result<Ok> parseAndUpdateScope(ParseContext::Scope& varScope, ParseContext::Scope& letScope);
MOZ_MUST_USE JS::Result<Ok> parseAndUpdateScope(ParseContext::Scope& varScope,
ParseContext::Scope& letScope);
// Parse a list of names and add it to a given scope.
MOZ_MUST_USE JS::Result<Ok> parseAndUpdateScopeNames(ParseContext::Scope& scope, DeclarationKind kind);
MOZ_MUST_USE JS::Result<Ok> parseStringList(MutableHandle<Maybe<Names>> out);
MOZ_MUST_USE JS::Result<Ok> parseAndUpdateScopeNames(ParseContext::Scope& scope,
DeclarationKind kind);
MOZ_MUST_USE JS::Result<Ok> parseAndUpdateCapturedNames();
MOZ_MUST_USE JS::Result<Ok> checkBinding(JSAtom* name);
// --- Utilities.
MOZ_MUST_USE JS::Result<ParseNode*> appendDirectivesToBody(ParseNode* body, ParseNode* directives);
MOZ_MUST_USE JS::Result<ParseNode*> appendDirectivesToBody(ParseNode* body,
ParseNode* directives);
// Read a string as a `Chars`.
MOZ_MUST_USE JS::Result<Ok> readString(Maybe<Chars>& out);
// Read a string
MOZ_MUST_USE JS::Result<Ok> readString(Chars& out);
MOZ_MUST_USE JS::Result<Ok> readMaybeString(Maybe<Chars>& out);
MOZ_MUST_USE JS::Result<Ok> readString(MutableHandleAtom out);
MOZ_MUST_USE JS::Result<Ok> readMaybeString(MutableHandleAtom out);
MOZ_MUST_USE JS::Result<bool> readBool();
MOZ_MUST_USE JS::Result<double> readNumber();
@ -261,8 +238,10 @@ class BinASTParser : private JS::AutoGCRooter, public ErrorReporter
UsedNameTracker& usedNames_;
Maybe<Tokenizer> tokenizer_;
FullParseHandler factory_;
VariableDeclarationKind variableDeclarationKind_;
friend class BinParseContext;
friend class AutoVariableDeclarationKind;
// Needs access to AutoGCRooter.
friend void TraceBinParser(JSTracer* trc, AutoGCRooter* parser);
@ -271,7 +250,8 @@ class BinASTParser : private JS::AutoGCRooter, public ErrorReporter
class BinParseContext : public ParseContext
{
public:
BinParseContext(JSContext* cx, BinASTParser* parser, SharedContext* sc, Directives* newDirectives)
BinParseContext(JSContext* cx, BinASTParser* parser, SharedContext* sc,
Directives* newDirectives)
: ParseContext(cx, parser->parseContext_, sc, *parser,
parser->usedNames_, newDirectives, /* isFull = */ true)
{ }

View File

@ -0,0 +1,871 @@
// Type aliases and enums.
typedef FrozenArray<(SpreadElement or Expression)> Arguments;
typedef DOMString string;
typedef string Identifier;
typedef string IdentifierName;
typedef string Label;
enum VariableDeclarationKind {
"var",
"let",
"const"
};
enum CompoundAssignmentOperator {
"+=",
"-=",
"*=",
"/=",
"%=",
"**=",
"<<=",
">>=",
">>>=",
"|=",
"^=",
"&="
};
enum BinaryOperator {
",",
"||",
"&&",
"|",
"^",
"&",
"==",
"!=",
"===",
"!==",
"<",
"<=",
">",
">=",
"in",
"instanceof",
"<<",
">>",
">>>",
"+",
"-",
"*",
"/",
"%",
"**",
};
enum UnaryOperator {
"+",
"-",
"!",
"~",
"typeof",
"void",
"delete"
};
enum UpdateOperator {
"++",
"--"
};
// deferred assertions
interface AssertedBlockScope {
// checked eagerly during transformation
attribute FrozenArray<IdentifierName> lexicallyDeclaredNames;
// checked lazily as inner functions are invoked
attribute FrozenArray<IdentifierName> capturedNames;
attribute boolean hasDirectEval;
};
interface AssertedVarScope {
// checked eagerly during transformation
attribute FrozenArray<IdentifierName> lexicallyDeclaredNames;
attribute FrozenArray<IdentifierName> varDeclaredNames;
// checked lazily as inner functions are invoked
attribute FrozenArray<IdentifierName> capturedNames;
attribute boolean hasDirectEval;
};
interface AssertedParameterScope {
// checked eagerly during transformation
attribute FrozenArray<IdentifierName> parameterNames;
// checked lazily as inner functions are invoked
attribute FrozenArray<IdentifierName> capturedNames;
attribute boolean hasDirectEval;
};
// nodes
interface Node {
[TypeIndicator] readonly attribute Type type;
};
typedef (Script or Module) Program;
typedef (DoWhileStatement or
ForInStatement or
ForOfStatement or
ForStatement or
WhileStatement)
IterationStatement;
typedef (Block or
BreakStatement or
ContinueStatement or
ClassDeclaration or
DebuggerStatement or
EmptyStatement or
ExpressionStatement or
FunctionDeclaration or
IfStatement or
IterationStatement or
LabelledStatement or
ReturnStatement or
SwitchStatement or
SwitchStatementWithDefault or
ThrowStatement or
TryCatchStatement or
TryFinallyStatement or
VariableDeclaration or
WithStatement)
Statement;
typedef (LiteralBooleanExpression or
LiteralInfinityExpression or
LiteralNullExpression or
LiteralNumericExpression or
LiteralStringExpression)
Literal;
typedef (Literal or
LiteralRegExpExpression or
ArrayExpression or
ArrowExpression or
AssignmentExpression or
BinaryExpression or
CallExpression or
CompoundAssignmentExpression or
ComputedMemberExpression or
ConditionalExpression or
ClassExpression or
FunctionExpression or
IdentifierExpression or
NewExpression or
NewTargetExpression or
ObjectExpression or
UnaryExpression or
StaticMemberExpression or
TemplateExpression or
ThisExpression or
UpdateExpression or
YieldExpression or
YieldStarExpression or
AwaitExpression)
Expression;
typedef (ComputedPropertyName or
LiteralPropertyName)
PropertyName;
typedef (Method or Getter or Setter) MethodDefinition;
typedef (MethodDefinition or
DataProperty or
ShorthandProperty)
ObjectProperty;
typedef (ExportAllFrom or
ExportFrom or
ExportLocals or
ExportDefault or
Export)
ExportDeclaration;
typedef (ImportNamespace or Import) ImportDeclaration;
// bindings
interface BindingIdentifier : Node {
attribute Identifier name;
};
typedef (ObjectBinding or
ArrayBinding)
BindingPattern;
typedef (BindingPattern or
BindingIdentifier)
Binding;
typedef (AssignmentTargetIdentifier or
ComputedMemberAssignmentTarget or
StaticMemberAssignmentTarget)
SimpleAssignmentTarget;
typedef (ObjectAssignmentTarget or
ArrayAssignmentTarget)
AssignmentTargetPattern;
// `DestructuringAssignmentTarget`
typedef (AssignmentTargetPattern or
SimpleAssignmentTarget)
AssignmentTarget;
// `FormalParameter`
typedef (Binding or
BindingWithInitializer)
Parameter;
interface BindingWithInitializer : Node {
attribute Binding binding;
attribute Expression init;
};
interface AssignmentTargetIdentifier : Node {
attribute Identifier name;
};
interface ComputedMemberAssignmentTarget : Node {
// The object whose property is being assigned.
attribute (Expression or Super) _object;
// The expression resolving to the name of the property to be accessed.
attribute Expression expression;
};
interface StaticMemberAssignmentTarget : Node {
// The object whose property is being assigned.
attribute (Expression or Super) _object;
// The name of the property to be accessed.
attribute IdentifierName property;
};
// `ArrayBindingPattern`
interface ArrayBinding : Node {
// The elements of the array pattern; a null value represents an elision.
attribute FrozenArray<(Binding or BindingWithInitializer)?> elements;
attribute Binding? rest;
};
// `SingleNameBinding`
interface BindingPropertyIdentifier : Node {
attribute BindingIdentifier binding;
attribute Expression? init;
};
// `BindingProperty :: PropertyName : BindingElement`
interface BindingPropertyProperty : Node {
attribute PropertyName name;
attribute (Binding or BindingWithInitializer) binding;
};
typedef (BindingPropertyIdentifier or
BindingPropertyProperty)
BindingProperty;
interface ObjectBinding : Node {
attribute FrozenArray<BindingProperty> properties;
};
// This interface represents the case where the initializer is present in
// `AssignmentElement :: DestructuringAssignmentTarget Initializer_opt`.
interface AssignmentTargetWithInitializer : Node {
attribute AssignmentTarget binding;
attribute Expression init;
};
// `ArrayAssignmentPattern`
interface ArrayAssignmentTarget : Node {
// The elements of the array pattern; a null value represents an elision.
attribute FrozenArray<(AssignmentTarget or AssignmentTargetWithInitializer?)> elements;
attribute AssignmentTarget? rest;
};
// `AssignmentProperty :: IdentifierReference Initializer_opt`
interface AssignmentTargetPropertyIdentifier : Node {
attribute AssignmentTargetIdentifier binding;
attribute Expression? init;
};
// `AssignmentProperty :: PropertyName : Node`
interface AssignmentTargetPropertyProperty : Node {
attribute PropertyName name;
attribute (AssignmentTarget or AssignmentTargetWithInitializer) binding;
};
typedef (AssignmentTargetPropertyIdentifier or
AssignmentTargetPropertyProperty)
AssignmentTargetProperty;
// `ObjectAssignmentPattern`
interface ObjectAssignmentTarget : Node {
attribute FrozenArray<AssignmentTargetProperty> properties;
};
// classes
interface ClassExpression : Node {
attribute BindingIdentifier? name;
attribute Expression? super;
attribute FrozenArray<ClassElement> elements;
};
interface ClassDeclaration : Node {
attribute BindingIdentifier name;
attribute Expression? super;
attribute FrozenArray<ClassElement> elements;
};
interface ClassElement : Node {
// True iff `IsStatic` of ClassElement is true.
attribute boolean isStatic;
attribute MethodDefinition method;
};
// modules
interface Module : Node {
attribute AssertedVarScope? scope;
attribute FrozenArray<Directive> directives;
attribute FrozenArray<(ImportDeclaration or ExportDeclaration or Statement)> items;
};
// An `ImportDeclaration` not including a namespace import.
interface Import : Node {
attribute string moduleSpecifier;
// `ImportedDefaultBinding`, if present.
attribute BindingIdentifier? defaultBinding;
attribute FrozenArray<ImportSpecifier> namedImports;
};
// An `ImportDeclaration` including a namespace import.
interface ImportNamespace : Node {
attribute string moduleSpecifier;
// `ImportedDefaultBinding`, if present.
attribute BindingIdentifier? defaultBinding;
attribute BindingIdentifier namespaceBinding;
};
interface ImportSpecifier : Node {
// The `IdentifierName` in the production `ImportSpecifier :: IdentifierName as ImportedBinding`;
// absent if this specifier represents the production `ImportSpecifier :: ImportedBinding`.
attribute IdentifierName? name;
attribute BindingIdentifier binding;
};
// `export * FromClause;`
interface ExportAllFrom : Node {
attribute string moduleSpecifier;
};
// `export ExportClause FromClause;`
interface ExportFrom : Node {
attribute FrozenArray<ExportFromSpecifier> namedExports;
attribute string moduleSpecifier;
};
// `export ExportClause;`
interface ExportLocals : Node {
attribute FrozenArray<ExportLocalSpecifier> namedExports;
};
// `export VariableStatement`, `export Declaration`
interface Export : Node {
attribute (FunctionDeclaration or ClassDeclaration or VariableDeclaration) declaration;
};
// `export default HoistableDeclaration`,
// `export default ClassDeclaration`,
// `export default AssignmentExpression`
interface ExportDefault : Node {
attribute (FunctionDeclaration or ClassDeclaration or Expression) body;
};
// `ExportSpecifier`, as part of an `ExportFrom`.
interface ExportFromSpecifier : Node {
// The only `IdentifierName in `ExportSpecifier :: IdentifierName`,
// or the first in `ExportSpecifier :: IdentifierName as IdentifierName`.
attribute IdentifierName name;
// The second `IdentifierName` in `ExportSpecifier :: IdentifierName as IdentifierName`,
// if that is the production represented.
attribute IdentifierName? exportedName;
};
// `ExportSpecifier`, as part of an `ExportLocals`.
interface ExportLocalSpecifier : Node {
// The only `IdentifierName in `ExportSpecifier :: IdentifierName`,
// or the first in `ExportSpecifier :: IdentifierName as IdentifierName`.
attribute IdentifierExpression name;
// The second `IdentifierName` in `ExportSpecifier :: IdentifierName as IdentifierName`, if present.
attribute IdentifierName? exportedName;
};
// property definition
// `MethodDefinition :: PropertyName ( UniqueFormalParameters ) { FunctionBody }`,
// `GeneratorMethod :: * PropertyName ( UniqueFormalParameters ) { GeneratorBody }`,
// `AsyncMethod :: async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody }`
interface Method : Node {
// True for `AsyncMethod`, false otherwise.
attribute boolean isAsync;
// True for `GeneratorMethod`, false otherwise.
attribute boolean isGenerator;
attribute AssertedParameterScope? parameterScope;
attribute AssertedVarScope? bodyScope;
attribute PropertyName name;
// The `UniqueFormalParameters`.
attribute FormalParameters params;
attribute FunctionBody body;
};
// `get PropertyName ( ) { FunctionBody }`
interface Getter : Node {
attribute AssertedVarScope? bodyScope;
attribute PropertyName name;
attribute FunctionBody body;
};
// `set PropertyName ( PropertySetParameterList ) { FunctionBody }`
interface Setter : Node {
attribute AssertedParameterScope? parameterScope;
attribute AssertedVarScope? bodyScope;
attribute PropertyName name;
// The `PropertySetParameterList`.
attribute Parameter param;
attribute FunctionBody body;
};
// `PropertyDefinition :: PropertyName : AssignmentExpression`
interface DataProperty : Node {
attribute PropertyName name;
// The `AssignmentExpression`.
attribute Expression expression;
};
// `PropertyDefinition :: IdentifierReference`
interface ShorthandProperty : Node {
// The `IdentifierReference`.
attribute IdentifierExpression name;
};
interface ComputedPropertyName : Node {
attribute Expression expression;
};
// `LiteralPropertyName`
interface LiteralPropertyName : Node {
attribute string value;
};
// literals
// `BooleanLiteral`
interface LiteralBooleanExpression : Node {
attribute boolean value;
};
// A `NumericLiteral` for which the Number value of its MV is positive infinity.
interface LiteralInfinityExpression : Node { };
// `NullLiteral`
interface LiteralNullExpression : Node { };
// `NumericLiteral`
interface LiteralNumericExpression : Node {
attribute double value;
};
// `RegularExpressionLiteral`
interface LiteralRegExpExpression : Node {
attribute string pattern;
attribute string flags;
};
// `StringLiteral`
interface LiteralStringExpression : Node {
attribute string value;
};
// other expressions
// `ArrayLiteral`
interface ArrayExpression : Node {
// The elements of the array literal; a null value represents an elision.
attribute FrozenArray<(SpreadElement or Expression)?> elements;
};
// `ArrowFunction`,
// `AsyncArrowFunction`
interface ArrowExpression : Node {
// True for `AsyncArrowFunction`, false otherwise.
attribute boolean isAsync;
attribute AssertedParameterScope? parameterScope;
attribute AssertedVarScope? bodyScope;
attribute FormalParameters params;
attribute (FunctionBody or Expression) body;
};
// `AssignmentExpression :: LeftHandSideExpression = AssignmentExpression`
interface AssignmentExpression : Node {
// The `LeftHandSideExpression`.
attribute AssignmentTarget binding;
// The `AssignmentExpression` following the `=`.
attribute Expression expression;
};
// `ExponentiationExpression`,
// `MultiplicativeExpression`,
// `AdditiveExpression`,
// `ShiftExpression`,
// `RelationalExpression`,
// `EqualityExpression`,
// `BitwiseANDExpression`,
// `BitwiseXORExpression`,
// `BitwiseORExpression`,
// `LogicalANDExpression`,
// `LogicalORExpression`
interface BinaryExpression : Node {
attribute BinaryOperator operator;
// The expression before the operator.
attribute Expression left;
// The expression after the operator.
attribute Expression right;
};
interface CallExpression : Node {
attribute (Expression or Super) callee;
attribute Arguments arguments;
};
// `AssignmentExpression :: LeftHandSideExpression AssignmentOperator AssignmentExpression`
interface CompoundAssignmentExpression : Node {
attribute CompoundAssignmentOperator operator;
// The `LeftHandSideExpression`.
attribute SimpleAssignmentTarget binding;
// The `AssignmentExpression`.
attribute Expression expression;
};
interface ComputedMemberExpression : Node {
// The object whose property is being accessed.
attribute (Expression or Super) _object;
// The expression resolving to the name of the property to be accessed.
attribute Expression expression;
};
// `ConditionalExpression :: LogicalORExpression ? AssignmentExpression : AssignmentExpression`
interface ConditionalExpression : Node {
// The `LogicalORExpression`.
attribute Expression test;
// The first `AssignmentExpression`.
attribute Expression consequent;
// The second `AssignmentExpression`.
attribute Expression alternate;
};
// `FunctionExpression`,
// `GeneratorExpression`,
// `AsyncFunctionExpression`,
interface FunctionExpression : Node {
attribute boolean isAsync;
attribute boolean isGenerator;
attribute AssertedParameterScope? parameterScope;
attribute AssertedVarScope? bodyScope;
attribute BindingIdentifier? name;
attribute FormalParameters params;
attribute FunctionBody body;
};
// `IdentifierReference`
interface IdentifierExpression : Node {
attribute Identifier name;
};
interface NewExpression : Node {
attribute Expression callee;
attribute Arguments arguments;
};
interface NewTargetExpression : Node { };
interface ObjectExpression : Node {
attribute FrozenArray<ObjectProperty> properties;
};
interface UnaryExpression : Node {
attribute UnaryOperator operator;
attribute Expression operand;
};
interface StaticMemberExpression : Node {
// The object whose property is being accessed.
attribute (Expression or Super) _object;
// The name of the property to be accessed.
attribute IdentifierName property;
};
// `TemplateLiteral`,
// `MemberExpression :: MemberExpression TemplateLiteral`,
// `CallExpression : CallExpression TemplateLiteral`
interface TemplateExpression : Node {
// The second `MemberExpression` or `CallExpression`, if present.
attribute Expression? tag;
// The contents of the template. This list must be alternating
// TemplateElements and Expressions, beginning and ending with
// TemplateElement.
attribute FrozenArray<(Expression or TemplateElement)> elements;
};
// `PrimaryExpression :: this`
interface ThisExpression : Node { };
// `UpdateExpression :: LeftHandSideExpression ++`,
// `UpdateExpression :: LeftHandSideExpression --`,
// `UpdateExpression :: ++ LeftHandSideExpression`,
// `UpdateExpression :: -- LeftHandSideExpression`
interface UpdateExpression : Node {
// True for `UpdateExpression :: ++ LeftHandSideExpression` and
// `UpdateExpression :: -- LeftHandSideExpression`, false otherwise.
attribute boolean isPrefix;
attribute UpdateOperator operator;
attribute SimpleAssignmentTarget operand;
};
// `YieldExpression :: yield`,
// `YieldExpression :: yield AssignmentExpression`
interface YieldExpression : Node {
// The `AssignmentExpression`, if present.
attribute Expression? expression;
};
// `YieldExpression :: yield * AssignmentExpression`
interface YieldStarExpression : Node {
attribute Expression expression;
};
interface AwaitExpression : Node {
attribute Expression expression;
};
// other statements
interface BreakStatement : Node {
attribute Label? label;
};
interface ContinueStatement : Node {
attribute Label? label;
};
interface DebuggerStatement : Node { };
interface DoWhileStatement : Node {
attribute Expression test;
attribute Statement body;
};
interface EmptyStatement : Node { };
interface ExpressionStatement : Node {
attribute Expression expression;
};
interface ForInOfBinding : Node {
attribute VariableDeclarationKind kind;
attribute Binding binding;
};
// `for ( LeftHandSideExpression in Expression ) Statement`,
// `for ( var ForBinding in Expression ) Statement`,
// `for ( ForDeclaration in Expression ) Statement`,
// `for ( var BindingIdentifier Initializer in Expression ) Statement`
interface ForInStatement : Node {
// The expression or declaration before `in`.
attribute (ForInOfBinding or AssignmentTarget) left;
// The expression after `in`.
attribute Expression right;
attribute Statement body;
};
// `for ( LeftHandSideExpression of Expression ) Statement`,
// `for ( var ForBinding of Expression ) Statement`,
// `for ( ForDeclaration of Expression ) Statement`
interface ForOfStatement : Node {
// The expression or declaration before `of`.
attribute (ForInOfBinding or AssignmentTarget) left;
// The expression after `of`.
attribute Expression right;
attribute Statement body;
};
// `for ( Expression ; Expression ; Expression ) Statement`,
// `for ( var VariableDeclarationList ; Expression ; Expression ) Statement`
interface ForStatement : Node {
// The expression or declaration before the first `;`, if present.
attribute (VariableDeclaration or Expression)? init;
// The expression before the second `;`, if present
attribute Expression? test;
// The expression after the second `;`, if present
attribute Expression? update;
attribute Statement body;
};
// `if ( Expression ) Statement`,
// `if ( Expression ) Statement else Statement`,
interface IfStatement : Node {
attribute Expression test;
// The first `Statement`.
attribute Statement consequent;
// The second `Statement`, if present.
attribute Statement? alternate;
};
interface LabelledStatement : Node {
attribute Label label;
attribute Statement body;
};
interface ReturnStatement : Node {
attribute Expression? expression;
};
// A `SwitchStatement` whose `CaseBlock` is
// `CaseBlock :: { CaseClauses }`.
interface SwitchStatement : Node {
attribute Expression discriminant;
attribute FrozenArray<SwitchCase> cases;
};
// A `SwitchStatement` whose `CaseBlock` is
// `CaseBlock :: { CaseClauses DefaultClause CaseClauses }`.
interface SwitchStatementWithDefault : Node {
attribute Expression discriminant;
// The `CaseClauses` before the `DefaultClause`.
attribute FrozenArray<SwitchCase> preDefaultCases;
// The `DefaultClause`.
attribute SwitchDefault defaultCase;
// The `CaseClauses` after the `DefaultClause`.
attribute FrozenArray<SwitchCase> postDefaultCases;
};
interface ThrowStatement : Node {
attribute Expression expression;
};
// `TryStatement :: try Block Catch`
interface TryCatchStatement : Node {
attribute Block body;
attribute CatchClause catchClause;
};
// `TryStatement :: try Block Finally`,
// `TryStatement :: try Block Catch Finally`
interface TryFinallyStatement : Node {
// The `Block`.
attribute Block body;
// The `Catch`, if present.
attribute CatchClause? catchClause;
// The `Finally`.
attribute Block finalizer;
};
interface WhileStatement : Node {
attribute Expression test;
attribute Statement body;
};
interface WithStatement : Node {
attribute Expression _object;
attribute Statement body;
};
// other nodes
interface Block : Node {
attribute AssertedBlockScope? scope;
attribute FrozenArray<Statement> statements;
};
// `Catch`
interface CatchClause : Node {
attribute Binding binding;
attribute Block body;
};
// An item in a `DirectivePrologue`
interface Directive : Node {
attribute string rawValue;
};
interface FormalParameters : Node {
attribute FrozenArray<Parameter> items;
attribute Binding? rest;
};
interface FunctionBody : Node {
attribute FrozenArray<Directive> directives;
attribute FrozenArray<Statement> statements;
};
// `FunctionDeclaration`,
// `GeneratorDeclaration`,
// `AsyncFunctionDeclaration`
interface FunctionDeclaration : Node {
attribute boolean isAsync;
attribute boolean isGenerator;
attribute AssertedParameterScope? parameterScope;
attribute AssertedVarScope? bodyScope;
attribute BindingIdentifier name;
attribute FormalParameters params;
attribute FunctionBody body;
};
interface Script : Node {
attribute AssertedVarScope? scope;
attribute FrozenArray<Directive> directives;
attribute FrozenArray<Statement> statements;
};
interface SpreadElement : Node {
attribute Expression expression;
};
// `super`
interface Super : Node { };
// `CaseClause`
interface SwitchCase : Node {
attribute Expression test;
attribute FrozenArray<Statement> consequent;
};
// `DefaultClause`
interface SwitchDefault : Node {
attribute FrozenArray<Statement> consequent;
};
// `TemplateCharacters`
interface TemplateElement : Node {
attribute string rawValue;
};
interface VariableDeclaration : Node {
attribute VariableDeclarationKind kind;
[NonEmpty] attribute FrozenArray<VariableDeclarator> declarators;
};
interface VariableDeclarator : Node {
attribute Binding binding;
attribute Expression? init;
};

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,20 @@
// This file was autogenerated by binjs_generate_spidermonkey,
// please DO NOT EDIT BY HAND.
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// To generate this file, see the documentation in
// js/src/frontend/binsource/README.md.
#ifndef frontend_BinToken_h
#define frontend_BinToken_h
#include <stddef.h>
/**
* Definition of Binary AST tokens.
*
@ -18,32 +26,25 @@
* - a Value, which may be either a node or a primitive value.
*
* The mapping between Kind and list of fields is determined entirely by
* the grammar of Binary AST. The mapping between (Kind, Name) and the structure
* of Value is also determined entirely by the grammar of Binary AST.
* the grammar of Binary AST. The mapping between (Kind, Name) and the
* structure of Value is also determined entirely by the grammar of
* Binary AST.
*
* As per the specifications of Binary AST, kinds may be added as the language
* grows, but never removed. The mapping between Kind and list of fields may
* also change to add new fields or make some fields optional, but may never
* remove a field. Finally, the mapping between (Kind, Name) and the structure
* of Value may be modified to add new possible values, but never to remove a
* value.
* As per the specifications of Binary AST, kinds may be added as the
* language grows, but never removed. The mapping between Kind and list
* of fields may also change to add new fields or make some fields optional,
* but may never remove a field. Finally, the mapping between (Kind, Name)
* and the structure of Value may be modified to add new possible values,
* but never to remove a value.
*
* A Binary AST parser must be able to fail gracefully when confronted with
* unknown Kinds or Names.
*
* At the time of this writing, the Binary AST defined from the Babylon AST
* (see https://github.com/babel/babylon/blob/master/ast/spec.md) restricted
* to ES5, with a few amendments to store additional scoping data and to
* represent the empty AST.
*
* Future versions of the Binary AST will progressively grow to encompass ES6
* and beyond.
*/
namespace js {
namespace frontend {
/**
/**
* The different kinds of Binary AST nodes, as per the specifications of
* Binary AST.
*
@ -60,80 +61,188 @@ namespace frontend {
* (sorted by alphabetical order)
*/
#define FOR_EACH_BIN_KIND(F) \
F(Arguments, Arguments) \
F(ArrayAssignmentTarget, ArrayAssignmentTarget) \
F(ArrayBinding, ArrayBinding) \
F(ArrayExpression, ArrayExpression) \
F(ArrowExpression, ArrowExpression) \
F(AssertedBlockScope, AssertedBlockScope) \
F(AssertedParameterScope, AssertedParameterScope) \
F(AssertedVarScope, AssertedVarScope) \
F(AssignmentExpression, AssignmentExpression) \
F(AssignmentOperator, AssignmentOperator) \
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(BINJS_Scope, BINJS:Scope) \
F(BlockStatement, BlockStatement) \
F(BooleanLiteral, BooleanLiteral) \
F(BracketExpression, BracketExpression) \
F(Binding, Binding) \
F(BindingIdentifier, BindingIdentifier) \
F(BindingOrBindingWithInitializer, BindingOrBindingWithInitializer) \
F(BindingPattern, BindingPattern) \
F(BindingProperty, BindingProperty) \
F(BindingPropertyIdentifier, BindingPropertyIdentifier) \
F(BindingPropertyProperty, BindingPropertyProperty) \
F(BindingWithInitializer, BindingWithInitializer) \
F(Block, Block) \
F(BreakStatement, BreakStatement) \
F(CallExpression, CallExpression) \
F(CatchClause, CatchClause) \
F(ClassDeclaration, ClassDeclaration) \
F(ClassElement, ClassElement) \
F(ClassExpression, ClassExpression) \
F(CompoundAssignmentExpression, CompoundAssignmentExpression) \
F(CompoundAssignmentOperator, CompoundAssignmentOperator) \
F(ComputedMemberAssignmentTarget, ComputedMemberAssignmentTarget) \
F(ComputedMemberExpression, ComputedMemberExpression) \
F(ComputedPropertyName, ComputedPropertyName) \
F(ConditionalExpression, ConditionalExpression) \
F(ContinueStatement, ContinueStatement) \
F(DataProperty, DataProperty) \
F(DebuggerStatement, DebuggerStatement) \
F(Declaration, Declaration) \
F(Directive, Directive) \
F(DirectiveLiteral, DirectiveLiteral) \
F(DotExpression, DotExpression) \
F(DoWhileStatement, DoWhileStatement) \
F(Elision, Elision) \
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(ForStatement, ForStatement) \
F(ForInOfBinding, ForInOfBinding) \
F(ForInOfBindingOrAssignmentTarget, ForInOfBindingOrAssignmentTarget) \
F(ForInStatement, ForInStatement) \
F(FunctionExpression, FunctionExpression) \
F(ForOfStatement, ForOfStatement) \
F(ForStatement, ForStatement) \
F(FormalParameters, FormalParameters) \
F(FunctionBody, FunctionBody) \
F(FunctionBodyOrExpression, FunctionBodyOrExpression) \
F(FunctionDeclaration, FunctionDeclaration) \
F(FunctionDeclarationOrClassDeclarationOrExpression, FunctionDeclarationOrClassDeclarationOrExpression) \
F(FunctionDeclarationOrClassDeclarationOrVariableDeclaration, FunctionDeclarationOrClassDeclarationOrVariableDeclaration) \
F(FunctionExpression, FunctionExpression) \
F(Getter, Getter) \
F(Identifier, Identifier) \
F(IdentifierExpression, IdentifierExpression) \
F(IdentifierName, IdentifierName) \
F(IfStatement, IfStatement) \
F(LabeledStatement, LabeledStatement) \
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(ListOfAssignmentTargetOrAssignmentTargetWithInitializer, ListOfAssignmentTargetOrAssignmentTargetWithInitializer) \
F(ListOfAssignmentTargetProperty, ListOfAssignmentTargetProperty) \
F(ListOfBindingProperty, ListOfBindingProperty) \
F(ListOfClassElement, ListOfClassElement) \
F(ListOfDirective, ListOfDirective) \
F(ListOfExportFromSpecifier, ListOfExportFromSpecifier) \
F(ListOfExportLocalSpecifier, ListOfExportLocalSpecifier) \
F(ListOfExpressionOrTemplateElement, ListOfExpressionOrTemplateElement) \
F(ListOfIdentifierName, ListOfIdentifierName) \
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(LogicalExpression, LogicalExpression) \
F(LogicalOperator, LogicalOperator) \
F(LiteralBooleanExpression, LiteralBooleanExpression) \
F(LiteralInfinityExpression, LiteralInfinityExpression) \
F(LiteralNullExpression, LiteralNullExpression) \
F(LiteralNumericExpression, LiteralNumericExpression) \
F(LiteralPropertyName, LiteralPropertyName) \
F(LiteralRegExpExpression, LiteralRegExpExpression) \
F(LiteralStringExpression, LiteralStringExpression) \
F(Method, Method) \
F(MethodDefinition, MethodDefinition) \
F(Module, Module) \
F(NewExpression, NewExpression) \
F(NullLiteral, NullLiteral) \
F(NumericLiteral, NumericLiteral) \
F(NewTargetExpression, NewTargetExpression) \
F(ObjectAssignmentTarget, ObjectAssignmentTarget) \
F(ObjectBinding, ObjectBinding) \
F(ObjectExpression, ObjectExpression) \
F(ObjectGetter, ObjectGetter) \
F(ObjectMethod, ObjectMethod) \
F(ObjectSetter, ObjectSetter) \
F(ObjectProperty, ObjectProperty) \
F(Pattern, Pattern) \
F(OptionalAssertedBlockScope, OptionalAssertedBlockScope) \
F(OptionalAssertedParameterScope, OptionalAssertedParameterScope) \
F(OptionalAssertedVarScope, OptionalAssertedVarScope) \
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(OptionalSpreadElementOrExpression, OptionalSpreadElementOrExpression) \
F(OptionalStatement, OptionalStatement) \
F(OptionalVariableDeclarationOrExpression, OptionalVariableDeclarationOrExpression) \
F(Parameter, Parameter) \
F(Program, Program) \
F(PropertyKind, PropertyKind) \
F(RegExpLiteral, RegExpLiteral) \
F(PropertyName, PropertyName) \
F(ReturnStatement, ReturnStatement) \
F(SequenceExpression, SequenceExpression) \
F(StringLiteral, StringLiteral) \
F(Script, Script) \
F(Setter, Setter) \
F(ShorthandProperty, ShorthandProperty) \
F(SimpleAssignmentTarget, SimpleAssignmentTarget) \
F(SpreadElement, SpreadElement) \
F(SpreadElementOrExpression, SpreadElementOrExpression) \
F(Statement, Statement) \
F(StaticMemberAssignmentTarget, StaticMemberAssignmentTarget) \
F(StaticMemberExpression, StaticMemberExpression) \
F(Super, Super) \
F(SwitchCase, SwitchCase) \
F(SwitchDefault, SwitchDefault) \
F(SwitchStatement, SwitchStatement) \
F(SwitchStatementWithDefault, SwitchStatementWithDefault) \
F(TemplateElement, TemplateElement) \
F(TemplateExpression, TemplateExpression) \
F(ThisExpression, ThisExpression) \
F(ThrowStatement, ThrowStatement) \
F(TryStatement, TryStatement) \
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(VariableKind, VariableKind) \
F(WhileStatement, WhileStatement) \
F(WithStatement, WithStatement)
F(WithStatement, WithStatement) \
F(YieldExpression, YieldExpression) \
F(YieldStarExpression, YieldStarExpression) \
F(_Null, _Null) \
F(string, string)
enum class BinKind {
#define EMIT_ENUM(name, _) name,
FOR_EACH_BIN_KIND(EMIT_ENUM)
#undef EMIT_ENUM
BINKIND_LIMIT /* domain size */
};
const char* describeBinKind(const BinKind& kind);
// The number of distinct values of BinKind.
const size_t BINKIND_LIMIT = 171;
/**
* The different fields of Binary AST nodes, as per the specifications of
@ -148,60 +257,91 @@ const char* describeBinKind(const BinKind& kind);
*
* (sorted by alphabetical order)
*/
#define FOR_EACH_BIN_FIELD(F) \
#define FOR_EACH_BIN_FIELD(F) \
F(Alternate, alternate) \
F(Argument, argument) \
F(Arguments, arguments) \
F(BINJS_CapturedNames, BINJS:CapturedNames) \
F(BINJS_ConstDeclaredNames, BINJS:ConstDeclaredNames) \
F(BINJS_HasDirectEval, BINJS:HasDirectEval) \
F(BINJS_LetDeclaredNames, BINJS:LetDeclaredNames) \
F(BINJS_VarDeclaredNames, BINJS:VarDeclaredNames) \
F(BINJS_Scope, BINJS:Scope) \
F(Block, block) \
F(Callee, callee) \
F(Cases, cases) \
F(Consequent, consequent) \
F(Binding, binding) \
F(Body, body) \
F(Declarations, declarations) \
F(BodyScope, bodyScope) \
F(Callee, callee) \
F(CapturedNames, capturedNames) \
F(Cases, cases) \
F(CatchClause, catchClause) \
F(Consequent, consequent) \
F(Declaration, declaration) \
F(Declarators, declarators) \
F(DefaultBinding, defaultBinding) \
F(DefaultCase, defaultCase) \
F(Directives, directives) \
F(Discriminant, discriminant) \
F(Elements, elements) \
F(ExportedName, exportedName) \
F(Expression, expression) \
F(Expressions, expressions) \
F(Finalizer, finalizer) \
F(Flags, flags) \
F(Handler, handler) \
F(Id, id) \
F(HasDirectEval, hasDirectEval) \
F(Init, init) \
F(Key, key) \
F(IsAsync, isAsync) \
F(IsGenerator, isGenerator) \
F(IsPrefix, isPrefix) \
F(IsStatic, isStatic) \
F(Items, items) \
F(Kind, kind) \
F(Label, label) \
F(Left, left) \
F(LexicallyDeclaredNames, lexicallyDeclaredNames) \
F(Method, method) \
F(ModuleSpecifier, moduleSpecifier) \
F(Name, name) \
F(NamedExports, namedExports) \
F(NamedImports, namedImports) \
F(NamespaceBinding, namespaceBinding) \
F(Object, object) \
F(Operand, operand) \
F(Operator, operator) \
F(Param, param) \
F(ParameterNames, parameterNames) \
F(ParameterScope, parameterScope) \
F(Params, params) \
F(Pattern, pattern) \
F(Prefix, prefix) \
F(PostDefaultCases, postDefaultCases) \
F(PreDefaultCases, preDefaultCases) \
F(Properties, properties) \
F(Property, property) \
F(RawValue, rawValue) \
F(Rest, rest) \
F(Right, right) \
F(Scope, scope) \
F(Statements, statements) \
F(Super, super) \
F(Tag, tag) \
F(Test, test) \
F(Update, update) \
F(Value, value)
F(Value, value) \
F(VarDeclaredNames, varDeclaredNames)
enum class BinField {
#define EMIT_ENUM(name, _) name,
FOR_EACH_BIN_FIELD(EMIT_ENUM)
#undef EMIT_ENUM
BINFIELD_LIMIT /* domain size */
};
// The number of distinct values of BinField.
const size_t BINFIELD_LIMIT = 61;
/**
* Return a string describing a `BinKind`.
*/
const char* describeBinKind(const BinKind& kind);
/**
* Return a string describing a `BinField`.
*/
const char* describeBinField(const BinField& kind);
} // namespace frontend
} // namespace js
#endif // frontend_BinToken_h

View File

@ -706,6 +706,7 @@ if CONFIG['JS_BUILD_BINAST']:
SOURCES += ['frontend/BinTokenReaderTester.cpp']
# These parts of BinAST should eventually move to release.
SOURCES += [
'frontend/BinSource-auto.cpp',
'frontend/BinSource.cpp',
'frontend/BinToken.cpp'
]