1 // WARNING: This file is auto-generated. 2 3 use crate::source_location::SourceLocation; 4 use crate::arena; 5 use crate::source_atom_set::SourceAtomSetIndex; 6 use crate::source_slice_list::SourceSliceIndex; 7 8 #[derive(Debug, PartialEq)] 9 pub enum Void { 10 } 11 12 #[derive(Debug, PartialEq)] 13 pub enum Argument<'alloc> { 14 SpreadElement(arena::Box<'alloc, Expression<'alloc>>), 15 Expression(arena::Box<'alloc, Expression<'alloc>>), 16 } 17 18 #[derive(Debug, PartialEq)] 19 pub struct Arguments<'alloc> { 20 pub args: arena::Vec<'alloc, Argument<'alloc>>, 21 pub loc: SourceLocation, 22 } 23 24 #[derive(Debug, PartialEq)] 25 pub struct Identifier { 26 pub value: SourceAtomSetIndex, 27 pub loc: SourceLocation, 28 } 29 30 #[derive(Debug, PartialEq)] 31 pub struct IdentifierName { 32 pub value: SourceAtomSetIndex, 33 pub loc: SourceLocation, 34 } 35 36 #[derive(Debug, PartialEq)] 37 pub struct PrivateIdentifier { 38 pub value: SourceAtomSetIndex, 39 pub loc: SourceLocation, 40 } 41 42 #[derive(Debug, PartialEq)] 43 pub struct Label { 44 pub value: SourceAtomSetIndex, 45 pub loc: SourceLocation, 46 } 47 48 #[derive(Debug, PartialEq)] 49 pub enum VariableDeclarationKind { 50 Var { 51 loc: SourceLocation, 52 }, 53 Let { 54 loc: SourceLocation, 55 }, 56 Const { 57 loc: SourceLocation, 58 }, 59 } 60 61 #[derive(Debug, PartialEq)] 62 pub enum CompoundAssignmentOperator { 63 LogicalOr { 64 loc: SourceLocation, 65 }, 66 LogicalAnd { 67 loc: SourceLocation, 68 }, 69 Coalesce { 70 loc: SourceLocation, 71 }, 72 Add { 73 loc: SourceLocation, 74 }, 75 Sub { 76 loc: SourceLocation, 77 }, 78 Mul { 79 loc: SourceLocation, 80 }, 81 Div { 82 loc: SourceLocation, 83 }, 84 Mod { 85 loc: SourceLocation, 86 }, 87 Pow { 88 loc: SourceLocation, 89 }, 90 LeftShift { 91 loc: SourceLocation, 92 }, 93 RightShift { 94 loc: SourceLocation, 95 }, 96 RightShiftExt { 97 loc: SourceLocation, 98 }, 99 Or { 100 loc: SourceLocation, 101 }, 102 Xor { 103 loc: SourceLocation, 104 }, 105 And { 106 loc: SourceLocation, 107 }, 108 } 109 110 #[derive(Debug, PartialEq)] 111 pub enum BinaryOperator { 112 Equals { 113 loc: SourceLocation, 114 }, 115 NotEquals { 116 loc: SourceLocation, 117 }, 118 StrictEquals { 119 loc: SourceLocation, 120 }, 121 StrictNotEquals { 122 loc: SourceLocation, 123 }, 124 LessThan { 125 loc: SourceLocation, 126 }, 127 LessThanOrEqual { 128 loc: SourceLocation, 129 }, 130 GreaterThan { 131 loc: SourceLocation, 132 }, 133 GreaterThanOrEqual { 134 loc: SourceLocation, 135 }, 136 In { 137 loc: SourceLocation, 138 }, 139 Instanceof { 140 loc: SourceLocation, 141 }, 142 LeftShift { 143 loc: SourceLocation, 144 }, 145 RightShift { 146 loc: SourceLocation, 147 }, 148 RightShiftExt { 149 loc: SourceLocation, 150 }, 151 Add { 152 loc: SourceLocation, 153 }, 154 Sub { 155 loc: SourceLocation, 156 }, 157 Mul { 158 loc: SourceLocation, 159 }, 160 Div { 161 loc: SourceLocation, 162 }, 163 Mod { 164 loc: SourceLocation, 165 }, 166 Pow { 167 loc: SourceLocation, 168 }, 169 Comma { 170 loc: SourceLocation, 171 }, 172 Coalesce { 173 loc: SourceLocation, 174 }, 175 LogicalOr { 176 loc: SourceLocation, 177 }, 178 LogicalAnd { 179 loc: SourceLocation, 180 }, 181 BitwiseOr { 182 loc: SourceLocation, 183 }, 184 BitwiseXor { 185 loc: SourceLocation, 186 }, 187 BitwiseAnd { 188 loc: SourceLocation, 189 }, 190 } 191 192 #[derive(Debug, PartialEq)] 193 pub enum UnaryOperator { 194 Plus { 195 loc: SourceLocation, 196 }, 197 Minus { 198 loc: SourceLocation, 199 }, 200 LogicalNot { 201 loc: SourceLocation, 202 }, 203 BitwiseNot { 204 loc: SourceLocation, 205 }, 206 Typeof { 207 loc: SourceLocation, 208 }, 209 Void { 210 loc: SourceLocation, 211 }, 212 Delete { 213 loc: SourceLocation, 214 }, 215 } 216 217 #[derive(Debug, PartialEq)] 218 pub enum UpdateOperator { 219 Increment { 220 loc: SourceLocation, 221 }, 222 Decrement { 223 loc: SourceLocation, 224 }, 225 } 226 227 #[derive(Debug, PartialEq)] 228 pub struct Function<'alloc> { 229 pub name: Option<BindingIdentifier>, 230 pub is_async: bool, 231 pub is_generator: bool, 232 pub params: FormalParameters<'alloc>, 233 pub body: FunctionBody<'alloc>, 234 pub loc: SourceLocation, 235 } 236 237 #[derive(Debug, PartialEq)] 238 pub enum Program<'alloc> { 239 Module(Module<'alloc>), 240 Script(Script<'alloc>), 241 } 242 243 #[derive(Debug, PartialEq)] 244 pub struct IfStatement<'alloc> { 245 pub test: arena::Box<'alloc, Expression<'alloc>>, 246 pub consequent: arena::Box<'alloc, Statement<'alloc>>, 247 pub alternate: Option<arena::Box<'alloc, Statement<'alloc>>>, 248 pub loc: SourceLocation, 249 } 250 251 #[derive(Debug, PartialEq)] 252 pub enum Statement<'alloc> { 253 BlockStatement { 254 block: Block<'alloc>, 255 loc: SourceLocation, 256 }, 257 BreakStatement { 258 label: Option<Label>, 259 loc: SourceLocation, 260 }, 261 ContinueStatement { 262 label: Option<Label>, 263 loc: SourceLocation, 264 }, 265 DebuggerStatement { 266 loc: SourceLocation, 267 }, 268 DoWhileStatement { 269 block: arena::Box<'alloc, Statement<'alloc>>, 270 test: arena::Box<'alloc, Expression<'alloc>>, 271 loc: SourceLocation, 272 }, 273 EmptyStatement { 274 loc: SourceLocation, 275 }, 276 ExpressionStatement(arena::Box<'alloc, Expression<'alloc>>), 277 ForInStatement { 278 left: VariableDeclarationOrAssignmentTarget<'alloc>, 279 right: arena::Box<'alloc, Expression<'alloc>>, 280 block: arena::Box<'alloc, Statement<'alloc>>, 281 loc: SourceLocation, 282 }, 283 ForOfStatement { 284 left: VariableDeclarationOrAssignmentTarget<'alloc>, 285 right: arena::Box<'alloc, Expression<'alloc>>, 286 block: arena::Box<'alloc, Statement<'alloc>>, 287 loc: SourceLocation, 288 }, 289 ForStatement { 290 init: Option<VariableDeclarationOrExpression<'alloc>>, 291 test: Option<arena::Box<'alloc, Expression<'alloc>>>, 292 update: Option<arena::Box<'alloc, Expression<'alloc>>>, 293 block: arena::Box<'alloc, Statement<'alloc>>, 294 loc: SourceLocation, 295 }, 296 IfStatement(IfStatement<'alloc>), 297 LabelledStatement { 298 label: Label, 299 body: arena::Box<'alloc, Statement<'alloc>>, 300 loc: SourceLocation, 301 }, 302 ReturnStatement { 303 expression: Option<arena::Box<'alloc, Expression<'alloc>>>, 304 loc: SourceLocation, 305 }, 306 SwitchStatement { 307 discriminant: arena::Box<'alloc, Expression<'alloc>>, 308 cases: arena::Vec<'alloc, SwitchCase<'alloc>>, 309 loc: SourceLocation, 310 }, 311 SwitchStatementWithDefault { 312 discriminant: arena::Box<'alloc, Expression<'alloc>>, 313 pre_default_cases: arena::Vec<'alloc, SwitchCase<'alloc>>, 314 default_case: SwitchDefault<'alloc>, 315 post_default_cases: arena::Vec<'alloc, SwitchCase<'alloc>>, 316 loc: SourceLocation, 317 }, 318 ThrowStatement { 319 expression: arena::Box<'alloc, Expression<'alloc>>, 320 loc: SourceLocation, 321 }, 322 TryCatchStatement { 323 body: Block<'alloc>, 324 catch_clause: CatchClause<'alloc>, 325 loc: SourceLocation, 326 }, 327 TryFinallyStatement { 328 body: Block<'alloc>, 329 catch_clause: Option<CatchClause<'alloc>>, 330 finalizer: Block<'alloc>, 331 loc: SourceLocation, 332 }, 333 WhileStatement { 334 test: arena::Box<'alloc, Expression<'alloc>>, 335 block: arena::Box<'alloc, Statement<'alloc>>, 336 loc: SourceLocation, 337 }, 338 WithStatement { 339 object: arena::Box<'alloc, Expression<'alloc>>, 340 body: arena::Box<'alloc, Statement<'alloc>>, 341 loc: SourceLocation, 342 }, 343 VariableDeclarationStatement(VariableDeclaration<'alloc>), 344 FunctionDeclaration(Function<'alloc>), 345 ClassDeclaration(ClassDeclaration<'alloc>), 346 } 347 348 #[derive(Debug, PartialEq)] 349 pub enum Expression<'alloc> { 350 MemberExpression(MemberExpression<'alloc>), 351 ClassExpression(ClassExpression<'alloc>), 352 LiteralBooleanExpression { 353 value: bool, 354 loc: SourceLocation, 355 }, 356 LiteralInfinityExpression { 357 loc: SourceLocation, 358 }, 359 LiteralNullExpression { 360 loc: SourceLocation, 361 }, 362 LiteralNumericExpression(NumericLiteral), 363 LiteralRegExpExpression { 364 pattern: SourceSliceIndex, 365 global: bool, 366 ignore_case: bool, 367 multi_line: bool, 368 dot_all: bool, 369 sticky: bool, 370 unicode: bool, 371 loc: SourceLocation, 372 }, 373 LiteralStringExpression { 374 value: SourceAtomSetIndex, 375 loc: SourceLocation, 376 }, 377 ArrayExpression(ArrayExpression<'alloc>), 378 ArrowExpression { 379 is_async: bool, 380 params: FormalParameters<'alloc>, 381 body: ArrowExpressionBody<'alloc>, 382 loc: SourceLocation, 383 }, 384 AssignmentExpression { 385 binding: AssignmentTarget<'alloc>, 386 expression: arena::Box<'alloc, Expression<'alloc>>, 387 loc: SourceLocation, 388 }, 389 BinaryExpression { 390 operator: BinaryOperator, 391 left: arena::Box<'alloc, Expression<'alloc>>, 392 right: arena::Box<'alloc, Expression<'alloc>>, 393 loc: SourceLocation, 394 }, 395 CallExpression(CallExpression<'alloc>), 396 CompoundAssignmentExpression { 397 operator: CompoundAssignmentOperator, 398 binding: SimpleAssignmentTarget<'alloc>, 399 expression: arena::Box<'alloc, Expression<'alloc>>, 400 loc: SourceLocation, 401 }, 402 ConditionalExpression { 403 test: arena::Box<'alloc, Expression<'alloc>>, 404 consequent: arena::Box<'alloc, Expression<'alloc>>, 405 alternate: arena::Box<'alloc, Expression<'alloc>>, 406 loc: SourceLocation, 407 }, 408 FunctionExpression(Function<'alloc>), 409 IdentifierExpression(IdentifierExpression), 410 NewExpression { 411 callee: arena::Box<'alloc, Expression<'alloc>>, 412 arguments: Arguments<'alloc>, 413 loc: SourceLocation, 414 }, 415 NewTargetExpression { 416 loc: SourceLocation, 417 }, 418 ObjectExpression(ObjectExpression<'alloc>), 419 OptionalExpression { 420 object: ExpressionOrSuper<'alloc>, 421 tail: arena::Box<'alloc, Expression<'alloc>>, 422 loc: SourceLocation, 423 }, 424 OptionalChain(OptionalChain<'alloc>), 425 UnaryExpression { 426 operator: UnaryOperator, 427 operand: arena::Box<'alloc, Expression<'alloc>>, 428 loc: SourceLocation, 429 }, 430 TemplateExpression(TemplateExpression<'alloc>), 431 ThisExpression { 432 loc: SourceLocation, 433 }, 434 UpdateExpression { 435 is_prefix: bool, 436 operator: UpdateOperator, 437 operand: SimpleAssignmentTarget<'alloc>, 438 loc: SourceLocation, 439 }, 440 YieldExpression { 441 expression: Option<arena::Box<'alloc, Expression<'alloc>>>, 442 loc: SourceLocation, 443 }, 444 YieldGeneratorExpression { 445 expression: arena::Box<'alloc, Expression<'alloc>>, 446 loc: SourceLocation, 447 }, 448 AwaitExpression { 449 expression: arena::Box<'alloc, Expression<'alloc>>, 450 loc: SourceLocation, 451 }, 452 ImportCallExpression { 453 argument: arena::Box<'alloc, Expression<'alloc>>, 454 loc: SourceLocation, 455 }, 456 } 457 458 #[derive(Debug, PartialEq)] 459 pub enum MemberExpression<'alloc> { 460 ComputedMemberExpression(ComputedMemberExpression<'alloc>), 461 StaticMemberExpression(StaticMemberExpression<'alloc>), 462 PrivateFieldExpression(PrivateFieldExpression<'alloc>), 463 } 464 465 #[derive(Debug, PartialEq)] 466 pub enum OptionalChain<'alloc> { 467 ComputedMemberExpressionTail { 468 expression: arena::Box<'alloc, Expression<'alloc>>, 469 loc: SourceLocation, 470 }, 471 StaticMemberExpressionTail { 472 property: IdentifierName, 473 loc: SourceLocation, 474 }, 475 PrivateFieldExpressionTail { 476 field: PrivateIdentifier, 477 loc: SourceLocation, 478 }, 479 CallExpressionTail { 480 arguments: Arguments<'alloc>, 481 loc: SourceLocation, 482 }, 483 ComputedMemberExpression(ComputedMemberExpression<'alloc>), 484 StaticMemberExpression(StaticMemberExpression<'alloc>), 485 PrivateFieldExpression(PrivateFieldExpression<'alloc>), 486 CallExpression(CallExpression<'alloc>), 487 } 488 489 #[derive(Debug, PartialEq)] 490 pub enum PropertyName<'alloc> { 491 ComputedPropertyName(ComputedPropertyName<'alloc>), 492 StaticPropertyName(StaticPropertyName), 493 StaticNumericPropertyName(NumericLiteral), 494 } 495 496 #[derive(Debug, PartialEq)] 497 pub struct CallExpression<'alloc> { 498 pub callee: ExpressionOrSuper<'alloc>, 499 pub arguments: Arguments<'alloc>, 500 pub loc: SourceLocation, 501 } 502 503 #[derive(Debug, PartialEq)] 504 pub enum ClassElementName<'alloc> { 505 ComputedPropertyName(ComputedPropertyName<'alloc>), 506 StaticPropertyName(StaticPropertyName), 507 StaticNumericPropertyName(NumericLiteral), 508 PrivateFieldName(PrivateIdentifier), 509 } 510 511 #[derive(Debug, PartialEq)] 512 pub enum ObjectProperty<'alloc> { 513 NamedObjectProperty(NamedObjectProperty<'alloc>), 514 ShorthandProperty(ShorthandProperty), 515 SpreadProperty(arena::Box<'alloc, Expression<'alloc>>), 516 } 517 518 #[derive(Debug, PartialEq)] 519 pub enum NamedObjectProperty<'alloc> { 520 MethodDefinition(MethodDefinition<'alloc>), 521 DataProperty(DataProperty<'alloc>), 522 } 523 524 #[derive(Debug, PartialEq)] 525 pub enum MethodDefinition<'alloc> { 526 Method(Method<'alloc>), 527 Getter(Getter<'alloc>), 528 Setter(Setter<'alloc>), 529 } 530 531 #[derive(Debug, PartialEq)] 532 pub enum ImportDeclaration<'alloc> { 533 Import(Import<'alloc>), 534 ImportNamespace(ImportNamespace), 535 } 536 537 #[derive(Debug, PartialEq)] 538 pub enum ExportDeclaration<'alloc> { 539 ExportAllFrom(ExportAllFrom), 540 ExportFrom(ExportFrom<'alloc>), 541 ExportLocals(ExportLocals<'alloc>), 542 Export(Export<'alloc>), 543 ExportDefault(ExportDefault<'alloc>), 544 } 545 546 #[derive(Debug, PartialEq)] 547 pub enum VariableReference { 548 BindingIdentifier(BindingIdentifier), 549 AssignmentTargetIdentifier(AssignmentTargetIdentifier), 550 } 551 552 #[derive(Debug, PartialEq)] 553 pub enum BindingPattern<'alloc> { 554 ObjectBinding(ObjectBinding<'alloc>), 555 ArrayBinding(ArrayBinding<'alloc>), 556 } 557 558 #[derive(Debug, PartialEq)] 559 pub enum Binding<'alloc> { 560 BindingPattern(BindingPattern<'alloc>), 561 BindingIdentifier(BindingIdentifier), 562 } 563 564 #[derive(Debug, PartialEq)] 565 pub enum SimpleAssignmentTarget<'alloc> { 566 AssignmentTargetIdentifier(AssignmentTargetIdentifier), 567 MemberAssignmentTarget(MemberAssignmentTarget<'alloc>), 568 } 569 570 #[derive(Debug, PartialEq)] 571 pub enum AssignmentTargetPattern<'alloc> { 572 ArrayAssignmentTarget(ArrayAssignmentTarget<'alloc>), 573 ObjectAssignmentTarget(ObjectAssignmentTarget<'alloc>), 574 } 575 576 #[derive(Debug, PartialEq)] 577 pub enum AssignmentTarget<'alloc> { 578 AssignmentTargetPattern(AssignmentTargetPattern<'alloc>), 579 SimpleAssignmentTarget(SimpleAssignmentTarget<'alloc>), 580 } 581 582 #[derive(Debug, PartialEq)] 583 pub enum Parameter<'alloc> { 584 Binding(Binding<'alloc>), 585 BindingWithDefault(BindingWithDefault<'alloc>), 586 } 587 588 #[derive(Debug, PartialEq)] 589 pub struct BindingWithDefault<'alloc> { 590 pub binding: Binding<'alloc>, 591 pub init: arena::Box<'alloc, Expression<'alloc>>, 592 pub loc: SourceLocation, 593 } 594 595 #[derive(Debug, PartialEq)] 596 pub struct BindingIdentifier { 597 pub name: Identifier, 598 pub loc: SourceLocation, 599 } 600 601 #[derive(Debug, PartialEq)] 602 pub struct AssignmentTargetIdentifier { 603 pub name: Identifier, 604 pub loc: SourceLocation, 605 } 606 607 #[derive(Debug, PartialEq)] 608 pub enum ExpressionOrSuper<'alloc> { 609 Expression(arena::Box<'alloc, Expression<'alloc>>), 610 Super { 611 loc: SourceLocation, 612 }, 613 } 614 615 #[derive(Debug, PartialEq)] 616 pub enum MemberAssignmentTarget<'alloc> { 617 ComputedMemberAssignmentTarget(ComputedMemberAssignmentTarget<'alloc>), 618 PrivateFieldAssignmentTarget(PrivateFieldAssignmentTarget<'alloc>), 619 StaticMemberAssignmentTarget(StaticMemberAssignmentTarget<'alloc>), 620 } 621 622 #[derive(Debug, PartialEq)] 623 pub struct ComputedMemberAssignmentTarget<'alloc> { 624 pub object: ExpressionOrSuper<'alloc>, 625 pub expression: arena::Box<'alloc, Expression<'alloc>>, 626 pub loc: SourceLocation, 627 } 628 629 #[derive(Debug, PartialEq)] 630 pub struct PrivateFieldAssignmentTarget<'alloc> { 631 pub object: ExpressionOrSuper<'alloc>, 632 pub field: PrivateIdentifier, 633 pub loc: SourceLocation, 634 } 635 636 #[derive(Debug, PartialEq)] 637 pub struct StaticMemberAssignmentTarget<'alloc> { 638 pub object: ExpressionOrSuper<'alloc>, 639 pub property: IdentifierName, 640 pub loc: SourceLocation, 641 } 642 643 #[derive(Debug, PartialEq)] 644 pub struct ArrayBinding<'alloc> { 645 pub elements: arena::Vec<'alloc, Option<Parameter<'alloc>>>, 646 pub rest: Option<arena::Box<'alloc, Binding<'alloc>>>, 647 pub loc: SourceLocation, 648 } 649 650 #[derive(Debug, PartialEq)] 651 pub struct ObjectBinding<'alloc> { 652 pub properties: arena::Vec<'alloc, BindingProperty<'alloc>>, 653 pub rest: Option<arena::Box<'alloc, BindingIdentifier>>, 654 pub loc: SourceLocation, 655 } 656 657 #[derive(Debug, PartialEq)] 658 pub enum BindingProperty<'alloc> { 659 BindingPropertyIdentifier(BindingPropertyIdentifier<'alloc>), 660 BindingPropertyProperty(BindingPropertyProperty<'alloc>), 661 } 662 663 #[derive(Debug, PartialEq)] 664 pub struct BindingPropertyIdentifier<'alloc> { 665 pub binding: BindingIdentifier, 666 pub init: Option<arena::Box<'alloc, Expression<'alloc>>>, 667 pub loc: SourceLocation, 668 } 669 670 #[derive(Debug, PartialEq)] 671 pub struct BindingPropertyProperty<'alloc> { 672 pub name: PropertyName<'alloc>, 673 pub binding: Parameter<'alloc>, 674 pub loc: SourceLocation, 675 } 676 677 #[derive(Debug, PartialEq)] 678 pub struct AssignmentTargetWithDefault<'alloc> { 679 pub binding: AssignmentTarget<'alloc>, 680 pub init: arena::Box<'alloc, Expression<'alloc>>, 681 pub loc: SourceLocation, 682 } 683 684 #[derive(Debug, PartialEq)] 685 pub enum AssignmentTargetMaybeDefault<'alloc> { 686 AssignmentTarget(AssignmentTarget<'alloc>), 687 AssignmentTargetWithDefault(AssignmentTargetWithDefault<'alloc>), 688 } 689 690 #[derive(Debug, PartialEq)] 691 pub struct ArrayAssignmentTarget<'alloc> { 692 pub elements: arena::Vec<'alloc, Option<AssignmentTargetMaybeDefault<'alloc>>>, 693 pub rest: Option<arena::Box<'alloc, AssignmentTarget<'alloc>>>, 694 pub loc: SourceLocation, 695 } 696 697 #[derive(Debug, PartialEq)] 698 pub struct ObjectAssignmentTarget<'alloc> { 699 pub properties: arena::Vec<'alloc, AssignmentTargetProperty<'alloc>>, 700 pub rest: Option<arena::Box<'alloc, AssignmentTarget<'alloc>>>, 701 pub loc: SourceLocation, 702 } 703 704 #[derive(Debug, PartialEq)] 705 pub enum AssignmentTargetProperty<'alloc> { 706 AssignmentTargetPropertyIdentifier(AssignmentTargetPropertyIdentifier<'alloc>), 707 AssignmentTargetPropertyProperty(AssignmentTargetPropertyProperty<'alloc>), 708 } 709 710 #[derive(Debug, PartialEq)] 711 pub struct AssignmentTargetPropertyIdentifier<'alloc> { 712 pub binding: AssignmentTargetIdentifier, 713 pub init: Option<arena::Box<'alloc, Expression<'alloc>>>, 714 pub loc: SourceLocation, 715 } 716 717 #[derive(Debug, PartialEq)] 718 pub struct AssignmentTargetPropertyProperty<'alloc> { 719 pub name: PropertyName<'alloc>, 720 pub binding: AssignmentTargetMaybeDefault<'alloc>, 721 pub loc: SourceLocation, 722 } 723 724 #[derive(Debug, PartialEq)] 725 pub struct ClassExpression<'alloc> { 726 pub name: Option<BindingIdentifier>, 727 pub super_: Option<arena::Box<'alloc, Expression<'alloc>>>, 728 pub elements: arena::Vec<'alloc, arena::Box<'alloc, ClassElement<'alloc>>>, 729 pub loc: SourceLocation, 730 } 731 732 #[derive(Debug, PartialEq)] 733 pub struct ClassDeclaration<'alloc> { 734 pub name: BindingIdentifier, 735 pub super_: Option<arena::Box<'alloc, Expression<'alloc>>>, 736 pub elements: arena::Vec<'alloc, arena::Box<'alloc, ClassElement<'alloc>>>, 737 pub loc: SourceLocation, 738 } 739 740 #[derive(Debug, PartialEq)] 741 pub enum ClassElement<'alloc> { 742 MethodDefinition { 743 is_static: bool, 744 method: MethodDefinition<'alloc>, 745 loc: SourceLocation, 746 }, 747 FieldDefinition { 748 name: ClassElementName<'alloc>, 749 init: Option<arena::Box<'alloc, Expression<'alloc>>>, 750 loc: SourceLocation, 751 }, 752 } 753 754 #[derive(Debug, PartialEq)] 755 pub enum ModuleItems<'alloc> { 756 ImportDeclaration(ImportDeclaration<'alloc>), 757 ExportDeclaration(ExportDeclaration<'alloc>), 758 Statement(arena::Box<'alloc, Statement<'alloc>>), 759 } 760 761 #[derive(Debug, PartialEq)] 762 pub struct Module<'alloc> { 763 pub directives: arena::Vec<'alloc, Directive>, 764 pub items: arena::Vec<'alloc, ModuleItems<'alloc>>, 765 pub loc: SourceLocation, 766 } 767 768 #[derive(Debug, PartialEq)] 769 pub struct Import<'alloc> { 770 pub module_specifier: SourceAtomSetIndex, 771 pub default_binding: Option<BindingIdentifier>, 772 pub named_imports: arena::Vec<'alloc, ImportSpecifier>, 773 pub loc: SourceLocation, 774 } 775 776 #[derive(Debug, PartialEq)] 777 pub struct ImportNamespace { 778 pub module_specifier: SourceAtomSetIndex, 779 pub default_binding: Option<BindingIdentifier>, 780 pub namespace_binding: BindingIdentifier, 781 pub loc: SourceLocation, 782 } 783 784 #[derive(Debug, PartialEq)] 785 pub struct ImportSpecifier { 786 pub name: Option<IdentifierName>, 787 pub binding: BindingIdentifier, 788 pub loc: SourceLocation, 789 } 790 791 #[derive(Debug, PartialEq)] 792 pub struct ExportAllFrom { 793 pub module_specifier: SourceAtomSetIndex, 794 pub loc: SourceLocation, 795 } 796 797 #[derive(Debug, PartialEq)] 798 pub struct ExportFrom<'alloc> { 799 pub named_exports: arena::Vec<'alloc, ExportFromSpecifier>, 800 pub module_specifier: SourceAtomSetIndex, 801 pub loc: SourceLocation, 802 } 803 804 #[derive(Debug, PartialEq)] 805 pub struct ExportLocals<'alloc> { 806 pub named_exports: arena::Vec<'alloc, ExportLocalSpecifier>, 807 pub loc: SourceLocation, 808 } 809 810 #[derive(Debug, PartialEq)] 811 pub enum Export<'alloc> { 812 FunctionDeclaration(Function<'alloc>), 813 ClassDeclaration(ClassDeclaration<'alloc>), 814 VariableDeclaration(VariableDeclaration<'alloc>), 815 } 816 817 #[derive(Debug, PartialEq)] 818 pub enum ExportDefault<'alloc> { 819 FunctionDeclaration(Function<'alloc>), 820 ClassDeclaration(ClassDeclaration<'alloc>), 821 Expression(arena::Box<'alloc, Expression<'alloc>>), 822 } 823 824 #[derive(Debug, PartialEq)] 825 pub struct ExportFromSpecifier { 826 pub name: IdentifierName, 827 pub exported_name: Option<IdentifierName>, 828 pub loc: SourceLocation, 829 } 830 831 #[derive(Debug, PartialEq)] 832 pub struct ExportLocalSpecifier { 833 pub name: IdentifierExpression, 834 pub exported_name: Option<IdentifierName>, 835 pub loc: SourceLocation, 836 } 837 838 #[derive(Debug, PartialEq)] 839 pub struct Method<'alloc> { 840 pub name: ClassElementName<'alloc>, 841 pub is_async: bool, 842 pub is_generator: bool, 843 pub params: FormalParameters<'alloc>, 844 pub body: FunctionBody<'alloc>, 845 pub loc: SourceLocation, 846 } 847 848 #[derive(Debug, PartialEq)] 849 pub struct Getter<'alloc> { 850 pub property_name: ClassElementName<'alloc>, 851 pub body: FunctionBody<'alloc>, 852 pub loc: SourceLocation, 853 } 854 855 #[derive(Debug, PartialEq)] 856 pub struct Setter<'alloc> { 857 pub property_name: ClassElementName<'alloc>, 858 pub param: Parameter<'alloc>, 859 pub body: FunctionBody<'alloc>, 860 pub loc: SourceLocation, 861 } 862 863 #[derive(Debug, PartialEq)] 864 pub struct DataProperty<'alloc> { 865 pub property_name: PropertyName<'alloc>, 866 pub expression: arena::Box<'alloc, Expression<'alloc>>, 867 pub loc: SourceLocation, 868 } 869 870 #[derive(Debug, PartialEq)] 871 pub struct ShorthandProperty { 872 pub name: IdentifierExpression, 873 pub loc: SourceLocation, 874 } 875 876 #[derive(Debug, PartialEq)] 877 pub struct ComputedPropertyName<'alloc> { 878 pub expression: arena::Box<'alloc, Expression<'alloc>>, 879 pub loc: SourceLocation, 880 } 881 882 #[derive(Debug, PartialEq)] 883 pub struct StaticPropertyName { 884 pub value: SourceAtomSetIndex, 885 pub loc: SourceLocation, 886 } 887 888 #[derive(Debug, PartialEq)] 889 pub struct NumericLiteral { 890 pub value: f64, 891 pub loc: SourceLocation, 892 } 893 894 #[derive(Debug, PartialEq)] 895 pub enum ArrayExpressionElement<'alloc> { 896 SpreadElement(arena::Box<'alloc, Expression<'alloc>>), 897 Expression(arena::Box<'alloc, Expression<'alloc>>), 898 Elision { 899 loc: SourceLocation, 900 }, 901 } 902 903 #[derive(Debug, PartialEq)] 904 pub struct ArrayExpression<'alloc> { 905 pub elements: arena::Vec<'alloc, ArrayExpressionElement<'alloc>>, 906 pub loc: SourceLocation, 907 } 908 909 #[derive(Debug, PartialEq)] 910 pub enum ArrowExpressionBody<'alloc> { 911 FunctionBody(FunctionBody<'alloc>), 912 Expression(arena::Box<'alloc, Expression<'alloc>>), 913 } 914 915 #[derive(Debug, PartialEq)] 916 pub struct ComputedMemberExpression<'alloc> { 917 pub object: ExpressionOrSuper<'alloc>, 918 pub expression: arena::Box<'alloc, Expression<'alloc>>, 919 pub loc: SourceLocation, 920 } 921 922 #[derive(Debug, PartialEq)] 923 pub struct IdentifierExpression { 924 pub name: Identifier, 925 pub loc: SourceLocation, 926 } 927 928 #[derive(Debug, PartialEq)] 929 pub struct ObjectExpression<'alloc> { 930 pub properties: arena::Vec<'alloc, arena::Box<'alloc, ObjectProperty<'alloc>>>, 931 pub loc: SourceLocation, 932 } 933 934 #[derive(Debug, PartialEq)] 935 pub struct StaticMemberExpression<'alloc> { 936 pub object: ExpressionOrSuper<'alloc>, 937 pub property: IdentifierName, 938 pub loc: SourceLocation, 939 } 940 941 #[derive(Debug, PartialEq)] 942 pub struct PrivateFieldExpression<'alloc> { 943 pub object: ExpressionOrSuper<'alloc>, 944 pub field: PrivateIdentifier, 945 pub loc: SourceLocation, 946 } 947 948 #[derive(Debug, PartialEq)] 949 pub enum TemplateExpressionElement<'alloc> { 950 Expression(arena::Box<'alloc, Expression<'alloc>>), 951 TemplateElement(TemplateElement), 952 } 953 954 #[derive(Debug, PartialEq)] 955 pub struct TemplateExpression<'alloc> { 956 pub tag: Option<arena::Box<'alloc, Expression<'alloc>>>, 957 pub elements: arena::Vec<'alloc, TemplateExpressionElement<'alloc>>, 958 pub loc: SourceLocation, 959 } 960 961 #[derive(Debug, PartialEq)] 962 pub enum VariableDeclarationOrAssignmentTarget<'alloc> { 963 VariableDeclaration(VariableDeclaration<'alloc>), 964 AssignmentTarget(AssignmentTarget<'alloc>), 965 } 966 967 #[derive(Debug, PartialEq)] 968 pub enum VariableDeclarationOrExpression<'alloc> { 969 VariableDeclaration(VariableDeclaration<'alloc>), 970 Expression(arena::Box<'alloc, Expression<'alloc>>), 971 } 972 973 #[derive(Debug, PartialEq)] 974 pub struct Block<'alloc> { 975 pub statements: arena::Vec<'alloc, Statement<'alloc>>, 976 pub declarations: Option<arena::Vec<'alloc, SourceAtomSetIndex>>, 977 pub loc: SourceLocation, 978 } 979 980 #[derive(Debug, PartialEq)] 981 pub struct CatchClause<'alloc> { 982 pub binding: Option<arena::Box<'alloc, Binding<'alloc>>>, 983 pub body: Block<'alloc>, 984 pub loc: SourceLocation, 985 } 986 987 #[derive(Debug, PartialEq)] 988 pub struct Directive { 989 pub raw_value: SourceAtomSetIndex, 990 pub loc: SourceLocation, 991 } 992 993 #[derive(Debug, PartialEq)] 994 pub struct FormalParameters<'alloc> { 995 pub items: arena::Vec<'alloc, Parameter<'alloc>>, 996 pub rest: Option<Binding<'alloc>>, 997 pub loc: SourceLocation, 998 } 999 1000 #[derive(Debug, PartialEq)] 1001 pub struct FunctionBody<'alloc> { 1002 pub directives: arena::Vec<'alloc, Directive>, 1003 pub statements: arena::Vec<'alloc, Statement<'alloc>>, 1004 pub loc: SourceLocation, 1005 } 1006 1007 #[derive(Debug, PartialEq)] 1008 pub struct Script<'alloc> { 1009 pub directives: arena::Vec<'alloc, Directive>, 1010 pub statements: arena::Vec<'alloc, Statement<'alloc>>, 1011 pub loc: SourceLocation, 1012 } 1013 1014 #[derive(Debug, PartialEq)] 1015 pub struct SwitchCase<'alloc> { 1016 pub test: arena::Box<'alloc, Expression<'alloc>>, 1017 pub consequent: arena::Vec<'alloc, Statement<'alloc>>, 1018 pub loc: SourceLocation, 1019 } 1020 1021 #[derive(Debug, PartialEq)] 1022 pub struct SwitchDefault<'alloc> { 1023 pub consequent: arena::Vec<'alloc, Statement<'alloc>>, 1024 pub loc: SourceLocation, 1025 } 1026 1027 #[derive(Debug, PartialEq)] 1028 pub struct TemplateElement { 1029 pub raw_value: SourceAtomSetIndex, 1030 pub loc: SourceLocation, 1031 } 1032 1033 #[derive(Debug, PartialEq)] 1034 pub struct VariableDeclaration<'alloc> { 1035 pub kind: VariableDeclarationKind, 1036 pub declarators: arena::Vec<'alloc, VariableDeclarator<'alloc>>, 1037 pub loc: SourceLocation, 1038 } 1039 1040 #[derive(Debug, PartialEq)] 1041 pub struct VariableDeclarator<'alloc> { 1042 pub binding: Binding<'alloc>, 1043 pub init: Option<arena::Box<'alloc, Expression<'alloc>>>, 1044 pub loc: SourceLocation, 1045 } 1046 1047 #[derive(Debug, PartialEq)] 1048 pub enum CoverParenthesized<'alloc> { 1049 Expression { 1050 expression: arena::Box<'alloc, Expression<'alloc>>, 1051 loc: SourceLocation, 1052 }, 1053 Parameters(arena::Box<'alloc, FormalParameters<'alloc>>), 1054 } 1055 1056