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

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

Issue 1686953005: Split Parameter and TypeParameter out of Identifier Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « lib/src/js/builder.dart ('k') | lib/src/js/printer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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> implements TypeRefVisitor<T> { 7 abstract class NodeVisitor<T> implements TypeRefVisitor<T> {
8 T visitProgram(Program node); 8 T visitProgram(Program node);
9 9
10 T visitBlock(Block node); 10 T visitBlock(Block node);
(...skipping 29 matching lines...) Expand all
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 T visitSpread(Spread node); 43 T visitSpread(Spread node);
44 T visitYield(Yield node); 44 T visitYield(Yield node);
45 45
46 T visitIdentifier(Identifier node); 46 T visitIdentifier(Identifier node);
47 T visitThis(This node); 47 T visitThis(This node);
48 T visitSuper(Super node); 48 T visitSuper(Super node);
49 T visitAccess(PropertyAccess node); 49 T visitAccess(PropertyAccess node);
50 T visitRestParameter(RestParameter node);
51 50
52 T visitNamedFunction(NamedFunction node); 51 T visitNamedFunction(NamedFunction node);
53 T visitFun(Fun node); 52 T visitFun(Fun node);
54 T visitArrowFun(ArrowFun node); 53 T visitArrowFun(ArrowFun node);
55 54
56 T visitLiteralBool(LiteralBool node); 55 T visitLiteralBool(LiteralBool node);
57 T visitLiteralString(LiteralString node); 56 T visitLiteralString(LiteralString node);
58 T visitLiteralNumber(LiteralNumber node); 57 T visitLiteralNumber(LiteralNumber node);
59 T visitLiteralNull(LiteralNull node); 58 T visitLiteralNull(LiteralNull node);
60 59
(...skipping 21 matching lines...) Expand all
82 T visitCommentExpression(CommentExpression node); 81 T visitCommentExpression(CommentExpression node);
83 82
84 T visitInterpolatedExpression(InterpolatedExpression node); 83 T visitInterpolatedExpression(InterpolatedExpression node);
85 T visitInterpolatedLiteral(InterpolatedLiteral node); 84 T visitInterpolatedLiteral(InterpolatedLiteral node);
86 T visitInterpolatedParameter(InterpolatedParameter node); 85 T visitInterpolatedParameter(InterpolatedParameter node);
87 T visitInterpolatedSelector(InterpolatedSelector node); 86 T visitInterpolatedSelector(InterpolatedSelector node);
88 T visitInterpolatedStatement(InterpolatedStatement node); 87 T visitInterpolatedStatement(InterpolatedStatement node);
89 T visitInterpolatedMethod(InterpolatedMethod node); 88 T visitInterpolatedMethod(InterpolatedMethod node);
90 T visitInterpolatedIdentifier(InterpolatedIdentifier node); 89 T visitInterpolatedIdentifier(InterpolatedIdentifier node);
91 90
91 T visitParameter(Parameter node);
92 T visitTypeParameter(TypeParameter node);
93
92 T visitArrayBindingPattern(ArrayBindingPattern node); 94 T visitArrayBindingPattern(ArrayBindingPattern node);
93 T visitObjectBindingPattern(ObjectBindingPattern node); 95 T visitObjectBindingPattern(ObjectBindingPattern node);
94 T visitDestructuredVariable(DestructuredVariable node); 96 T visitDestructuredVariable(DestructuredVariable node);
95 T visitSimpleBindingPattern(SimpleBindingPattern node); 97 T visitSimpleBindingPattern(SimpleBindingPattern node);
96 } 98 }
97 99
98 abstract class TypeRefVisitor<T> { 100 abstract class TypeRefVisitor<T> {
99 T visitQualifiedTypeRef(QualifiedTypeRef node); 101 T visitQualifiedTypeRef(QualifiedTypeRef node);
100 T visitGenericTypeRef(GenericTypeRef node); 102 T visitGenericTypeRef(GenericTypeRef node);
101 T visitUnionTypeRef(UnionTypeRef node); 103 T visitUnionTypeRef(UnionTypeRef node);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 T visitPrefix(Prefix node) => visitExpression(node); 166 T visitPrefix(Prefix node) => visitExpression(node);
165 T visitPostfix(Postfix node) => visitExpression(node); 167 T visitPostfix(Postfix node) => visitExpression(node);
166 T visitSpread(Spread node) => visitPrefix(node); 168 T visitSpread(Spread node) => visitPrefix(node);
167 T visitYield(Yield node) => visitExpression(node); 169 T visitYield(Yield node) => visitExpression(node);
168 T visitAccess(PropertyAccess node) => visitExpression(node); 170 T visitAccess(PropertyAccess node) => visitExpression(node);
169 171
170 T visitIdentifier(Identifier node) => visitExpression(node); 172 T visitIdentifier(Identifier node) => visitExpression(node);
171 T visitThis(This node) => visitExpression(node); 173 T visitThis(This node) => visitExpression(node);
172 T visitSuper(Super node) => visitExpression(node); 174 T visitSuper(Super node) => visitExpression(node);
173 175
174 T visitRestParameter(RestParameter node) => visitNode(node);
175
176 T visitNamedFunction(NamedFunction node) => visitExpression(node); 176 T visitNamedFunction(NamedFunction node) => visitExpression(node);
177 T visitFunctionExpression(FunctionExpression node) => visitExpression(node); 177 T visitFunctionExpression(FunctionExpression node) => visitExpression(node);
178 T visitFun(Fun node) => visitFunctionExpression(node); 178 T visitFun(Fun node) => visitFunctionExpression(node);
179 T visitArrowFun(ArrowFun node) => visitFunctionExpression(node); 179 T visitArrowFun(ArrowFun node) => visitFunctionExpression(node);
180 180
181 T visitLiteral(Literal node) => visitExpression(node); 181 T visitLiteral(Literal node) => visitExpression(node);
182 182
183 T visitLiteralBool(LiteralBool node) => visitLiteral(node); 183 T visitLiteralBool(LiteralBool node) => visitLiteral(node);
184 T visitLiteralString(LiteralString node) => visitLiteral(node); 184 T visitLiteralString(LiteralString node) => visitLiteral(node);
185 T visitLiteralNumber(LiteralNumber node) => visitLiteral(node); 185 T visitLiteralNumber(LiteralNumber node) => visitLiteral(node);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 T visitInterpolatedIdentifier(InterpolatedIdentifier node) 221 T visitInterpolatedIdentifier(InterpolatedIdentifier node)
222 => visitInterpolatedNode(node); 222 => visitInterpolatedNode(node);
223 223
224 // Ignore comments by default. 224 // Ignore comments by default.
225 T visitComment(Comment node) => null; 225 T visitComment(Comment node) => null;
226 T visitCommentExpression(CommentExpression node) => null; 226 T visitCommentExpression(CommentExpression node) => null;
227 227
228 T visitAwait(Await node) => visitExpression(node); 228 T visitAwait(Await node) => visitExpression(node);
229 T visitDartYield(DartYield node) => visitStatement(node); 229 T visitDartYield(DartYield node) => visitStatement(node);
230 230
231 T visitParameter(Parameter node) => visitNode(node);
232 T visitTypeParameter(TypeParameter node) => visitNode(node);
233
231 T visitBindingPattern(BindingPattern node) => visitNode(node); 234 T visitBindingPattern(BindingPattern node) => visitNode(node);
232 T visitArrayBindingPattern(ArrayBindingPattern node) 235 T visitArrayBindingPattern(ArrayBindingPattern node)
233 => visitBindingPattern(node); 236 => visitBindingPattern(node);
234 T visitObjectBindingPattern(ObjectBindingPattern node) 237 T visitObjectBindingPattern(ObjectBindingPattern node)
235 => visitBindingPattern(node); 238 => visitBindingPattern(node);
236 T visitDestructuredVariable(DestructuredVariable node) => visitNode(node); 239 T visitDestructuredVariable(DestructuredVariable node) => visitNode(node);
237 T visitSimpleBindingPattern(SimpleBindingPattern node) => visitNode(node); 240 T visitSimpleBindingPattern(SimpleBindingPattern node) => visitNode(node);
238 241
239 T visitTypeRef(TypeRef node) => visitNode(node); 242 T visitTypeRef(TypeRef node) => visitNode(node);
240 T visitQualifiedTypeRef(QualifiedTypeRef node) => visitTypeRef(node); 243 T visitQualifiedTypeRef(QualifiedTypeRef node) => visitTypeRef(node);
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 684
682 accept(NodeVisitor visitor) => visitor.visitDartYield(this); 685 accept(NodeVisitor visitor) => visitor.visitDartYield(this);
683 686
684 void visitChildren(NodeVisitor visitor) { 687 void visitChildren(NodeVisitor visitor) {
685 expression.accept(visitor); 688 expression.accept(visitor);
686 } 689 }
687 690
688 DartYield _clone() => new DartYield(expression, hasStar); 691 DartYield _clone() => new DartYield(expression, hasStar);
689 } 692 }
690 693
691 abstract class Expression extends Node { 694 abstract class Expression extends Node implements LValue {
692 Expression(); 695 Expression();
693 696
694 factory Expression.binary(List<Expression> exprs, String op) { 697 factory Expression.binary(List<Expression> exprs, String op) {
695 Expression comma = null; 698 Expression comma = null;
696 for (var node in exprs) { 699 for (var node in exprs) {
697 comma = (comma == null) ? node : new Binary(op, comma, node); 700 comma = (comma == null) ? node : new Binary(op, comma, node);
698 } 701 }
699 return comma; 702 return comma;
700 } 703 }
701 704
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 declaration.accept(visitor); 757 declaration.accept(visitor);
755 } 758 }
756 } 759 }
757 760
758 VariableDeclarationList _clone() => 761 VariableDeclarationList _clone() =>
759 new VariableDeclarationList(keyword, declarations); 762 new VariableDeclarationList(keyword, declarations);
760 763
761 int get precedenceLevel => EXPRESSION; 764 int get precedenceLevel => EXPRESSION;
762 } 765 }
763 766
767 abstract class LValue implements Node {}
768
764 class Assignment extends Expression { 769 class Assignment extends Expression {
765 final Expression leftHandSide; 770 final LValue leftHandSide;
766 final String op; // Null, if the assignment is not compound. 771 final String op; // Null, if the assignment is not compound.
767 final Expression value; // May be null, for [VariableInitialization]s. 772 final Expression value; // May be null, for [VariableInitialization]s.
768 773
769 Assignment(leftHandSide, value) 774 Assignment(leftHandSide, value)
770 : this.compound(leftHandSide, null, value); 775 : this.compound(leftHandSide, null, value);
771 Assignment.compound(this.leftHandSide, this.op, this.value); 776 Assignment.compound(this.leftHandSide, this.op, this.value);
772 777
773 int get precedenceLevel => ASSIGNMENT; 778 int get precedenceLevel => ASSIGNMENT;
774 779
775 bool get isCompound => op != null; 780 bool get isCompound => op != null;
776 781
777 accept(NodeVisitor visitor) => visitor.visitAssignment(this); 782 accept(NodeVisitor visitor) => visitor.visitAssignment(this);
778 783
779 void visitChildren(NodeVisitor visitor) { 784 void visitChildren(NodeVisitor visitor) {
780 leftHandSide.accept(visitor); 785 leftHandSide.accept(visitor);
781 if (value != null) value.accept(visitor); 786 if (value != null) value.accept(visitor);
782 } 787 }
783 788
784 Assignment _clone() => 789 Assignment _clone() =>
785 new Assignment.compound(leftHandSide, op, value); 790 new Assignment.compound(leftHandSide, op, value);
786 } 791 }
787 792
788 class VariableInitialization extends Assignment { 793 class VariableInitialization extends Assignment {
794 final TypeRef type;
789 /** [value] may be null. */ 795 /** [value] may be null. */
790 VariableInitialization(VariableBinding declaration, Expression value) 796 VariableInitialization(VariableBinding declaration, Expression value, {this.ty pe})
791 : super(declaration, value); 797 : super(declaration, value);
792 798
793 VariableBinding get declaration => leftHandSide; 799 VariableBinding get declaration => leftHandSide;
794 800
795 accept(NodeVisitor visitor) => visitor.visitVariableInitialization(this); 801 accept(NodeVisitor visitor) => visitor.visitVariableInitialization(this);
796 802
797 VariableInitialization _clone() => 803 VariableInitialization _clone() =>
798 new VariableInitialization(declaration, value); 804 new VariableInitialization(declaration, value);
799 } 805 }
800 806
801 abstract class VariableBinding extends Expression { 807 abstract class VariableBinding implements LValue {}
802 }
803 808
804 class DestructuredVariable extends Expression implements Parameter { 809 class DestructuredVariable extends Node implements VariableBinding {
805 /// [LiteralString] or [Identifier]. 810 /// [LiteralString] or [Identifier].
806 final Expression name; 811 final Expression name;
807 final BindingPattern structure; 812 final BindingPattern structure;
808 final Expression defaultValue; 813 final Expression defaultValue;
809 final TypeRef type; 814 final TypeRef type;
810 DestructuredVariable({this.name, this.structure, this.defaultValue, this.type} ) { 815 DestructuredVariable({this.name, this.structure, this.type, this.defaultValue} ) {
811 assert(name != null || structure != null); 816 assert(name != null || structure != null);
812 } 817 }
813 818
814 accept(NodeVisitor visitor) => visitor.visitDestructuredVariable(this); 819 accept(NodeVisitor visitor) => visitor.visitDestructuredVariable(this);
815 void visitChildren(NodeVisitor visitor) { 820 void visitChildren(NodeVisitor visitor) {
816 name?.accept(visitor); 821 name?.accept(visitor);
817 structure?.accept(visitor); 822 structure?.accept(visitor);
823 type?.accept(visitor);
818 defaultValue?.accept(visitor); 824 defaultValue?.accept(visitor);
819 } 825 }
820 826
821 /// Avoid parenthesis when pretty-printing.
822 @override int get precedenceLevel => PRIMARY;
823 @override Node _clone() => 827 @override Node _clone() =>
824 new DestructuredVariable( 828 new DestructuredVariable(
825 name: name, structure: structure, defaultValue: defaultValue); 829 name: name, structure: structure, defaultValue: defaultValue);
826 } 830 }
827 831
828 abstract class BindingPattern extends Expression implements VariableBinding { 832 abstract class BindingPattern extends Expression implements VariableBinding {
829 final List<DestructuredVariable> variables; 833 final List<DestructuredVariable> variables;
830 BindingPattern(this.variables); 834 BindingPattern(this.variables);
831 835
832 void visitChildren(NodeVisitor visitor) { 836 void visitChildren(NodeVisitor visitor) {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 1057
1054 Postfix _clone() => new Postfix(op, argument); 1058 Postfix _clone() => new Postfix(op, argument);
1055 1059
1056 void visitChildren(NodeVisitor visitor) { 1060 void visitChildren(NodeVisitor visitor) {
1057 argument.accept(visitor); 1061 argument.accept(visitor);
1058 } 1062 }
1059 1063
1060 int get precedenceLevel => UNARY; 1064 int get precedenceLevel => UNARY;
1061 } 1065 }
1062 1066
1063 abstract class Parameter implements Expression, VariableBinding { 1067 class Parameter extends Node implements VariableBinding {
1064 TypeRef get type; 1068 final VariableBinding binding;
1069 final TypeRef type;
1070 final Expression defaultValue;
1071 final bool isRest;
1072 Parameter(this.binding, {this.type, this.defaultValue, this.isRest: false});
1073
1074 accept(NodeVisitor visitor) => visitor.visitParameter(this);
1075 void visitChildren(NodeVisitor visitor) {
1076 binding?.accept(visitor);
1077 defaultValue?.accept(visitor);
1078 type?.accept(visitor);
1079 }
1080 Parameter _clone() => new Parameter(binding, type: type, isRest: isRest);
1065 } 1081 }
1066 1082
1067 class Identifier extends Expression implements Parameter, VariableBinding { 1083 class TypeParameter extends Node {
1084 final Identifier name;
1085 final TypeRef bound;
1086 TypeParameter(this.name, {this.bound});
1087
1088 accept(NodeVisitor visitor) => visitor.visitTypeParameter(this);
1089 void visitChildren(NodeVisitor visitor) {
1090 name?.accept(visitor);
1091 bound?.accept(visitor);
1092 }
1093 TypeParameter _clone() => new TypeParameter(name, bound: bound);
1094 }
1095
1096 class Identifier extends Expression implements VariableBinding {
1068 final String name; 1097 final String name;
1069 final bool allowRename; 1098 final bool allowRename;
1070 final TypeRef type;
1071 1099
1072 Identifier(this.name, {this.allowRename: true, this.type}) { 1100 Identifier(this.name, {this.allowRename: true}) {
1073 if (!_identifierRE.hasMatch(name)) { 1101 if (!_identifierRE.hasMatch(name)) {
1074 throw new ArgumentError.value(name, "name", "not a valid identifier"); 1102 throw new ArgumentError.value(name, "name", "not a valid identifier");
1075 } 1103 }
1076 } 1104 }
1077 static RegExp _identifierRE = new RegExp(r'^[A-Za-z_$][A-Za-z_$0-9]*$'); 1105 static RegExp _identifierRE = new RegExp(r'^[A-Za-z_$][A-Za-z_$0-9]*$');
1078 1106
1079 Identifier _clone() => 1107 Identifier _clone() =>
1080 new Identifier(name, allowRename: allowRename); 1108 new Identifier(name, allowRename: allowRename);
1081 accept(NodeVisitor visitor) => visitor.visitIdentifier(this); 1109 accept(NodeVisitor visitor) => visitor.visitIdentifier(this);
1082 int get precedenceLevel => PRIMARY; 1110 int get precedenceLevel => PRIMARY;
1083 void visitChildren(NodeVisitor visitor) {} 1111 void visitChildren(NodeVisitor visitor) {}
1084 } 1112 }
1085 1113
1086 // This is an expression for convenience in the AST.
1087 class RestParameter extends Expression implements Parameter {
1088 final Identifier parameter;
1089 TypeRef get type => null;
1090
1091 RestParameter(this.parameter);
1092
1093 RestParameter _clone() => new RestParameter(parameter);
1094 accept(NodeVisitor visitor) => visitor.visitRestParameter(this);
1095 void visitChildren(NodeVisitor visitor) {
1096 parameter.accept(visitor);
1097 }
1098 int get precedenceLevel => PRIMARY;
1099 }
1100
1101 class This extends Expression { 1114 class This extends Expression {
1102 accept(NodeVisitor visitor) => visitor.visitThis(this); 1115 accept(NodeVisitor visitor) => visitor.visitThis(this);
1103 This _clone() => new This(); 1116 This _clone() => new This();
1104 int get precedenceLevel => PRIMARY; 1117 int get precedenceLevel => PRIMARY;
1105 void visitChildren(NodeVisitor visitor) {} 1118 void visitChildren(NodeVisitor visitor) {}
1106 1119
1107 static bool foundIn(Node node) { 1120 static bool foundIn(Node node) {
1108 _thisFinder.found = false; 1121 _thisFinder.found = false;
1109 node.accept(_thisFinder); 1122 node.accept(_thisFinder);
1110 return _thisFinder.found; 1123 return _thisFinder.found;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 1161
1149 int get precedenceLevel => PRIMARY_LOW_PRECEDENCE; 1162 int get precedenceLevel => PRIMARY_LOW_PRECEDENCE;
1150 } 1163 }
1151 1164
1152 abstract class FunctionExpression extends Expression { 1165 abstract class FunctionExpression extends Expression {
1153 List<Parameter> get params; 1166 List<Parameter> get params;
1154 1167
1155 get body; // Expression or block 1168 get body; // Expression or block
1156 /// Type parameters passed to this generic function, if any. `null` otherwise. 1169 /// Type parameters passed to this generic function, if any. `null` otherwise.
1157 // TODO(ochafik): Support type bounds. 1170 // TODO(ochafik): Support type bounds.
1158 List<Identifier> get typeParams; 1171 List<TypeParameter> get typeParams;
1159 /// Return type of this function, if any. `null` otherwise. 1172 /// Return type of this function, if any. `null` otherwise.
1160 TypeRef get returnType; 1173 TypeRef get returnType;
1161 } 1174 }
1162 1175
1163 class Fun extends FunctionExpression { 1176 class Fun extends FunctionExpression {
1164 final List<Parameter> params; 1177 final List<Parameter> params;
1165 final Block body; 1178 final Block body;
1166 @override final List<Identifier> typeParams; 1179 @override final List<TypeParameter> typeParams;
1167 @override final TypeRef returnType; 1180 @override final TypeRef returnType;
1168 /** Whether this is a JS generator (`function*`) that may contain `yield`. */ 1181 /** Whether this is a JS generator (`function*`) that may contain `yield`. */
1169 final bool isGenerator; 1182 final bool isGenerator;
1170 1183
1171 final AsyncModifier asyncModifier; 1184 final AsyncModifier asyncModifier;
1172 1185
1173 Fun(this.params, this.body, {this.isGenerator: false, 1186 Fun(this.params, this.body, {this.isGenerator: false,
1174 this.asyncModifier: const AsyncModifier.sync(), 1187 this.asyncModifier: const AsyncModifier.sync(),
1175 this.typeParams, this.returnType}); 1188 this.typeParams, this.returnType});
1176 1189
1177 accept(NodeVisitor visitor) => visitor.visitFun(this); 1190 accept(NodeVisitor visitor) => visitor.visitFun(this);
1178 1191
1179 void visitChildren(NodeVisitor visitor) { 1192 void visitChildren(NodeVisitor visitor) {
1180 for (Parameter param in params) param.accept(visitor); 1193 for (Parameter param in params) param.accept(visitor);
1181 body.accept(visitor); 1194 body.accept(visitor);
1182 } 1195 }
1183 1196
1184 Fun _clone() => new Fun(params, body, 1197 Fun _clone() => new Fun(params, body,
1185 isGenerator: isGenerator, asyncModifier: asyncModifier); 1198 isGenerator: isGenerator, asyncModifier: asyncModifier);
1186 1199
1187 int get precedenceLevel => PRIMARY_LOW_PRECEDENCE; 1200 int get precedenceLevel => PRIMARY_LOW_PRECEDENCE;
1188 } 1201 }
1189 1202
1190 class ArrowFun extends FunctionExpression { 1203 class ArrowFun extends FunctionExpression {
1191 final List<Parameter> params; 1204 final List<Parameter> params;
1192 final body; // Expression or Block 1205 final body; // Expression or Block
1193 @override final List<Identifier> typeParams; 1206 @override final List<TypeParameter> typeParams;
1194 @override final TypeRef returnType; 1207 @override final TypeRef returnType;
1195 1208
1196 ArrowFun(this.params, this.body, {this.typeParams, this.returnType}); 1209 ArrowFun(this.params, this.body, {this.typeParams, this.returnType});
1197 1210
1198 accept(NodeVisitor visitor) => visitor.visitArrowFun(this); 1211 accept(NodeVisitor visitor) => visitor.visitArrowFun(this);
1199 1212
1200 void visitChildren(NodeVisitor visitor) { 1213 void visitChildren(NodeVisitor visitor) {
1201 for (Parameter param in params) param.accept(visitor); 1214 for (Parameter param in params) param.accept(visitor);
1202 body.accept(visitor); 1215 body.accept(visitor);
1203 } 1216 }
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 visitChildren(NodeVisitor visitor) => classExpr.accept(visitor); 1488 visitChildren(NodeVisitor visitor) => classExpr.accept(visitor);
1476 ClassDeclaration _clone() => new ClassDeclaration(classExpr); 1489 ClassDeclaration _clone() => new ClassDeclaration(classExpr);
1477 } 1490 }
1478 1491
1479 class ClassExpression extends Expression { 1492 class ClassExpression extends Expression {
1480 final Identifier name; 1493 final Identifier name;
1481 final Expression heritage; // Can be null. 1494 final Expression heritage; // Can be null.
1482 final List<Method> methods; 1495 final List<Method> methods;
1483 /// Type parameters of this class, if any. `null` otherwise. 1496 /// Type parameters of this class, if any. `null` otherwise.
1484 // TODO(ochafik): Support type bounds. 1497 // TODO(ochafik): Support type bounds.
1485 final List<Identifier> typeParams; 1498 final List<TypeParameter> typeParams;
1486 /// Field declarations of this class (TypeScript / ES6_TYPED). 1499 /// Field declarations of this class (TypeScript / ES6_TYPED).
1487 final List<VariableDeclarationList> fields; 1500 final List<VariableDeclarationList> fields;
1488 1501
1489 ClassExpression(this.name, this.heritage, this.methods, 1502 ClassExpression(this.name, this.heritage, this.methods,
1490 {this.typeParams, this.fields}); 1503 {this.typeParams, this.fields});
1491 1504
1492 accept(NodeVisitor visitor) => visitor.visitClassExpression(this); 1505 accept(NodeVisitor visitor) => visitor.visitClassExpression(this);
1493 1506
1494 void visitChildren(NodeVisitor visitor) { 1507 void visitChildren(NodeVisitor visitor) {
1495 name.accept(visitor); 1508 name.accept(visitor);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 final nameOrPosition; 1577 final nameOrPosition;
1565 1578
1566 InterpolatedLiteral(this.nameOrPosition); 1579 InterpolatedLiteral(this.nameOrPosition);
1567 1580
1568 accept(NodeVisitor visitor) => visitor.visitInterpolatedLiteral(this); 1581 accept(NodeVisitor visitor) => visitor.visitInterpolatedLiteral(this);
1569 void visitChildren(NodeVisitor visitor) {} 1582 void visitChildren(NodeVisitor visitor) {}
1570 InterpolatedLiteral _clone() => new InterpolatedLiteral(nameOrPosition); 1583 InterpolatedLiteral _clone() => new InterpolatedLiteral(nameOrPosition);
1571 } 1584 }
1572 1585
1573 class InterpolatedParameter extends Expression with InterpolatedNode 1586 class InterpolatedParameter extends Expression with InterpolatedNode
1574 implements Identifier { 1587 implements Parameter {
1575 final nameOrPosition; 1588 final nameOrPosition;
1589 final bool isRest;
1576 TypeRef get type => null; 1590 TypeRef get type => null;
1577 1591
1578 String get name { throw "InterpolatedParameter.name must not be invoked"; } 1592 Identifier get binding { throw "InterpolatedParameter.binding must not be invo ked"; }
1593 Expression get defaultValue { throw "InterpolatedParameter.defaultValue must n ot be invoked"; }
1579 bool get allowRename => false; 1594 bool get allowRename => false;
1580 1595
1581 InterpolatedParameter(this.nameOrPosition); 1596 InterpolatedParameter(this.nameOrPosition, {this.isRest: false});
1582 1597
1583 accept(NodeVisitor visitor) => visitor.visitInterpolatedParameter(this); 1598 accept(NodeVisitor visitor) => visitor.visitInterpolatedParameter(this);
1584 void visitChildren(NodeVisitor visitor) {} 1599 void visitChildren(NodeVisitor visitor) {}
1585 InterpolatedParameter _clone() => new InterpolatedParameter(nameOrPosition); 1600 InterpolatedParameter _clone() =>
1601 new InterpolatedParameter(nameOrPosition, isRest: isRest);
1586 1602
1587 int get precedenceLevel => PRIMARY; 1603 int get precedenceLevel => PRIMARY;
1588 } 1604 }
1589 1605
1590 class InterpolatedSelector extends Expression with InterpolatedNode { 1606 class InterpolatedSelector extends Expression with InterpolatedNode {
1591 final nameOrPosition; 1607 final nameOrPosition;
1592 1608
1593 InterpolatedSelector(this.nameOrPosition); 1609 InterpolatedSelector(this.nameOrPosition);
1594 1610
1595 accept(NodeVisitor visitor) => visitor.visitInterpolatedSelector(this); 1611 accept(NodeVisitor visitor) => visitor.visitInterpolatedSelector(this);
(...skipping 30 matching lines...) Expand all
1626 bool get isGetter => _unsupported; 1642 bool get isGetter => _unsupported;
1627 bool get isSetter => _unsupported; 1643 bool get isSetter => _unsupported;
1628 bool get isStatic => _unsupported; 1644 bool get isStatic => _unsupported;
1629 Fun get function => _unsupported; 1645 Fun get function => _unsupported;
1630 get _unsupported => throw '$runtimeType does not support this member.'; 1646 get _unsupported => throw '$runtimeType does not support this member.';
1631 } 1647 }
1632 1648
1633 class InterpolatedIdentifier extends Expression with InterpolatedNode 1649 class InterpolatedIdentifier extends Expression with InterpolatedNode
1634 implements Identifier { 1650 implements Identifier {
1635 final nameOrPosition; 1651 final nameOrPosition;
1636 TypeRef get type => null;
1637 1652
1638 InterpolatedIdentifier(this.nameOrPosition); 1653 InterpolatedIdentifier(this.nameOrPosition);
1639 1654
1640 accept(NodeVisitor visitor) => 1655 accept(NodeVisitor visitor) =>
1641 visitor.visitInterpolatedIdentifier(this); 1656 visitor.visitInterpolatedIdentifier(this);
1642 void visitChildren(NodeVisitor visitor) {} 1657 void visitChildren(NodeVisitor visitor) {}
1643 InterpolatedIdentifier _clone() => new InterpolatedIdentifier(nameOrPosition); 1658 InterpolatedIdentifier _clone() => new InterpolatedIdentifier(nameOrPosition);
1644 1659
1645 int get precedenceLevel => PRIMARY; 1660 int get precedenceLevel => PRIMARY;
1646 String get name => throw '$runtimeType does not support this member.'; 1661 String get name => throw '$runtimeType does not support this member.';
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 1844
1830 final List<ModuleItem> body; 1845 final List<ModuleItem> body;
1831 Module(this.body, {this.name}); 1846 Module(this.body, {this.name});
1832 1847
1833 accept(NodeVisitor visitor) => visitor.visitModule(this); 1848 accept(NodeVisitor visitor) => visitor.visitModule(this);
1834 void visitChildren(NodeVisitor visitor) { 1849 void visitChildren(NodeVisitor visitor) {
1835 for (ModuleItem item in body) item.accept(visitor); 1850 for (ModuleItem item in body) item.accept(visitor);
1836 } 1851 }
1837 Module _clone() => new Module(body); 1852 Module _clone() => new Module(body);
1838 } 1853 }
OLDNEW
« no previous file with comments | « lib/src/js/builder.dart ('k') | lib/src/js/printer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698