| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library tree_ir_nodes; | 5 library tree_ir_nodes; |
| 6 | 6 |
| 7 import '../constants/expressions.dart'; | 7 import '../constants/expressions.dart'; |
| 8 import '../constants/values.dart' as values; | 8 import '../constants/values.dart' as values; |
| 9 import '../dart_types.dart' show DartType, GenericType, InterfaceType, TypeVaria
bleType; | 9 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; |
| 10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
| 11 import '../io/source_information.dart' show SourceInformation; | 11 import '../io/source_information.dart' show SourceInformation; |
| 12 import '../universe/universe.dart'; | |
| 13 import '../universe/universe.dart' show Selector; | 12 import '../universe/universe.dart' show Selector; |
| 14 | 13 |
| 15 // The Tree language is the target of translation out of the CPS-based IR. | 14 // The Tree language is the target of translation out of the CPS-based IR. |
| 16 // | 15 // |
| 17 // The translation from CPS to Dart consists of several stages. Among the | 16 // The translation from CPS to Dart consists of several stages. Among the |
| 18 // stages are translation to direct style, translation out of SSA, eliminating | 17 // stages are translation to direct style, translation out of SSA, eliminating |
| 19 // unnecessary names, recognizing high-level control constructs. Combining | 18 // unnecessary names, recognizing high-level control constructs. Combining |
| 20 // these separate concerns is complicated and the constraints of the CPS-based | 19 // these separate concerns is complicated and the constraints of the CPS-based |
| 21 // language do not permit a multi-stage translation. | 20 // language do not permit a multi-stage translation. |
| 22 // | 21 // |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitConstant(this, arg); | 280 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitConstant(this, arg); |
| 282 | 281 |
| 283 values.ConstantValue get value => expression.value; | 282 values.ConstantValue get value => expression.value; |
| 284 } | 283 } |
| 285 | 284 |
| 286 class This extends Expression { | 285 class This extends Expression { |
| 287 accept(ExpressionVisitor visitor) => visitor.visitThis(this); | 286 accept(ExpressionVisitor visitor) => visitor.visitThis(this); |
| 288 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitThis(this, arg); | 287 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitThis(this, arg); |
| 289 } | 288 } |
| 290 | 289 |
| 291 class ReifyTypeVar extends Expression implements DartSpecificNode { | |
| 292 TypeVariableElement typeVariable; | |
| 293 | |
| 294 ReifyTypeVar(this.typeVariable); | |
| 295 | |
| 296 accept(ExpressionVisitor visitor) => visitor.visitReifyTypeVar(this); | |
| 297 accept1(ExpressionVisitor1 visitor, arg) { | |
| 298 return visitor.visitReifyTypeVar(this, arg); | |
| 299 } | |
| 300 } | |
| 301 | |
| 302 class LiteralList extends Expression { | 290 class LiteralList extends Expression { |
| 303 final GenericType type; | 291 final InterfaceType type; |
| 304 final List<Expression> values; | 292 final List<Expression> values; |
| 305 | 293 |
| 306 LiteralList(this.type, this.values); | 294 LiteralList(this.type, this.values); |
| 307 | 295 |
| 308 accept(ExpressionVisitor visitor) => visitor.visitLiteralList(this); | 296 accept(ExpressionVisitor visitor) => visitor.visitLiteralList(this); |
| 309 accept1(ExpressionVisitor1 visitor, arg) { | 297 accept1(ExpressionVisitor1 visitor, arg) { |
| 310 return visitor.visitLiteralList(this, arg); | 298 return visitor.visitLiteralList(this, arg); |
| 311 } | 299 } |
| 312 } | 300 } |
| 313 | 301 |
| 314 class LiteralMapEntry { | 302 class LiteralMapEntry { |
| 315 Expression key; | 303 Expression key; |
| 316 Expression value; | 304 Expression value; |
| 317 | 305 |
| 318 LiteralMapEntry(this.key, this.value); | 306 LiteralMapEntry(this.key, this.value); |
| 319 } | 307 } |
| 320 | 308 |
| 321 class LiteralMap extends Expression { | 309 class LiteralMap extends Expression { |
| 322 final GenericType type; | 310 final InterfaceType type; |
| 323 final List<LiteralMapEntry> entries; | 311 final List<LiteralMapEntry> entries; |
| 324 | 312 |
| 325 LiteralMap(this.type, this.entries); | 313 LiteralMap(this.type, this.entries); |
| 326 | 314 |
| 327 accept(ExpressionVisitor visitor) => visitor.visitLiteralMap(this); | 315 accept(ExpressionVisitor visitor) => visitor.visitLiteralMap(this); |
| 328 accept1(ExpressionVisitor1 visitor, arg) { | 316 accept1(ExpressionVisitor1 visitor, arg) { |
| 329 return visitor.visitLiteralMap(this, arg); | 317 return visitor.visitLiteralMap(this, arg); |
| 330 } | 318 } |
| 331 } | 319 } |
| 332 | 320 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 /// Logical negation. | 371 /// Logical negation. |
| 384 class Not extends Expression { | 372 class Not extends Expression { |
| 385 Expression operand; | 373 Expression operand; |
| 386 | 374 |
| 387 Not(this.operand); | 375 Not(this.operand); |
| 388 | 376 |
| 389 accept(ExpressionVisitor visitor) => visitor.visitNot(this); | 377 accept(ExpressionVisitor visitor) => visitor.visitNot(this); |
| 390 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitNot(this, arg); | 378 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitNot(this, arg); |
| 391 } | 379 } |
| 392 | 380 |
| 393 class FunctionExpression extends Expression implements DartSpecificNode { | 381 /// Currently unused. |
| 382 /// |
| 383 /// See CreateFunction in the cps_ir_nodes.dart. |
| 384 class FunctionExpression extends Expression { |
| 394 final FunctionDefinition definition; | 385 final FunctionDefinition definition; |
| 395 | 386 |
| 396 FunctionExpression(this.definition); | 387 FunctionExpression(this.definition); |
| 397 | 388 |
| 398 accept(ExpressionVisitor visitor) => visitor.visitFunctionExpression(this); | 389 accept(ExpressionVisitor visitor) => visitor.visitFunctionExpression(this); |
| 399 accept1(ExpressionVisitor1 visitor, arg) { | 390 accept1(ExpressionVisitor1 visitor, arg) { |
| 400 return visitor.visitFunctionExpression(this, arg); | 391 return visitor.visitFunctionExpression(this, arg); |
| 401 } | 392 } |
| 402 } | 393 } |
| 403 | 394 |
| 404 /// Declares a local function. | |
| 405 /// Used for functions that may not occur in expression context due to | |
| 406 /// being recursive or having a return type. | |
| 407 /// The [variable] must not occur as the left-hand side of an [Assign] or | |
| 408 /// any other [FunctionDeclaration]. | |
| 409 class FunctionDeclaration extends Statement implements DartSpecificNode { | |
| 410 Variable variable; | |
| 411 final FunctionDefinition definition; | |
| 412 Statement next; | |
| 413 | |
| 414 FunctionDeclaration(this.variable, this.definition, this.next) { | |
| 415 ++variable.writeCount; | |
| 416 } | |
| 417 | |
| 418 accept(StatementVisitor visitor) => visitor.visitFunctionDeclaration(this); | |
| 419 accept1(StatementVisitor1 visitor, arg) { | |
| 420 return visitor.visitFunctionDeclaration(this, arg); | |
| 421 } | |
| 422 } | |
| 423 | |
| 424 /// A [LabeledStatement] or [WhileTrue] or [WhileCondition]. | 395 /// A [LabeledStatement] or [WhileTrue] or [WhileCondition]. |
| 425 abstract class JumpTarget extends Statement { | 396 abstract class JumpTarget extends Statement { |
| 426 Label get label; | 397 Label get label; |
| 427 Statement get body; | 398 Statement get body; |
| 428 } | 399 } |
| 429 | 400 |
| 430 /** | 401 /** |
| 431 * A labeled statement. Breaks to the label within the labeled statement | 402 * A labeled statement. Breaks to the label within the labeled statement |
| 432 * target the successor statement. | 403 * target the successor statement. |
| 433 */ | 404 */ |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 void set next(Statement s) => throw 'UNREACHABLE'; | 503 void set next(Statement s) => throw 'UNREACHABLE'; |
| 533 | 504 |
| 534 Continue(this.target) { | 505 Continue(this.target) { |
| 535 ++target.useCount; | 506 ++target.useCount; |
| 536 } | 507 } |
| 537 | 508 |
| 538 accept(StatementVisitor visitor) => visitor.visitContinue(this); | 509 accept(StatementVisitor visitor) => visitor.visitContinue(this); |
| 539 accept1(StatementVisitor1 visitor, arg) => visitor.visitContinue(this, arg); | 510 accept1(StatementVisitor1 visitor, arg) => visitor.visitContinue(this, arg); |
| 540 } | 511 } |
| 541 | 512 |
| 542 /// Declares a captured [variable] with an initial [value]. | |
| 543 /// | |
| 544 /// All uses of the variable must be inside the [next] statement. | |
| 545 class VariableDeclaration extends Statement implements DartSpecificNode { | |
| 546 Variable variable; | |
| 547 Expression value; | |
| 548 Statement next; | |
| 549 | |
| 550 VariableDeclaration(this.variable, this.value, this.next) { | |
| 551 assert(variable.isCaptured); // Because otherwise no declaration is needed. | |
| 552 ++variable.writeCount; | |
| 553 } | |
| 554 | |
| 555 accept(StatementVisitor visitor) { | |
| 556 return visitor.visitVariableDeclaration(this); | |
| 557 } | |
| 558 | |
| 559 accept1(StatementVisitor1 visitor, arg) { | |
| 560 return visitor.visitVariableDeclaration(this, arg); | |
| 561 } | |
| 562 } | |
| 563 | |
| 564 /** | 513 /** |
| 565 * A return exit from the function. | 514 * A return exit from the function. |
| 566 * | 515 * |
| 567 * In contrast to the CPS-based IR, the return value is an arbitrary | 516 * In contrast to the CPS-based IR, the return value is an arbitrary |
| 568 * expression. | 517 * expression. |
| 569 */ | 518 */ |
| 570 class Return extends Statement { | 519 class Return extends Statement { |
| 571 /// Should not be null. Use [Constant] with [NullConstantValue] for void | 520 /// Should not be null. Use [Constant] with [NullConstantValue] for void |
| 572 /// returns. | 521 /// returns. |
| 573 /// Even in constructors this holds true. Take special care when translating | 522 /// Even in constructors this holds true. Take special care when translating |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 variable.writeCount++; // Being a catch parameter counts as a write. | 605 variable.writeCount++; // Being a catch parameter counts as a write. |
| 657 } | 606 } |
| 658 } | 607 } |
| 659 | 608 |
| 660 accept(StatementVisitor visitor) => visitor.visitTry(this); | 609 accept(StatementVisitor visitor) => visitor.visitTry(this); |
| 661 accept1(StatementVisitor1 visitor, arg) { | 610 accept1(StatementVisitor1 visitor, arg) { |
| 662 return visitor.visitTry(this, arg); | 611 return visitor.visitTry(this, arg); |
| 663 } | 612 } |
| 664 } | 613 } |
| 665 | 614 |
| 666 abstract class RootNode extends Node { | 615 class FunctionDefinition extends Node { |
| 667 ExecutableElement get element; | |
| 668 List<Variable> get parameters; | |
| 669 | |
| 670 /// True if there is no body for this root node. | |
| 671 /// | |
| 672 /// In some parts of the compiler, empty root nodes are used as placeholders | |
| 673 /// for abstract methods, external constructors, fields without initializers, | |
| 674 /// etc. | |
| 675 bool get isEmpty; | |
| 676 | |
| 677 void forEachBody(void action(Statement node)); | |
| 678 void replaceEachBody(Statement transform(Statement node)); | |
| 679 | |
| 680 accept(RootVisitor v); | |
| 681 accept1(RootVisitor1 v, arg); | |
| 682 } | |
| 683 | |
| 684 class FieldDefinition extends RootNode implements DartSpecificNode { | |
| 685 final FieldElement element; | |
| 686 // The `body` of a field is its initializer. | |
| 687 Statement body; | |
| 688 List<Variable> get parameters => const <Variable>[]; | |
| 689 | |
| 690 FieldDefinition(this.element, this.body); | |
| 691 | |
| 692 bool get isEmpty => body == null; | |
| 693 | |
| 694 accept(RootVisitor v) => v.visitFieldDefinition(this); | |
| 695 accept1(RootVisitor1 v, arg) => v.visitFieldDefinition(this, arg); | |
| 696 | |
| 697 void forEachBody(void action(Statement node)) { | |
| 698 if (isEmpty) return; | |
| 699 action(body); | |
| 700 } | |
| 701 | |
| 702 void replaceEachBody(Statement transform(Statement node)) { | |
| 703 if (isEmpty) return; | |
| 704 body = transform(body); | |
| 705 } | |
| 706 } | |
| 707 | |
| 708 class FunctionDefinition extends RootNode { | |
| 709 final ExecutableElement element; | 616 final ExecutableElement element; |
| 710 final List<Variable> parameters; | 617 final List<Variable> parameters; |
| 711 Statement body; | 618 Statement body; |
| 712 final List<ConstDeclaration> localConstants; | |
| 713 final List<ConstantExpression> defaultParameterValues; | |
| 714 | 619 |
| 715 /// Creates a function definition and updates `writeCount` for [parameters]. | 620 /// Creates a function definition and updates `writeCount` for [parameters]. |
| 716 FunctionDefinition(this.element, this.parameters, this.body, | 621 FunctionDefinition(this.element, this.parameters, this.body) { |
| 717 this.localConstants, this.defaultParameterValues) { | |
| 718 for (Variable param in parameters) { | 622 for (Variable param in parameters) { |
| 719 param.writeCount++; // Being a parameter counts as a write. | 623 param.writeCount++; // Being a parameter counts as a write. |
| 720 } | 624 } |
| 721 } | 625 } |
| 722 | |
| 723 bool get isEmpty => body == null; | |
| 724 | |
| 725 accept(RootVisitor v) => v.visitFunctionDefinition(this); | |
| 726 accept1(RootVisitor1 v, arg) => v.visitFunctionDefinition(this, arg); | |
| 727 | |
| 728 void forEachBody(void action(Statement node)) { | |
| 729 if (isEmpty) return; | |
| 730 action(body); | |
| 731 } | |
| 732 | |
| 733 void replaceEachBody(Statement transform(Statement node)) { | |
| 734 if (isEmpty) return; | |
| 735 body = transform(body); | |
| 736 } | |
| 737 } | 626 } |
| 738 | 627 |
| 739 abstract class Initializer implements DartSpecificNode { | 628 class CreateBox extends Expression { |
| 740 accept(InitializerVisitor v); | |
| 741 accept1(InitializerVisitor1 v, arg); | |
| 742 | |
| 743 void forEachBody(void action(Statement node)); | |
| 744 void replaceEachBody(Statement transform(Statement node)); | |
| 745 } | |
| 746 | |
| 747 class FieldInitializer extends Initializer { | |
| 748 final FieldElement element; | |
| 749 Statement body; | |
| 750 bool processed = false; | |
| 751 | |
| 752 FieldInitializer(this.element, this.body); | |
| 753 | |
| 754 accept(InitializerVisitor visitor) => visitor.visitFieldInitializer(this); | |
| 755 accept1(InitializerVisitor1 visitor, arg) { | |
| 756 return visitor.visitFieldInitializer(this, arg); | |
| 757 } | |
| 758 | |
| 759 void forEachBody(void action(Statement node)) { | |
| 760 action(body); | |
| 761 } | |
| 762 | |
| 763 void replaceEachBody(Statement transform(Statement node)) { | |
| 764 body = transform(body); | |
| 765 } | |
| 766 } | |
| 767 | |
| 768 class SuperInitializer extends Initializer { | |
| 769 final ConstructorElement target; | |
| 770 final Selector selector; | |
| 771 final List<Statement> arguments; | |
| 772 bool processed = false; | |
| 773 | |
| 774 SuperInitializer(this.target, this.selector, this.arguments); | |
| 775 accept(InitializerVisitor visitor) => visitor.visitSuperInitializer(this); | |
| 776 accept1(InitializerVisitor1 visitor, arg) { | |
| 777 return visitor.visitSuperInitializer(this, arg); | |
| 778 } | |
| 779 | |
| 780 void forEachBody(void action(Statement node)) { | |
| 781 arguments.forEach(action); | |
| 782 } | |
| 783 | |
| 784 void replaceEachBody(Statement transform(Statement node)) { | |
| 785 for (int i = 0; i < arguments.length; i++) { | |
| 786 arguments[i] = transform(arguments[i]); | |
| 787 } | |
| 788 } | |
| 789 } | |
| 790 | |
| 791 class ConstructorDefinition extends RootNode | |
| 792 implements DartSpecificNode { | |
| 793 final ConstructorElement element; | |
| 794 final List<Variable> parameters; | |
| 795 Statement body; | |
| 796 final List<ConstDeclaration> localConstants; | |
| 797 final List<ConstantExpression> defaultParameterValues; | |
| 798 final List<Initializer> initializers; | |
| 799 | |
| 800 ConstructorDefinition(this.element, | |
| 801 this.parameters, | |
| 802 this.body, | |
| 803 this.initializers, | |
| 804 this.localConstants, | |
| 805 this.defaultParameterValues) { | |
| 806 for (Variable param in parameters) { | |
| 807 param.writeCount++; // Being a parameter counts as a write. | |
| 808 } | |
| 809 } | |
| 810 | |
| 811 bool get isEmpty => body == null; | |
| 812 | |
| 813 accept(RootVisitor v) => v.visitConstructorDefinition(this); | |
| 814 accept1(RootVisitor1 v, arg) => v.visitConstructorDefinition(this, arg); | |
| 815 | |
| 816 void forEachBody(void action(Statement node)) { | |
| 817 if (isEmpty) return; | |
| 818 for (Initializer init in initializers) { | |
| 819 init.forEachBody(action); | |
| 820 } | |
| 821 action(body); | |
| 822 } | |
| 823 | |
| 824 void replaceEachBody(Statement transform(Statement node)) { | |
| 825 if (isEmpty) return; | |
| 826 for (Initializer init in initializers) { | |
| 827 init.replaceEachBody(transform); | |
| 828 } | |
| 829 body = transform(body); | |
| 830 } | |
| 831 } | |
| 832 | |
| 833 abstract class JsSpecificNode implements Node {} | |
| 834 | |
| 835 abstract class DartSpecificNode implements Node {} | |
| 836 | |
| 837 class CreateBox extends Expression implements JsSpecificNode { | |
| 838 accept(ExpressionVisitor visitor) => visitor.visitCreateBox(this); | 629 accept(ExpressionVisitor visitor) => visitor.visitCreateBox(this); |
| 839 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitCreateBox(this, arg); | 630 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitCreateBox(this, arg); |
| 840 } | 631 } |
| 841 | 632 |
| 842 class CreateInstance extends Expression implements JsSpecificNode { | 633 class CreateInstance extends Expression { |
| 843 ClassElement classElement; | 634 ClassElement classElement; |
| 844 List<Expression> arguments; | 635 List<Expression> arguments; |
| 845 List<Expression> typeInformation; | 636 List<Expression> typeInformation; |
| 846 | 637 |
| 847 CreateInstance(this.classElement, this.arguments, this.typeInformation); | 638 CreateInstance(this.classElement, this.arguments, this.typeInformation); |
| 848 | 639 |
| 849 accept(ExpressionVisitor visitor) => visitor.visitCreateInstance(this); | 640 accept(ExpressionVisitor visitor) => visitor.visitCreateInstance(this); |
| 850 accept1(ExpressionVisitor1 visitor, arg) { | 641 accept1(ExpressionVisitor1 visitor, arg) { |
| 851 return visitor.visitCreateInstance(this, arg); | 642 return visitor.visitCreateInstance(this, arg); |
| 852 } | 643 } |
| 853 } | 644 } |
| 854 | 645 |
| 855 class GetField extends Expression implements JsSpecificNode { | 646 class GetField extends Expression { |
| 856 Expression object; | 647 Expression object; |
| 857 Element field; | 648 Element field; |
| 858 | 649 |
| 859 GetField(this.object, this.field); | 650 GetField(this.object, this.field); |
| 860 | 651 |
| 861 accept(ExpressionVisitor visitor) => visitor.visitGetField(this); | 652 accept(ExpressionVisitor visitor) => visitor.visitGetField(this); |
| 862 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitGetField(this, arg); | 653 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitGetField(this, arg); |
| 863 } | 654 } |
| 864 | 655 |
| 865 class SetField extends Expression implements JsSpecificNode { | 656 class SetField extends Expression { |
| 866 Expression object; | 657 Expression object; |
| 867 Element field; | 658 Element field; |
| 868 Expression value; | 659 Expression value; |
| 869 | 660 |
| 870 SetField(this.object, this.field, this.value); | 661 SetField(this.object, this.field, this.value); |
| 871 | 662 |
| 872 accept(ExpressionVisitor visitor) => visitor.visitSetField(this); | 663 accept(ExpressionVisitor visitor) => visitor.visitSetField(this); |
| 873 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitSetField(this, arg); | 664 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitSetField(this, arg); |
| 874 } | 665 } |
| 875 | 666 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 889 Element element; | 680 Element element; |
| 890 Expression value; | 681 Expression value; |
| 891 SourceInformation sourceInformation; | 682 SourceInformation sourceInformation; |
| 892 | 683 |
| 893 SetStatic(this.element, this.value, this.sourceInformation); | 684 SetStatic(this.element, this.value, this.sourceInformation); |
| 894 | 685 |
| 895 accept(ExpressionVisitor visitor) => visitor.visitSetStatic(this); | 686 accept(ExpressionVisitor visitor) => visitor.visitSetStatic(this); |
| 896 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitSetStatic(this, arg); | 687 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitSetStatic(this, arg); |
| 897 } | 688 } |
| 898 | 689 |
| 899 class ReifyRuntimeType extends Expression implements JsSpecificNode { | 690 class ReifyRuntimeType extends Expression { |
| 900 Expression value; | 691 Expression value; |
| 901 | 692 |
| 902 ReifyRuntimeType(this.value); | 693 ReifyRuntimeType(this.value); |
| 903 | 694 |
| 904 accept(ExpressionVisitor visitor) { | 695 accept(ExpressionVisitor visitor) { |
| 905 return visitor.visitReifyRuntimeType(this); | 696 return visitor.visitReifyRuntimeType(this); |
| 906 } | 697 } |
| 907 | 698 |
| 908 accept1(ExpressionVisitor1 visitor, arg) { | 699 accept1(ExpressionVisitor1 visitor, arg) { |
| 909 return visitor.visitReifyRuntimeType(this, arg); | 700 return visitor.visitReifyRuntimeType(this, arg); |
| 910 } | 701 } |
| 911 } | 702 } |
| 912 | 703 |
| 913 class ReadTypeVariable extends Expression implements JsSpecificNode { | 704 class ReadTypeVariable extends Expression { |
| 914 final TypeVariableType variable; | 705 final TypeVariableType variable; |
| 915 Expression target; | 706 Expression target; |
| 916 | 707 |
| 917 ReadTypeVariable(this.variable, this.target); | 708 ReadTypeVariable(this.variable, this.target); |
| 918 | 709 |
| 919 accept(ExpressionVisitor visitor) { | 710 accept(ExpressionVisitor visitor) { |
| 920 return visitor.visitReadTypeVariable(this); | 711 return visitor.visitReadTypeVariable(this); |
| 921 } | 712 } |
| 922 | 713 |
| 923 accept1(ExpressionVisitor1 visitor, arg) { | 714 accept1(ExpressionVisitor1 visitor, arg) { |
| 924 return visitor.visitReadTypeVariable(this, arg); | 715 return visitor.visitReadTypeVariable(this, arg); |
| 925 } | 716 } |
| 926 } | 717 } |
| 927 | 718 |
| 928 class CreateInvocationMirror extends Expression implements JsSpecificNode { | 719 class CreateInvocationMirror extends Expression { |
| 929 final Selector selector; | 720 final Selector selector; |
| 930 final List<Expression> arguments; | 721 final List<Expression> arguments; |
| 931 | 722 |
| 932 CreateInvocationMirror(this.selector, this.arguments); | 723 CreateInvocationMirror(this.selector, this.arguments); |
| 933 | 724 |
| 934 accept(ExpressionVisitor visitor) { | 725 accept(ExpressionVisitor visitor) { |
| 935 return visitor.visitCreateInvocationMirror(this); | 726 return visitor.visitCreateInvocationMirror(this); |
| 936 } | 727 } |
| 937 | 728 |
| 938 accept1(ExpressionVisitor1 visitor, arg) { | 729 accept1(ExpressionVisitor1 visitor, arg) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 962 E visitExpression(Expression node) => node.accept(this); | 753 E visitExpression(Expression node) => node.accept(this); |
| 963 E visitVariableUse(VariableUse node); | 754 E visitVariableUse(VariableUse node); |
| 964 E visitAssign(Assign node); | 755 E visitAssign(Assign node); |
| 965 E visitInvokeStatic(InvokeStatic node); | 756 E visitInvokeStatic(InvokeStatic node); |
| 966 E visitInvokeMethod(InvokeMethod node); | 757 E visitInvokeMethod(InvokeMethod node); |
| 967 E visitInvokeMethodDirectly(InvokeMethodDirectly node); | 758 E visitInvokeMethodDirectly(InvokeMethodDirectly node); |
| 968 E visitInvokeConstructor(InvokeConstructor node); | 759 E visitInvokeConstructor(InvokeConstructor node); |
| 969 E visitConcatenateStrings(ConcatenateStrings node); | 760 E visitConcatenateStrings(ConcatenateStrings node); |
| 970 E visitConstant(Constant node); | 761 E visitConstant(Constant node); |
| 971 E visitThis(This node); | 762 E visitThis(This node); |
| 972 E visitReifyTypeVar(ReifyTypeVar node); | |
| 973 E visitConditional(Conditional node); | 763 E visitConditional(Conditional node); |
| 974 E visitLogicalOperator(LogicalOperator node); | 764 E visitLogicalOperator(LogicalOperator node); |
| 975 E visitNot(Not node); | 765 E visitNot(Not node); |
| 976 E visitLiteralList(LiteralList node); | 766 E visitLiteralList(LiteralList node); |
| 977 E visitLiteralMap(LiteralMap node); | 767 E visitLiteralMap(LiteralMap node); |
| 978 E visitTypeOperator(TypeOperator node); | 768 E visitTypeOperator(TypeOperator node); |
| 979 E visitFunctionExpression(FunctionExpression node); | 769 E visitFunctionExpression(FunctionExpression node); |
| 980 E visitGetField(GetField node); | 770 E visitGetField(GetField node); |
| 981 E visitSetField(SetField node); | 771 E visitSetField(SetField node); |
| 982 E visitGetStatic(GetStatic node); | 772 E visitGetStatic(GetStatic node); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 993 E visitExpression(Expression node, A arg) => node.accept1(this, arg); | 783 E visitExpression(Expression node, A arg) => node.accept1(this, arg); |
| 994 E visitVariableUse(VariableUse node, A arg); | 784 E visitVariableUse(VariableUse node, A arg); |
| 995 E visitAssign(Assign node, A arg); | 785 E visitAssign(Assign node, A arg); |
| 996 E visitInvokeStatic(InvokeStatic node, A arg); | 786 E visitInvokeStatic(InvokeStatic node, A arg); |
| 997 E visitInvokeMethod(InvokeMethod node, A arg); | 787 E visitInvokeMethod(InvokeMethod node, A arg); |
| 998 E visitInvokeMethodDirectly(InvokeMethodDirectly node, A arg); | 788 E visitInvokeMethodDirectly(InvokeMethodDirectly node, A arg); |
| 999 E visitInvokeConstructor(InvokeConstructor node, A arg); | 789 E visitInvokeConstructor(InvokeConstructor node, A arg); |
| 1000 E visitConcatenateStrings(ConcatenateStrings node, A arg); | 790 E visitConcatenateStrings(ConcatenateStrings node, A arg); |
| 1001 E visitConstant(Constant node, A arg); | 791 E visitConstant(Constant node, A arg); |
| 1002 E visitThis(This node, A arg); | 792 E visitThis(This node, A arg); |
| 1003 E visitReifyTypeVar(ReifyTypeVar node, A arg); | |
| 1004 E visitConditional(Conditional node, A arg); | 793 E visitConditional(Conditional node, A arg); |
| 1005 E visitLogicalOperator(LogicalOperator node, A arg); | 794 E visitLogicalOperator(LogicalOperator node, A arg); |
| 1006 E visitNot(Not node, A arg); | 795 E visitNot(Not node, A arg); |
| 1007 E visitLiteralList(LiteralList node, A arg); | 796 E visitLiteralList(LiteralList node, A arg); |
| 1008 E visitLiteralMap(LiteralMap node, A arg); | 797 E visitLiteralMap(LiteralMap node, A arg); |
| 1009 E visitTypeOperator(TypeOperator node, A arg); | 798 E visitTypeOperator(TypeOperator node, A arg); |
| 1010 E visitFunctionExpression(FunctionExpression node, A arg); | 799 E visitFunctionExpression(FunctionExpression node, A arg); |
| 1011 E visitGetField(GetField node, A arg); | 800 E visitGetField(GetField node, A arg); |
| 1012 E visitSetField(SetField node, A arg); | 801 E visitSetField(SetField node, A arg); |
| 1013 E visitGetStatic(GetStatic node, A arg); | 802 E visitGetStatic(GetStatic node, A arg); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1024 S visitStatement(Statement node) => node.accept(this); | 813 S visitStatement(Statement node) => node.accept(this); |
| 1025 S visitLabeledStatement(LabeledStatement node); | 814 S visitLabeledStatement(LabeledStatement node); |
| 1026 S visitReturn(Return node); | 815 S visitReturn(Return node); |
| 1027 S visitThrow(Throw node); | 816 S visitThrow(Throw node); |
| 1028 S visitRethrow(Rethrow node); | 817 S visitRethrow(Rethrow node); |
| 1029 S visitBreak(Break node); | 818 S visitBreak(Break node); |
| 1030 S visitContinue(Continue node); | 819 S visitContinue(Continue node); |
| 1031 S visitIf(If node); | 820 S visitIf(If node); |
| 1032 S visitWhileTrue(WhileTrue node); | 821 S visitWhileTrue(WhileTrue node); |
| 1033 S visitWhileCondition(WhileCondition node); | 822 S visitWhileCondition(WhileCondition node); |
| 1034 S visitFunctionDeclaration(FunctionDeclaration node); | |
| 1035 S visitVariableDeclaration(VariableDeclaration node); | |
| 1036 S visitExpressionStatement(ExpressionStatement node); | 823 S visitExpressionStatement(ExpressionStatement node); |
| 1037 S visitTry(Try node); | 824 S visitTry(Try node); |
| 1038 } | 825 } |
| 1039 | 826 |
| 1040 abstract class StatementVisitor1<S, A> { | 827 abstract class StatementVisitor1<S, A> { |
| 1041 S visitStatement(Statement node, A arg) => node.accept1(this, arg); | 828 S visitStatement(Statement node, A arg) => node.accept1(this, arg); |
| 1042 S visitLabeledStatement(LabeledStatement node, A arg); | 829 S visitLabeledStatement(LabeledStatement node, A arg); |
| 1043 S visitReturn(Return node, A arg); | 830 S visitReturn(Return node, A arg); |
| 1044 S visitThrow(Throw node, A arg); | 831 S visitThrow(Throw node, A arg); |
| 1045 S visitRethrow(Rethrow node, A arg); | 832 S visitRethrow(Rethrow node, A arg); |
| 1046 S visitBreak(Break node, A arg); | 833 S visitBreak(Break node, A arg); |
| 1047 S visitContinue(Continue node, A arg); | 834 S visitContinue(Continue node, A arg); |
| 1048 S visitIf(If node, A arg); | 835 S visitIf(If node, A arg); |
| 1049 S visitWhileTrue(WhileTrue node, A arg); | 836 S visitWhileTrue(WhileTrue node, A arg); |
| 1050 S visitWhileCondition(WhileCondition node, A arg); | 837 S visitWhileCondition(WhileCondition node, A arg); |
| 1051 S visitFunctionDeclaration(FunctionDeclaration node, A arg); | |
| 1052 S visitVariableDeclaration(VariableDeclaration node, A arg); | |
| 1053 S visitExpressionStatement(ExpressionStatement node, A arg); | 838 S visitExpressionStatement(ExpressionStatement node, A arg); |
| 1054 S visitTry(Try node, A arg); | 839 S visitTry(Try node, A arg); |
| 1055 } | 840 } |
| 1056 | 841 |
| 1057 abstract class RootVisitor<T> { | |
| 1058 T visitRootNode(RootNode node) => node.accept(this); | |
| 1059 T visitFunctionDefinition(FunctionDefinition node); | |
| 1060 T visitConstructorDefinition(ConstructorDefinition node); | |
| 1061 T visitFieldDefinition(FieldDefinition node); | |
| 1062 } | |
| 1063 | |
| 1064 abstract class RootVisitor1<T, A> { | |
| 1065 T visitRootNode(RootNode node, A arg) => node.accept1(this, arg); | |
| 1066 T visitFunctionDefinition(FunctionDefinition node, A arg); | |
| 1067 T visitConstructorDefinition(ConstructorDefinition node, A arg); | |
| 1068 T visitFieldDefinition(FieldDefinition node, A arg); | |
| 1069 } | |
| 1070 | |
| 1071 abstract class InitializerVisitor<T> { | |
| 1072 T visitInitializer(Initializer node) => node.accept(this); | |
| 1073 T visitFieldInitializer(FieldInitializer node); | |
| 1074 T visitSuperInitializer(SuperInitializer node); | |
| 1075 } | |
| 1076 | |
| 1077 | |
| 1078 abstract class InitializerVisitor1<T, A> { | |
| 1079 T visitInitializer(Initializer node, A arg) => node.accept1(this, arg); | |
| 1080 T visitFieldInitializer(FieldInitializer node, A arg); | |
| 1081 T visitSuperInitializer(SuperInitializer node, A arg); | |
| 1082 } | |
| 1083 | |
| 1084 abstract class RecursiveVisitor implements StatementVisitor, ExpressionVisitor { | 842 abstract class RecursiveVisitor implements StatementVisitor, ExpressionVisitor { |
| 1085 visitExpression(Expression e) => e.accept(this); | 843 visitExpression(Expression e) => e.accept(this); |
| 1086 visitStatement(Statement s) => s.accept(this); | 844 visitStatement(Statement s) => s.accept(this); |
| 1087 | 845 |
| 1088 visitInnerFunction(FunctionDefinition node); | 846 visitInnerFunction(FunctionDefinition node); |
| 1089 | 847 |
| 1090 visitVariable(Variable variable) {} | 848 visitVariable(Variable variable) {} |
| 1091 | 849 |
| 1092 visitVariableUse(VariableUse node) { | 850 visitVariableUse(VariableUse node) { |
| 1093 visitVariable(node.variable); | 851 visitVariable(node.variable); |
| 1094 } | 852 } |
| 1095 | 853 |
| 1096 visitVariableDeclaration(VariableDeclaration node) { | |
| 1097 visitVariable(node.variable); | |
| 1098 visitStatement(node.next); | |
| 1099 } | |
| 1100 | |
| 1101 visitAssign(Assign node) { | 854 visitAssign(Assign node) { |
| 1102 visitVariable(node.variable); | 855 visitVariable(node.variable); |
| 1103 visitExpression(node.value); | 856 visitExpression(node.value); |
| 1104 } | 857 } |
| 1105 | 858 |
| 1106 visitInvokeStatic(InvokeStatic node) { | 859 visitInvokeStatic(InvokeStatic node) { |
| 1107 node.arguments.forEach(visitExpression); | 860 node.arguments.forEach(visitExpression); |
| 1108 } | 861 } |
| 1109 | 862 |
| 1110 visitInvokeMethod(InvokeMethod node) { | 863 visitInvokeMethod(InvokeMethod node) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1122 } | 875 } |
| 1123 | 876 |
| 1124 visitConcatenateStrings(ConcatenateStrings node) { | 877 visitConcatenateStrings(ConcatenateStrings node) { |
| 1125 node.arguments.forEach(visitExpression); | 878 node.arguments.forEach(visitExpression); |
| 1126 } | 879 } |
| 1127 | 880 |
| 1128 visitConstant(Constant node) {} | 881 visitConstant(Constant node) {} |
| 1129 | 882 |
| 1130 visitThis(This node) {} | 883 visitThis(This node) {} |
| 1131 | 884 |
| 1132 visitReifyTypeVar(ReifyTypeVar node) {} | |
| 1133 | |
| 1134 visitConditional(Conditional node) { | 885 visitConditional(Conditional node) { |
| 1135 visitExpression(node.condition); | 886 visitExpression(node.condition); |
| 1136 visitExpression(node.thenExpression); | 887 visitExpression(node.thenExpression); |
| 1137 visitExpression(node.elseExpression); | 888 visitExpression(node.elseExpression); |
| 1138 } | 889 } |
| 1139 | 890 |
| 1140 visitLogicalOperator(LogicalOperator node) { | 891 visitLogicalOperator(LogicalOperator node) { |
| 1141 visitExpression(node.left); | 892 visitExpression(node.left); |
| 1142 visitExpression(node.right); | 893 visitExpression(node.right); |
| 1143 } | 894 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1194 visitWhileTrue(WhileTrue node) { | 945 visitWhileTrue(WhileTrue node) { |
| 1195 visitStatement(node.body); | 946 visitStatement(node.body); |
| 1196 } | 947 } |
| 1197 | 948 |
| 1198 visitWhileCondition(WhileCondition node) { | 949 visitWhileCondition(WhileCondition node) { |
| 1199 visitExpression(node.condition); | 950 visitExpression(node.condition); |
| 1200 visitStatement(node.body); | 951 visitStatement(node.body); |
| 1201 visitStatement(node.next); | 952 visitStatement(node.next); |
| 1202 } | 953 } |
| 1203 | 954 |
| 1204 visitFunctionDeclaration(FunctionDeclaration node) { | |
| 1205 visitInnerFunction(node.definition); | |
| 1206 visitStatement(node.next); | |
| 1207 } | |
| 1208 | |
| 1209 visitExpressionStatement(ExpressionStatement node) { | 955 visitExpressionStatement(ExpressionStatement node) { |
| 1210 visitExpression(node.expression); | 956 visitExpression(node.expression); |
| 1211 visitStatement(node.next); | 957 visitStatement(node.next); |
| 1212 } | 958 } |
| 1213 | 959 |
| 1214 visitTry(Try node) { | 960 visitTry(Try node) { |
| 1215 visitStatement(node.tryBody); | 961 visitStatement(node.tryBody); |
| 1216 visitStatement(node.catchBody); | 962 visitStatement(node.catchBody); |
| 1217 } | 963 } |
| 1218 | 964 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1269 } | 1015 } |
| 1270 | 1016 |
| 1271 void _replaceExpressions(List<Expression> list) { | 1017 void _replaceExpressions(List<Expression> list) { |
| 1272 for (int i = 0; i < list.length; i++) { | 1018 for (int i = 0; i < list.length; i++) { |
| 1273 list[i] = visitExpression(list[i]); | 1019 list[i] = visitExpression(list[i]); |
| 1274 } | 1020 } |
| 1275 } | 1021 } |
| 1276 | 1022 |
| 1277 visitVariableUse(VariableUse node) => node; | 1023 visitVariableUse(VariableUse node) => node; |
| 1278 | 1024 |
| 1279 visitVariableDeclaration(VariableDeclaration node) { | |
| 1280 node.next = visitStatement(node.next); | |
| 1281 return node; | |
| 1282 } | |
| 1283 | |
| 1284 visitAssign(Assign node) { | 1025 visitAssign(Assign node) { |
| 1285 node.value = visitExpression(node.value); | 1026 node.value = visitExpression(node.value); |
| 1286 return node; | 1027 return node; |
| 1287 } | 1028 } |
| 1288 | 1029 |
| 1289 visitInvokeStatic(InvokeStatic node) { | 1030 visitInvokeStatic(InvokeStatic node) { |
| 1290 _replaceExpressions(node.arguments); | 1031 _replaceExpressions(node.arguments); |
| 1291 return node; | 1032 return node; |
| 1292 } | 1033 } |
| 1293 | 1034 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1310 | 1051 |
| 1311 visitConcatenateStrings(ConcatenateStrings node) { | 1052 visitConcatenateStrings(ConcatenateStrings node) { |
| 1312 _replaceExpressions(node.arguments); | 1053 _replaceExpressions(node.arguments); |
| 1313 return node; | 1054 return node; |
| 1314 } | 1055 } |
| 1315 | 1056 |
| 1316 visitConstant(Constant node) => node; | 1057 visitConstant(Constant node) => node; |
| 1317 | 1058 |
| 1318 visitThis(This node) => node; | 1059 visitThis(This node) => node; |
| 1319 | 1060 |
| 1320 visitReifyTypeVar(ReifyTypeVar node) => node; | |
| 1321 | |
| 1322 visitConditional(Conditional node) { | 1061 visitConditional(Conditional node) { |
| 1323 node.condition = visitExpression(node.condition); | 1062 node.condition = visitExpression(node.condition); |
| 1324 node.thenExpression = visitExpression(node.thenExpression); | 1063 node.thenExpression = visitExpression(node.thenExpression); |
| 1325 node.elseExpression = visitExpression(node.elseExpression); | 1064 node.elseExpression = visitExpression(node.elseExpression); |
| 1326 return node; | 1065 return node; |
| 1327 } | 1066 } |
| 1328 | 1067 |
| 1329 visitLogicalOperator(LogicalOperator node) { | 1068 visitLogicalOperator(LogicalOperator node) { |
| 1330 node.left = visitExpression(node.left); | 1069 node.left = visitExpression(node.left); |
| 1331 node.right = visitExpression(node.right); | 1070 node.right = visitExpression(node.right); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 return node; | 1134 return node; |
| 1396 } | 1135 } |
| 1397 | 1136 |
| 1398 visitWhileCondition(WhileCondition node) { | 1137 visitWhileCondition(WhileCondition node) { |
| 1399 node.condition = visitExpression(node.condition); | 1138 node.condition = visitExpression(node.condition); |
| 1400 node.body = visitStatement(node.body); | 1139 node.body = visitStatement(node.body); |
| 1401 node.next = visitStatement(node.next); | 1140 node.next = visitStatement(node.next); |
| 1402 return node; | 1141 return node; |
| 1403 } | 1142 } |
| 1404 | 1143 |
| 1405 visitFunctionDeclaration(FunctionDeclaration node) { | |
| 1406 visitInnerFunction(node.definition); | |
| 1407 node.next = visitStatement(node.next); | |
| 1408 return node; | |
| 1409 } | |
| 1410 | |
| 1411 visitExpressionStatement(ExpressionStatement node) { | 1144 visitExpressionStatement(ExpressionStatement node) { |
| 1412 node.expression = visitExpression(node.expression); | 1145 node.expression = visitExpression(node.expression); |
| 1413 node.next = visitStatement(node.next); | 1146 node.next = visitStatement(node.next); |
| 1414 return node; | 1147 return node; |
| 1415 } | 1148 } |
| 1416 | 1149 |
| 1417 visitTry(Try node) { | 1150 visitTry(Try node) { |
| 1418 node.tryBody = visitStatement(node.tryBody); | 1151 node.tryBody = visitStatement(node.tryBody); |
| 1419 node.catchBody = visitStatement(node.catchBody); | 1152 node.catchBody = visitStatement(node.catchBody); |
| 1420 return node; | 1153 return node; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1458 visitTypeExpression(TypeExpression node) { | 1191 visitTypeExpression(TypeExpression node) { |
| 1459 _replaceExpressions(node.arguments); | 1192 _replaceExpressions(node.arguments); |
| 1460 return node; | 1193 return node; |
| 1461 } | 1194 } |
| 1462 | 1195 |
| 1463 visitCreateInvocationMirror(CreateInvocationMirror node) { | 1196 visitCreateInvocationMirror(CreateInvocationMirror node) { |
| 1464 _replaceExpressions(node.arguments); | 1197 _replaceExpressions(node.arguments); |
| 1465 return node; | 1198 return node; |
| 1466 } | 1199 } |
| 1467 } | 1200 } |
| OLD | NEW |