DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Implementation

Mercurial (409f3966645a)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432
// 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.
 *
 * In the Binary AST world, an AST is composed of nodes, where a node is
 * defined by:
 * - a Kind (see `BinKind`);
 * - a list of fields, where each field is:
 *    - a Name (see `BinField`);
 *    - 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.
 *
 * 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.
 */

namespace js {
namespace frontend {

/**
 * The different kinds of Binary AST nodes, as per the specifications of
 * Binary AST.
 *
 * These kinds match roughly with the `ParseNodeKind` used internally.
 *
 * Usage:
 *
 * ```c++
 * #define WITH_KIND(CPP_NAME, SPEC_NAME) ...
 * FOR_EACH_BIN_KIND(WITH_KIND)
 * ```
 *
 *
 * (sorted by alphabetical order)
 */
#define FOR_EACH_BIN_KIND(F) \
    F(_Null, "") \
    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(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") \
    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(Directive, "Directive") \
    F(DoWhileStatement, "DoWhileStatement") \
    F(EagerArrowExpression, "EagerArrowExpression") \
    F(EagerFunctionDeclaration, "EagerFunctionDeclaration") \
    F(EagerFunctionExpression, "EagerFunctionExpression") \
    F(EagerGetter, "EagerGetter") \
    F(EagerMethod, "EagerMethod") \
    F(EagerSetter, "EagerSetter") \
    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(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(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(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(NewTargetExpression, "NewTargetExpression") \
    F(ObjectAssignmentTarget, "ObjectAssignmentTarget") \
    F(ObjectBinding, "ObjectBinding") \
    F(ObjectExpression, "ObjectExpression") \
    F(ObjectProperty, "ObjectProperty") \
    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(PropertyName, "PropertyName") \
    F(ReturnStatement, "ReturnStatement") \
    F(Script, "Script") \
    F(Setter, "Setter") \
    F(ShorthandProperty, "ShorthandProperty") \
    F(SimpleAssignmentTarget, "SimpleAssignmentTarget") \
    F(SkippableArrowExpression, "SkippableArrowExpression") \
    F(SkippableFunctionDeclaration, "SkippableFunctionDeclaration") \
    F(SkippableFunctionExpression, "SkippableFunctionExpression") \
    F(SkippableGetter, "SkippableGetter") \
    F(SkippableMethod, "SkippableMethod") \
    F(SkippableSetter, "SkippableSetter") \
    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(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")

enum class BinKind {
#define EMIT_ENUM(name, _) name,
    FOR_EACH_BIN_KIND(EMIT_ENUM)
#undef EMIT_ENUM
};

// The number of distinct values of BinKind.
const size_t BINKIND_LIMIT = 183;




/**
 * The different variants of Binary AST string enums, as per
 * the specifications of Binary AST, as a single macro and
 * `enum class`.
 *
 * Separate enum classes are also defined in BinSource-auto.h.
 *
 * Usage:
 *
 * ```c++
 * #define WITH_VARIANT(CPP_NAME, SPEC_NAME) ...
 * FOR_EACH_BIN_VARIANT(WITH_VARIANT)
 * ```
 *
 * (sorted by alphabetical order)
 */
#define FOR_EACH_BIN_FIELD(F) \
    F(Skip, "_skip") \
    F(Alternate, "alternate") \
    F(Arguments, "arguments") \
    F(Binding, "binding") \
    F(BindingScope, "bindingScope") \
    F(Body, "body") \
    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(Finalizer, "finalizer") \
    F(Flags, "flags") \
    F(HasDirectEval, "hasDirectEval") \
    F(Init, "init") \
    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(PostDefaultCases, "postDefaultCases") \
    F(PreDefaultCases, "preDefaultCases") \
    F(Properties, "properties") \
    F(Property, "property") \
    F(RawValue, "rawValue") \
    F(Rest, "rest") \
    F(Right, "right") \
    F(Scope, "scope") \
    F(Skipped, "skipped") \
    F(Statements, "statements") \
    F(Super, "super") \
    F(Tag, "tag") \
    F(Test, "test") \
    F(Update, "update") \
    F(Value, "value") \
    F(VarDeclaredNames, "varDeclaredNames")

enum class BinField {
#define EMIT_ENUM(name, _) name,
    FOR_EACH_BIN_FIELD(EMIT_ENUM)
#undef EMIT_ENUM
};

// The number of distinct values of BinField.
const size_t BINFIELD_LIMIT = 64;



#define FOR_EACH_BIN_VARIANT(F) \
    F(BinaryOperatorBitAnd, "&") \
    F(BinaryOperatorBitOr, "|") \
    F(BinaryOperatorBitXor, "^") \
    F(BinaryOperatorComma, ",") \
    F(BinaryOperatorDiv, "/") \
    F(BinaryOperatorEq, "==") \
    F(BinaryOperatorGeqThan, ">=") \
    F(BinaryOperatorGreaterThan, ">") \
    F(BinaryOperatorIn, "in") \
    F(BinaryOperatorInstanceof, "instanceof") \
    F(BinaryOperatorLeqThan, "<=") \
    F(BinaryOperatorLessThan, "<") \
    F(BinaryOperatorLogicalAnd, "&&") \
    F(BinaryOperatorLogicalOr, "||") \
    F(BinaryOperatorLsh, "<<") \
    F(BinaryOperatorMod, "%") \
    F(BinaryOperatorMul, "*") \
    F(BinaryOperatorNeq, "!=") \
    F(BinaryOperatorOrUnaryOperatorMinus, "-") \
    F(BinaryOperatorOrUnaryOperatorPlus, "+") \
    F(BinaryOperatorPow, "**") \
    F(BinaryOperatorRsh, ">>") \
    F(BinaryOperatorStrictEq, "===") \
    F(BinaryOperatorStrictNeq, "!==") \
    F(BinaryOperatorUrsh, ">>>") \
    F(CompoundAssignmentOperatorBitAndAssign, "&=") \
    F(CompoundAssignmentOperatorBitOrAssign, "|=") \
    F(CompoundAssignmentOperatorBitXorAssign, "^=") \
    F(CompoundAssignmentOperatorDivAssign, "/=") \
    F(CompoundAssignmentOperatorLshAssign, "<<=") \
    F(CompoundAssignmentOperatorMinusAssign, "-=") \
    F(CompoundAssignmentOperatorModAssign, "%=") \
    F(CompoundAssignmentOperatorMulAssign, "*=") \
    F(CompoundAssignmentOperatorPlusAssign, "+=") \
    F(CompoundAssignmentOperatorPowAssign, "**=") \
    F(CompoundAssignmentOperatorRshAssign, ">>=") \
    F(CompoundAssignmentOperatorUrshAssign, ">>>=") \
    F(UnaryOperatorBitNot, "~") \
    F(UnaryOperatorDelete, "delete") \
    F(UnaryOperatorNot, "!") \
    F(UnaryOperatorTypeof, "typeof") \
    F(UnaryOperatorVoid, "void") \
    F(UpdateOperatorDecr, "--") \
    F(UpdateOperatorIncr, "++") \
    F(VariableDeclarationKindConst, "const") \
    F(VariableDeclarationKindLet, "let") \
    F(VariableDeclarationKindVar, "var")

enum class BinVariant {
#define EMIT_ENUM(name, _) name,
    FOR_EACH_BIN_VARIANT(EMIT_ENUM)
#undef EMIT_ENUM
};

// The number of distinct values of BinVariant.
const size_t BINVARIANT_LIMIT = 47;



/**
 * Return a string describing a `BinKind`.
 */
const char* describeBinKind(const BinKind& kind);

/**
 * Return a string describing a `BinField`.
 */
const char* describeBinField(const BinField& kind);

/**
 * Return a string describing a `BinVariant`.
 */
const char* describeBinVariant(const BinVariant& kind);

} // namespace frontend
} // namespace js

#endif // frontend_BinToken_h