| OLD | NEW |
| 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; | 5 part of js; |
| 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 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 void visitChildren(NodeVisitor visitor) { | 1019 void visitChildren(NodeVisitor visitor) { |
| 1020 name.accept(visitor); | 1020 name.accept(visitor); |
| 1021 value.accept(visitor); | 1021 value.accept(visitor); |
| 1022 } | 1022 } |
| 1023 | 1023 |
| 1024 Property _clone() => new Property(name, value); | 1024 Property _clone() => new Property(name, value); |
| 1025 } | 1025 } |
| 1026 | 1026 |
| 1027 /// Tag class for all interpolated positions. | 1027 /// Tag class for all interpolated positions. |
| 1028 abstract class InterpolatedNode implements Node { | 1028 abstract class InterpolatedNode implements Node { |
| 1029 get name; // 'int' for positional interpolated nodes, 'String' for named. | 1029 get nameOrPosition; |
| 1030 |
| 1031 bool get isNamed => nameOrPosition is String; |
| 1032 bool get isPositional => nameOrPosition is int; |
| 1030 } | 1033 } |
| 1031 | 1034 |
| 1032 class InterpolatedExpression extends Expression implements InterpolatedNode { | 1035 class InterpolatedExpression extends Expression with InterpolatedNode { |
| 1033 final name; | 1036 final nameOrPosition; |
| 1034 | 1037 |
| 1035 InterpolatedExpression(this.name); | 1038 InterpolatedExpression(this.nameOrPosition); |
| 1036 | 1039 |
| 1037 accept(NodeVisitor visitor) => visitor.visitInterpolatedExpression(this); | 1040 accept(NodeVisitor visitor) => visitor.visitInterpolatedExpression(this); |
| 1038 void visitChildren(NodeVisitor visitor) {} | 1041 void visitChildren(NodeVisitor visitor) {} |
| 1039 InterpolatedExpression _clone() => new InterpolatedExpression(name); | 1042 InterpolatedExpression _clone() => |
| 1043 new InterpolatedExpression(nameOrPosition); |
| 1040 | 1044 |
| 1041 int get precedenceLevel => PRIMARY; | 1045 int get precedenceLevel => PRIMARY; |
| 1042 } | 1046 } |
| 1043 | 1047 |
| 1044 class InterpolatedLiteral extends Literal implements InterpolatedNode { | 1048 class InterpolatedLiteral extends Literal with InterpolatedNode { |
| 1045 final name; | 1049 final nameOrPosition; |
| 1046 | 1050 |
| 1047 InterpolatedLiteral(this.name); | 1051 InterpolatedLiteral(this.nameOrPosition); |
| 1048 | 1052 |
| 1049 accept(NodeVisitor visitor) => visitor.visitInterpolatedLiteral(this); | 1053 accept(NodeVisitor visitor) => visitor.visitInterpolatedLiteral(this); |
| 1050 void visitChildren(NodeVisitor visitor) {} | 1054 void visitChildren(NodeVisitor visitor) {} |
| 1051 InterpolatedLiteral _clone() => new InterpolatedLiteral(name); | 1055 InterpolatedLiteral _clone() => new InterpolatedLiteral(nameOrPosition); |
| 1052 } | 1056 } |
| 1053 | 1057 |
| 1054 class InterpolatedParameter extends Expression | 1058 class InterpolatedParameter extends Expression with InterpolatedNode |
| 1055 implements Parameter, InterpolatedNode { | 1059 implements Parameter { |
| 1056 final name; | 1060 final nameOrPosition; |
| 1061 |
| 1062 String get name { throw "InterpolatedParameter.name must not be invoked"; } |
| 1057 bool get allowRename => false; | 1063 bool get allowRename => false; |
| 1058 | 1064 |
| 1059 InterpolatedParameter(this.name); | 1065 InterpolatedParameter(this.nameOrPosition); |
| 1060 | 1066 |
| 1061 accept(NodeVisitor visitor) => visitor.visitInterpolatedParameter(this); | 1067 accept(NodeVisitor visitor) => visitor.visitInterpolatedParameter(this); |
| 1062 void visitChildren(NodeVisitor visitor) {} | 1068 void visitChildren(NodeVisitor visitor) {} |
| 1063 InterpolatedParameter _clone() => new InterpolatedParameter(name); | 1069 InterpolatedParameter _clone() => new InterpolatedParameter(nameOrPosition); |
| 1064 | 1070 |
| 1065 int get precedenceLevel => PRIMARY; | 1071 int get precedenceLevel => PRIMARY; |
| 1066 } | 1072 } |
| 1067 | 1073 |
| 1068 class InterpolatedSelector extends Expression implements InterpolatedNode { | 1074 class InterpolatedSelector extends Expression with InterpolatedNode { |
| 1069 final name; | 1075 final nameOrPosition; |
| 1070 | 1076 |
| 1071 InterpolatedSelector(this.name); | 1077 InterpolatedSelector(this.nameOrPosition); |
| 1072 | 1078 |
| 1073 accept(NodeVisitor visitor) => visitor.visitInterpolatedSelector(this); | 1079 accept(NodeVisitor visitor) => visitor.visitInterpolatedSelector(this); |
| 1074 void visitChildren(NodeVisitor visitor) {} | 1080 void visitChildren(NodeVisitor visitor) {} |
| 1075 InterpolatedSelector _clone() => new InterpolatedSelector(name); | 1081 InterpolatedSelector _clone() => new InterpolatedSelector(nameOrPosition); |
| 1076 | 1082 |
| 1077 int get precedenceLevel => PRIMARY; | 1083 int get precedenceLevel => PRIMARY; |
| 1078 } | 1084 } |
| 1079 | 1085 |
| 1080 class InterpolatedStatement extends Statement implements InterpolatedNode { | 1086 class InterpolatedStatement extends Statement with InterpolatedNode { |
| 1081 final name; | 1087 final nameOrPosition; |
| 1082 | 1088 |
| 1083 InterpolatedStatement(this.name); | 1089 InterpolatedStatement(this.nameOrPosition); |
| 1084 | 1090 |
| 1085 accept(NodeVisitor visitor) => visitor.visitInterpolatedStatement(this); | 1091 accept(NodeVisitor visitor) => visitor.visitInterpolatedStatement(this); |
| 1086 void visitChildren(NodeVisitor visitor) {} | 1092 void visitChildren(NodeVisitor visitor) {} |
| 1087 InterpolatedStatement _clone() => new InterpolatedStatement(name); | 1093 InterpolatedStatement _clone() => new InterpolatedStatement(nameOrPosition); |
| 1088 } | 1094 } |
| 1089 | 1095 |
| 1090 /** | 1096 /** |
| 1091 * [RegExpLiteral]s, despite being called "Literal", do not inherit from | 1097 * [RegExpLiteral]s, despite being called "Literal", do not inherit from |
| 1092 * [Literal]. Indeed, regular expressions in JavaScript have a side-effect and | 1098 * [Literal]. Indeed, regular expressions in JavaScript have a side-effect and |
| 1093 * are thus not in the same category as numbers or strings. | 1099 * are thus not in the same category as numbers or strings. |
| 1094 */ | 1100 */ |
| 1095 class RegExpLiteral extends Expression { | 1101 class RegExpLiteral extends Expression { |
| 1096 /** Contains the pattern and the flags.*/ | 1102 /** Contains the pattern and the flags.*/ |
| 1097 final String pattern; | 1103 final String pattern; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1114 class Comment extends Statement { | 1120 class Comment extends Statement { |
| 1115 final String comment; | 1121 final String comment; |
| 1116 | 1122 |
| 1117 Comment(this.comment); | 1123 Comment(this.comment); |
| 1118 | 1124 |
| 1119 accept(NodeVisitor visitor) => visitor.visitComment(this); | 1125 accept(NodeVisitor visitor) => visitor.visitComment(this); |
| 1120 Comment _clone() => new Comment(comment); | 1126 Comment _clone() => new Comment(comment); |
| 1121 | 1127 |
| 1122 void visitChildren(NodeVisitor visitor) {} | 1128 void visitChildren(NodeVisitor visitor) {} |
| 1123 } | 1129 } |
| OLD | NEW |