Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: lib/src/js/nodes.dart

Issue 1029583011: [js_ast] adds Identifier that merges VariableDeclaration/Use and Parameter (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of js_ast; 5 part of js_ast;
6 6
7 abstract class NodeVisitor<T> { 7 abstract class NodeVisitor<T> {
8 T visitProgram(Program node); 8 T visitProgram(Program node);
9 9
10 T visitBlock(Block node); 10 T visitBlock(Block node);
(...skipping 23 matching lines...) Expand all
34 T visitVariableDeclarationList(VariableDeclarationList node); 34 T visitVariableDeclarationList(VariableDeclarationList node);
35 T visitAssignment(Assignment node); 35 T visitAssignment(Assignment node);
36 T visitVariableInitialization(VariableInitialization node); 36 T visitVariableInitialization(VariableInitialization node);
37 T visitConditional(Conditional cond); 37 T visitConditional(Conditional cond);
38 T visitNew(New node); 38 T visitNew(New node);
39 T visitCall(Call node); 39 T visitCall(Call node);
40 T visitBinary(Binary node); 40 T visitBinary(Binary node);
41 T visitPrefix(Prefix node); 41 T visitPrefix(Prefix node);
42 T visitPostfix(Postfix node); 42 T visitPostfix(Postfix node);
43 43
44 T visitVariableUse(VariableUse node); 44 T visitIdentifier(Identifier node);
45 T visitThis(This node); 45 T visitThis(This node);
46 T visitSuper(Super node); 46 T visitSuper(Super node);
47 T visitVariableDeclaration(VariableDeclaration node);
48 T visitParameter(Parameter node);
49 T visitAccess(PropertyAccess node); 47 T visitAccess(PropertyAccess node);
50 48
51 T visitNamedFunction(NamedFunction node); 49 T visitNamedFunction(NamedFunction node);
52 T visitFun(Fun node); 50 T visitFun(Fun node);
53 T visitArrowFun(ArrowFun node); 51 T visitArrowFun(ArrowFun node);
54 52
55 T visitLiteralBool(LiteralBool node); 53 T visitLiteralBool(LiteralBool node);
56 T visitLiteralString(LiteralString node); 54 T visitLiteralString(LiteralString node);
57 T visitLiteralNumber(LiteralNumber node); 55 T visitLiteralNumber(LiteralNumber node);
58 T visitLiteralNull(LiteralNull node); 56 T visitLiteralNull(LiteralNull node);
(...skipping 14 matching lines...) Expand all
73 71
74 T visitComment(Comment node); 72 T visitComment(Comment node);
75 T visitCommentExpression(CommentExpression node); 73 T visitCommentExpression(CommentExpression node);
76 74
77 T visitInterpolatedExpression(InterpolatedExpression node); 75 T visitInterpolatedExpression(InterpolatedExpression node);
78 T visitInterpolatedLiteral(InterpolatedLiteral node); 76 T visitInterpolatedLiteral(InterpolatedLiteral node);
79 T visitInterpolatedParameter(InterpolatedParameter node); 77 T visitInterpolatedParameter(InterpolatedParameter node);
80 T visitInterpolatedSelector(InterpolatedSelector node); 78 T visitInterpolatedSelector(InterpolatedSelector node);
81 T visitInterpolatedStatement(InterpolatedStatement node); 79 T visitInterpolatedStatement(InterpolatedStatement node);
82 T visitInterpolatedMethod(InterpolatedMethod node); 80 T visitInterpolatedMethod(InterpolatedMethod node);
83 T visitInterpolatedVariableDeclaration(InterpolatedVariableDeclaration node); 81 T visitInterpolatedIdentifier(InterpolatedIdentifier node);
84 } 82 }
85 83
86 class BaseVisitor<T> implements NodeVisitor<T> { 84 class BaseVisitor<T> implements NodeVisitor<T> {
87 T visitNode(Node node) { 85 T visitNode(Node node) {
88 node.visitChildren(this); 86 node.visitChildren(this);
89 return null; 87 return null;
90 } 88 }
91 89
92 T visitProgram(Program node) => visitNode(node); 90 T visitProgram(Program node) => visitNode(node);
93 91
(...skipping 20 matching lines...) Expand all
114 T visitFunctionDeclaration(FunctionDeclaration node) 112 T visitFunctionDeclaration(FunctionDeclaration node)
115 => visitStatement(node); 113 => visitStatement(node);
116 T visitLabeledStatement(LabeledStatement node) => visitStatement(node); 114 T visitLabeledStatement(LabeledStatement node) => visitStatement(node);
117 T visitLiteralStatement(LiteralStatement node) => visitStatement(node); 115 T visitLiteralStatement(LiteralStatement node) => visitStatement(node);
118 116
119 T visitCatch(Catch node) => visitNode(node); 117 T visitCatch(Catch node) => visitNode(node);
120 T visitCase(Case node) => visitNode(node); 118 T visitCase(Case node) => visitNode(node);
121 T visitDefault(Default node) => visitNode(node); 119 T visitDefault(Default node) => visitNode(node);
122 120
123 T visitExpression(Expression node) => visitNode(node); 121 T visitExpression(Expression node) => visitNode(node);
124 T visitVariableReference(VariableReference node) => visitExpression(node);
125 122
126 T visitLiteralExpression(LiteralExpression node) => visitExpression(node); 123 T visitLiteralExpression(LiteralExpression node) => visitExpression(node);
127 T visitVariableDeclarationList(VariableDeclarationList node) 124 T visitVariableDeclarationList(VariableDeclarationList node)
128 => visitExpression(node); 125 => visitExpression(node);
129 T visitAssignment(Assignment node) => visitExpression(node); 126 T visitAssignment(Assignment node) => visitExpression(node);
130 T visitVariableInitialization(VariableInitialization node) { 127 T visitVariableInitialization(VariableInitialization node) {
131 if (node.value != null) { 128 if (node.value != null) {
132 return visitAssignment(node); 129 return visitAssignment(node);
133 } else { 130 } else {
134 return visitExpression(node); 131 return visitExpression(node);
135 } 132 }
136 } 133 }
137 T visitConditional(Conditional node) => visitExpression(node); 134 T visitConditional(Conditional node) => visitExpression(node);
138 T visitNew(New node) => visitExpression(node); 135 T visitNew(New node) => visitExpression(node);
139 T visitCall(Call node) => visitExpression(node); 136 T visitCall(Call node) => visitExpression(node);
140 T visitBinary(Binary node) => visitExpression(node); 137 T visitBinary(Binary node) => visitExpression(node);
141 T visitPrefix(Prefix node) => visitExpression(node); 138 T visitPrefix(Prefix node) => visitExpression(node);
142 T visitPostfix(Postfix node) => visitExpression(node); 139 T visitPostfix(Postfix node) => visitExpression(node);
143 T visitAccess(PropertyAccess node) => visitExpression(node); 140 T visitAccess(PropertyAccess node) => visitExpression(node);
144 141
145 T visitVariableUse(VariableUse node) => visitVariableReference(node); 142 T visitIdentifier(Identifier node) => visitExpression(node);
146 T visitVariableDeclaration(VariableDeclaration node) 143 T visitThis(This node) => visitExpression(node);
147 => visitVariableReference(node); 144 T visitSuper(Super node) => visitExpression(node);
148 T visitParameter(Parameter node) => visitVariableDeclaration(node);
149 T visitThis(This node) => visitParameter(node);
150 T visitSuper(Super node) => visitParameter(node);
151 145
152 T visitNamedFunction(NamedFunction node) => visitExpression(node); 146 T visitNamedFunction(NamedFunction node) => visitExpression(node);
153 T visitFunctionExpression(FunctionExpression node) => visitExpression(node); 147 T visitFunctionExpression(FunctionExpression node) => visitExpression(node);
154 T visitFun(Fun node) => visitFunctionExpression(node); 148 T visitFun(Fun node) => visitFunctionExpression(node);
155 T visitArrowFun(ArrowFun node) => visitFunctionExpression(node); 149 T visitArrowFun(ArrowFun node) => visitFunctionExpression(node);
156 150
157 T visitLiteral(Literal node) => visitExpression(node); 151 T visitLiteral(Literal node) => visitExpression(node);
158 152
159 T visitLiteralBool(LiteralBool node) => visitLiteral(node); 153 T visitLiteralBool(LiteralBool node) => visitLiteral(node);
160 T visitLiteralString(LiteralString node) => visitLiteral(node); 154 T visitLiteralString(LiteralString node) => visitLiteral(node);
(...skipping 19 matching lines...) Expand all
180 T visitInterpolatedLiteral(InterpolatedLiteral node) 174 T visitInterpolatedLiteral(InterpolatedLiteral node)
181 => visitInterpolatedNode(node); 175 => visitInterpolatedNode(node);
182 T visitInterpolatedParameter(InterpolatedParameter node) 176 T visitInterpolatedParameter(InterpolatedParameter node)
183 => visitInterpolatedNode(node); 177 => visitInterpolatedNode(node);
184 T visitInterpolatedSelector(InterpolatedSelector node) 178 T visitInterpolatedSelector(InterpolatedSelector node)
185 => visitInterpolatedNode(node); 179 => visitInterpolatedNode(node);
186 T visitInterpolatedStatement(InterpolatedStatement node) 180 T visitInterpolatedStatement(InterpolatedStatement node)
187 => visitInterpolatedNode(node); 181 => visitInterpolatedNode(node);
188 T visitInterpolatedMethod(InterpolatedMethod node) 182 T visitInterpolatedMethod(InterpolatedMethod node)
189 => visitInterpolatedNode(node); 183 => visitInterpolatedNode(node);
190 T visitInterpolatedVariableDeclaration(InterpolatedVariableDeclaration node) 184 T visitInterpolatedIdentifier(InterpolatedIdentifier node)
191 => visitInterpolatedNode(node); 185 => visitInterpolatedNode(node);
192 186
193 // Ignore comments by default. 187 // Ignore comments by default.
194 T visitComment(Comment node) => null; 188 T visitComment(Comment node) => null;
195 T visitCommentExpression(CommentExpression node) => null; 189 T visitCommentExpression(CommentExpression node) => null;
196 190
197 T visitAwait(Await node) => visitExpression(node); 191 T visitAwait(Await node) => visitExpression(node);
198 T visitDartYield(DartYield node) => visitStatement(node); 192 T visitDartYield(DartYield node) => visitStatement(node);
199 } 193 }
200 194
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 void visitChildren(NodeVisitor visitor) { 449 void visitChildren(NodeVisitor visitor) {
456 body.accept(visitor); 450 body.accept(visitor);
457 if (catchPart != null) catchPart.accept(visitor); 451 if (catchPart != null) catchPart.accept(visitor);
458 if (finallyPart != null) finallyPart.accept(visitor); 452 if (finallyPart != null) finallyPart.accept(visitor);
459 } 453 }
460 454
461 Try _clone() => new Try(body, catchPart, finallyPart); 455 Try _clone() => new Try(body, catchPart, finallyPart);
462 } 456 }
463 457
464 class Catch extends Node { 458 class Catch extends Node {
465 final VariableDeclaration declaration; 459 final Identifier declaration;
466 final Block body; 460 final Block body;
467 461
468 Catch(this.declaration, this.body); 462 Catch(this.declaration, this.body);
469 463
470 accept(NodeVisitor visitor) => visitor.visitCatch(this); 464 accept(NodeVisitor visitor) => visitor.visitCatch(this);
471 465
472 void visitChildren(NodeVisitor visitor) { 466 void visitChildren(NodeVisitor visitor) {
473 declaration.accept(visitor); 467 declaration.accept(visitor);
474 body.accept(visitor); 468 body.accept(visitor);
475 } 469 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 accept(NodeVisitor visitor) => visitor.visitDefault(this); 514 accept(NodeVisitor visitor) => visitor.visitDefault(this);
521 515
522 void visitChildren(NodeVisitor visitor) { 516 void visitChildren(NodeVisitor visitor) {
523 body.accept(visitor); 517 body.accept(visitor);
524 } 518 }
525 519
526 Default _clone() => new Default(body); 520 Default _clone() => new Default(body);
527 } 521 }
528 522
529 class FunctionDeclaration extends Statement { 523 class FunctionDeclaration extends Statement {
530 final VariableDeclaration name; 524 final Identifier name;
531 final Fun function; 525 final Fun function;
532 526
533 FunctionDeclaration(this.name, this.function); 527 FunctionDeclaration(this.name, this.function);
534 528
535 accept(NodeVisitor visitor) => visitor.visitFunctionDeclaration(this); 529 accept(NodeVisitor visitor) => visitor.visitFunctionDeclaration(this);
536 530
537 void visitChildren(NodeVisitor visitor) { 531 void visitChildren(NodeVisitor visitor) {
538 name.accept(visitor); 532 name.accept(visitor);
539 function.accept(visitor); 533 function.accept(visitor);
540 } 534 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 leftHandSide.accept(visitor); 653 leftHandSide.accept(visitor);
660 if (value != null) value.accept(visitor); 654 if (value != null) value.accept(visitor);
661 } 655 }
662 656
663 Assignment _clone() => 657 Assignment _clone() =>
664 new Assignment.compound(leftHandSide, op, value); 658 new Assignment.compound(leftHandSide, op, value);
665 } 659 }
666 660
667 class VariableInitialization extends Assignment { 661 class VariableInitialization extends Assignment {
668 /** [value] may be null. */ 662 /** [value] may be null. */
669 VariableInitialization(VariableDeclaration declaration, Expression value) 663 VariableInitialization(Identifier declaration, Expression value)
670 : super(declaration, value); 664 : super(declaration, value);
671 665
672 VariableDeclaration get declaration => leftHandSide; 666 Identifier get declaration => leftHandSide;
673 667
674 accept(NodeVisitor visitor) => visitor.visitVariableInitialization(this); 668 accept(NodeVisitor visitor) => visitor.visitVariableInitialization(this);
675 669
676 VariableInitialization _clone() => 670 VariableInitialization _clone() =>
677 new VariableInitialization(declaration, value); 671 new VariableInitialization(declaration, value);
678 } 672 }
679 673
680 class Conditional extends Expression { 674 class Conditional extends Expression {
681 final Expression condition; 675 final Expression condition;
682 final Expression then; 676 final Expression then;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 Postfix(this.op, this.argument); 803 Postfix(this.op, this.argument);
810 804
811 accept(NodeVisitor visitor) => visitor.visitPostfix(this); 805 accept(NodeVisitor visitor) => visitor.visitPostfix(this);
812 806
813 Postfix _clone() => new Postfix(op, argument); 807 Postfix _clone() => new Postfix(op, argument);
814 808
815 void visitChildren(NodeVisitor visitor) { 809 void visitChildren(NodeVisitor visitor) {
816 argument.accept(visitor); 810 argument.accept(visitor);
817 } 811 }
818 812
819
820 int get precedenceLevel => UNARY; 813 int get precedenceLevel => UNARY;
821 } 814 }
822 815
823 abstract class VariableReference extends Expression { 816 class Identifier extends Expression {
824 final String name; 817 final String name;
818 final bool allowRename;
825 819
826 VariableReference(this.name) { 820 Identifier(this.name, {this.allowRename: true}) {
827 assert(_identifierRE.hasMatch(name)); 821 assert(_identifierRE.hasMatch(name));
828 } 822 }
829 static RegExp _identifierRE = new RegExp(r'^[A-Za-z_$][A-Za-z_$0-9]*$'); 823 static RegExp _identifierRE = new RegExp(r'^[A-Za-z_$][A-Za-z_$0-9]*$');
830 824
831 accept(NodeVisitor visitor); 825 Identifier _clone() =>
826 new Identifier(name, allowRename: allowRename);
827 accept(NodeVisitor visitor) => visitor.visitIdentifier(this);
832 int get precedenceLevel => PRIMARY; 828 int get precedenceLevel => PRIMARY;
833 void visitChildren(NodeVisitor visitor) {} 829 void visitChildren(NodeVisitor visitor) {}
834 } 830 }
835 831
836 class VariableUse extends VariableReference { 832 class This extends Expression {
837 VariableUse(String name) : super(name);
838
839 accept(NodeVisitor visitor) => visitor.visitVariableUse(this);
840 VariableUse _clone() => new VariableUse(name);
841
842 VariableUse asVariableUse() => this;
843
844 toString() => 'VariableUse($name)';
845 }
846
847 class VariableDeclaration extends VariableReference {
848 final bool allowRename;
849 VariableDeclaration(String name, {this.allowRename: true}) : super(name);
850
851 accept(NodeVisitor visitor) => visitor.visitVariableDeclaration(this);
852 VariableDeclaration _clone() => new VariableDeclaration(name);
853 }
854
855 class Parameter extends VariableDeclaration {
856 Parameter(String name) : super(name);
857
858 accept(NodeVisitor visitor) => visitor.visitParameter(this);
859 Parameter _clone() => new Parameter(name);
860 }
861
862 class This extends Parameter {
863 This() : super("this");
864
865 accept(NodeVisitor visitor) => visitor.visitThis(this); 833 accept(NodeVisitor visitor) => visitor.visitThis(this);
866 This _clone() => new This(); 834 This _clone() => new This();
835 int get precedenceLevel => PRIMARY;
836 void visitChildren(NodeVisitor visitor) {}
867 } 837 }
868 838
869 // `super` is more restricted in the ES6 spec, but for simplicity we accept 839 // `super` is more restricted in the ES6 spec, but for simplicity we accept
870 // it anywhere that `this` is accepted. 840 // it anywhere that `this` is accepted.
871 class Super extends Parameter { 841 class Super extends Expression {
872 Super() : super("super");
873
874 accept(NodeVisitor visitor) => visitor.visitSuper(this); 842 accept(NodeVisitor visitor) => visitor.visitSuper(this);
875 Super _clone() => new Super(); 843 Super _clone() => new Super();
844 int get precedenceLevel => PRIMARY;
845 void visitChildren(NodeVisitor visitor) {}
876 } 846 }
877 847
878 class NamedFunction extends Expression { 848 class NamedFunction extends Expression {
879 final VariableDeclaration name; 849 final Identifier name;
880 final Fun function; 850 final Fun function;
881 851
882 NamedFunction(this.name, this.function); 852 NamedFunction(this.name, this.function);
883 853
884 accept(NodeVisitor visitor) => visitor.visitNamedFunction(this); 854 accept(NodeVisitor visitor) => visitor.visitNamedFunction(this);
885 855
886 void visitChildren(NodeVisitor visitor) { 856 void visitChildren(NodeVisitor visitor) {
887 name.accept(visitor); 857 name.accept(visitor);
888 function.accept(visitor); 858 function.accept(visitor);
889 } 859 }
890 NamedFunction _clone() => new NamedFunction(name, function); 860 NamedFunction _clone() => new NamedFunction(name, function);
891 861
892 int get precedenceLevel => CALL; 862 int get precedenceLevel => CALL;
893 } 863 }
894 864
895 abstract class FunctionExpression extends Expression { 865 abstract class FunctionExpression extends Expression {
896 List<Parameter> get params; 866 List<Identifier> get params;
897 get body; // Expression or block 867 get body; // Expression or block
898 } 868 }
899 869
900 class Fun extends FunctionExpression { 870 class Fun extends FunctionExpression {
901 final List<Parameter> params; 871 final List<Identifier> params;
902 final Block body; 872 final Block body;
903 final AsyncModifier asyncModifier; 873 final AsyncModifier asyncModifier;
904 874
905 Fun(this.params, this.body, {this.asyncModifier: const AsyncModifier.sync()}); 875 Fun(this.params, this.body, {this.asyncModifier: const AsyncModifier.sync()});
906 876
907 accept(NodeVisitor visitor) => visitor.visitFun(this); 877 accept(NodeVisitor visitor) => visitor.visitFun(this);
908 878
909 void visitChildren(NodeVisitor visitor) { 879 void visitChildren(NodeVisitor visitor) {
910 for (Parameter param in params) param.accept(visitor); 880 for (Identifier param in params) param.accept(visitor);
911 body.accept(visitor); 881 body.accept(visitor);
912 } 882 }
913 883
914 Fun _clone() => new Fun(params, body, asyncModifier: asyncModifier); 884 Fun _clone() => new Fun(params, body, asyncModifier: asyncModifier);
915 885
916 int get precedenceLevel => CALL; 886 int get precedenceLevel => CALL;
917 } 887 }
918 888
919 class ArrowFun extends FunctionExpression { 889 class ArrowFun extends FunctionExpression {
920 final List<Parameter> params; 890 final List<Identifier> params;
921 final body; // Expression or Block 891 final body; // Expression or Block
922 892
923 ArrowFun(this.params, this.body); 893 ArrowFun(this.params, this.body);
924 894
925 accept(NodeVisitor visitor) => visitor.visitArrowFun(this); 895 accept(NodeVisitor visitor) => visitor.visitArrowFun(this);
926 896
927 void visitChildren(NodeVisitor visitor) { 897 void visitChildren(NodeVisitor visitor) {
928 for (Parameter param in params) param.accept(visitor); 898 for (Identifier param in params) param.accept(visitor);
929 body.accept(visitor); 899 body.accept(visitor);
930 } 900 }
931 901
932 ArrowFun _clone() => new ArrowFun(params, body); 902 ArrowFun _clone() => new ArrowFun(params, body);
933 903
934 /// Ensure parens always get generated if necessary. 904 /// Ensure parens always get generated if necessary.
935 // TODO(jmesserly): I'm not sure the printer is handling this correctly for 905 // TODO(jmesserly): I'm not sure the printer is handling this correctly for
936 // function() { ... } either. 906 // function() { ... } either.
937 int get precedenceLevel => ASSIGNMENT; 907 int get precedenceLevel => ASSIGNMENT;
938 } 908 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 1050
1081 ObjectInitializer _clone() => new ObjectInitializer(properties); 1051 ObjectInitializer _clone() => new ObjectInitializer(properties);
1082 1052
1083 int get precedenceLevel => PRIMARY; 1053 int get precedenceLevel => PRIMARY;
1084 } 1054 }
1085 1055
1086 class Property extends Node { 1056 class Property extends Node {
1087 final Expression name; 1057 final Expression name;
1088 final Expression value; 1058 final Expression value;
1089 1059
1090 Property(this.name, this.value) { 1060 Property(this.name, this.value);
1091 assert(name is! VariableDeclaration);
1092 }
1093 1061
1094 accept(NodeVisitor visitor) => visitor.visitProperty(this); 1062 accept(NodeVisitor visitor) => visitor.visitProperty(this);
1095 1063
1096 void visitChildren(NodeVisitor visitor) { 1064 void visitChildren(NodeVisitor visitor) {
1097 name.accept(visitor); 1065 name.accept(visitor);
1098 value.accept(visitor); 1066 value.accept(visitor);
1099 } 1067 }
1100 1068
1101 Property _clone() => new Property(name, value); 1069 Property _clone() => new Property(name, value);
1102 } 1070 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 final ClassExpression classExpr; 1121 final ClassExpression classExpr;
1154 1122
1155 ClassDeclaration(this.classExpr); 1123 ClassDeclaration(this.classExpr);
1156 1124
1157 accept(NodeVisitor visitor) => visitor.visitClassDeclaration(this); 1125 accept(NodeVisitor visitor) => visitor.visitClassDeclaration(this);
1158 visitChildren(NodeVisitor visitor) => classExpr.accept(visitor); 1126 visitChildren(NodeVisitor visitor) => classExpr.accept(visitor);
1159 ClassDeclaration _clone() => new ClassDeclaration(classExpr); 1127 ClassDeclaration _clone() => new ClassDeclaration(classExpr);
1160 } 1128 }
1161 1129
1162 class ClassExpression extends Expression { 1130 class ClassExpression extends Expression {
1163 final VariableDeclaration name; 1131 final Identifier name;
1164 final Expression heritage; // Can be null. 1132 final Expression heritage; // Can be null.
1165 final List<Method> methods; 1133 final List<Method> methods;
1166 1134
1167 ClassExpression(this.name, this.heritage, this.methods); 1135 ClassExpression(this.name, this.heritage, this.methods);
1168 1136
1169 accept(NodeVisitor visitor) => visitor.visitClassExpression(this); 1137 accept(NodeVisitor visitor) => visitor.visitClassExpression(this);
1170 1138
1171 void visitChildren(NodeVisitor visitor) { 1139 void visitChildren(NodeVisitor visitor) {
1172 name.accept(visitor); 1140 name.accept(visitor);
1173 if (heritage != null) heritage.accept(visitor); 1141 if (heritage != null) heritage.accept(visitor);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 final nameOrPosition; 1197 final nameOrPosition;
1230 1198
1231 InterpolatedLiteral(this.nameOrPosition); 1199 InterpolatedLiteral(this.nameOrPosition);
1232 1200
1233 accept(NodeVisitor visitor) => visitor.visitInterpolatedLiteral(this); 1201 accept(NodeVisitor visitor) => visitor.visitInterpolatedLiteral(this);
1234 void visitChildren(NodeVisitor visitor) {} 1202 void visitChildren(NodeVisitor visitor) {}
1235 InterpolatedLiteral _clone() => new InterpolatedLiteral(nameOrPosition); 1203 InterpolatedLiteral _clone() => new InterpolatedLiteral(nameOrPosition);
1236 } 1204 }
1237 1205
1238 class InterpolatedParameter extends Expression with InterpolatedNode 1206 class InterpolatedParameter extends Expression with InterpolatedNode
1239 implements Parameter { 1207 implements Identifier {
1240 final nameOrPosition; 1208 final nameOrPosition;
1241 1209
1242 String get name { throw "InterpolatedParameter.name must not be invoked"; } 1210 String get name { throw "InterpolatedParameter.name must not be invoked"; }
1243 bool get allowRename => false; 1211 bool get allowRename => false;
1244 1212
1245 InterpolatedParameter(this.nameOrPosition); 1213 InterpolatedParameter(this.nameOrPosition);
1246 1214
1247 accept(NodeVisitor visitor) => visitor.visitInterpolatedParameter(this); 1215 accept(NodeVisitor visitor) => visitor.visitInterpolatedParameter(this);
1248 void visitChildren(NodeVisitor visitor) {} 1216 void visitChildren(NodeVisitor visitor) {}
1249 InterpolatedParameter _clone() => new InterpolatedParameter(nameOrPosition); 1217 InterpolatedParameter _clone() => new InterpolatedParameter(nameOrPosition);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 int get precedenceLevel => PRIMARY; 1255 int get precedenceLevel => PRIMARY;
1288 Expression get name => _unsupported; 1256 Expression get name => _unsupported;
1289 Expression get value => _unsupported; 1257 Expression get value => _unsupported;
1290 bool get isGetter => _unsupported; 1258 bool get isGetter => _unsupported;
1291 bool get isSetter => _unsupported; 1259 bool get isSetter => _unsupported;
1292 bool get isStatic => _unsupported; 1260 bool get isStatic => _unsupported;
1293 Fun get function => _unsupported; 1261 Fun get function => _unsupported;
1294 get _unsupported => throw '$runtimeType does not support this member.'; 1262 get _unsupported => throw '$runtimeType does not support this member.';
1295 } 1263 }
1296 1264
1297 class InterpolatedVariableDeclaration extends Expression with InterpolatedNode 1265 class InterpolatedIdentifier extends Expression with InterpolatedNode
1298 implements VariableDeclaration { 1266 implements Identifier {
1299 final nameOrPosition; 1267 final nameOrPosition;
1300 1268
1301 InterpolatedVariableDeclaration(this.nameOrPosition); 1269 InterpolatedIdentifier(this.nameOrPosition);
1302 1270
1303 accept(NodeVisitor visitor) => 1271 accept(NodeVisitor visitor) =>
1304 visitor.visitInterpolatedVariableDeclaration(this); 1272 visitor.visitInterpolatedIdentifier(this);
1305 void visitChildren(NodeVisitor visitor) {} 1273 void visitChildren(NodeVisitor visitor) {}
1306 InterpolatedVariableDeclaration _clone() => 1274 InterpolatedIdentifier _clone() => new InterpolatedIdentifier(nameOrPosition);
1307 new InterpolatedVariableDeclaration(nameOrPosition);
1308 1275
1309 int get precedenceLevel => PRIMARY; 1276 int get precedenceLevel => PRIMARY;
1310 String get name => throw '$runtimeType does not support this member.'; 1277 String get name => throw '$runtimeType does not support this member.';
1311 bool get allowRename => false; 1278 bool get allowRename => false;
1312 } 1279 }
1313 1280
1314 /** 1281 /**
1315 * [RegExpLiteral]s, despite being called "Literal", do not inherit from 1282 * [RegExpLiteral]s, despite being called "Literal", do not inherit from
1316 * [Literal]. Indeed, regular expressions in JavaScript have a side-effect and 1283 * [Literal]. Indeed, regular expressions in JavaScript have a side-effect and
1317 * are thus not in the same category as numbers or strings. 1284 * are thus not in the same category as numbers or strings.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 final Expression expression; 1342 final Expression expression;
1376 1343
1377 CommentExpression(this.comment, this.expression); 1344 CommentExpression(this.comment, this.expression);
1378 1345
1379 int get precedenceLevel => PRIMARY; 1346 int get precedenceLevel => PRIMARY;
1380 accept(NodeVisitor visitor) => visitor.visitCommentExpression(this); 1347 accept(NodeVisitor visitor) => visitor.visitCommentExpression(this);
1381 CommentExpression _clone() => new CommentExpression(comment, expression); 1348 CommentExpression _clone() => new CommentExpression(comment, expression);
1382 1349
1383 void visitChildren(NodeVisitor visitor) => expression.accept(visitor); 1350 void visitChildren(NodeVisitor visitor) => expression.accept(visitor);
1384 } 1351 }
OLDNEW
« no previous file with comments | « lib/src/js/builder.dart ('k') | lib/src/js/printer.dart » ('j') | lib/src/js/printer.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698