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, InterfaceType, TypeVariableType; | 9 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; |
10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 260 |
261 accept(ExpressionVisitor visitor) { | 261 accept(ExpressionVisitor visitor) { |
262 return visitor.visitInvokeConstructor(this); | 262 return visitor.visitInvokeConstructor(this); |
263 } | 263 } |
264 | 264 |
265 accept1(ExpressionVisitor1 visitor, arg) { | 265 accept1(ExpressionVisitor1 visitor, arg) { |
266 return visitor.visitInvokeConstructor(this, arg); | 266 return visitor.visitInvokeConstructor(this, arg); |
267 } | 267 } |
268 } | 268 } |
269 | 269 |
| 270 /// Calls [toString] on each argument and concatenates the results. |
| 271 class ConcatenateStrings extends Expression { |
| 272 final List<Expression> arguments; |
| 273 |
| 274 ConcatenateStrings(this.arguments); |
| 275 |
| 276 accept(ExpressionVisitor visitor) => visitor.visitConcatenateStrings(this); |
| 277 accept1(ExpressionVisitor1 visitor, arg) { |
| 278 return visitor.visitConcatenateStrings(this, arg); |
| 279 } |
| 280 } |
| 281 |
270 /** | 282 /** |
271 * A constant. | 283 * A constant. |
272 */ | 284 */ |
273 class Constant extends Expression { | 285 class Constant extends Expression { |
| 286 final ConstantExpression expression; |
274 final values.ConstantValue value; | 287 final values.ConstantValue value; |
275 | 288 |
276 Constant(this.value); | 289 Constant(this.expression, this.value); |
277 | 290 |
278 Constant.bool(values.BoolConstantValue constantValue) | 291 Constant.bool(values.BoolConstantValue constantValue) |
279 : value = constantValue; | 292 : expression = new BoolConstantExpression( |
| 293 constantValue.primitiveValue), |
| 294 value = constantValue; |
280 | 295 |
281 accept(ExpressionVisitor visitor) => visitor.visitConstant(this); | 296 accept(ExpressionVisitor visitor) => visitor.visitConstant(this); |
282 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitConstant(this, arg); | 297 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitConstant(this, arg); |
283 } | 298 } |
284 | 299 |
285 class This extends Expression { | 300 class This extends Expression { |
286 accept(ExpressionVisitor visitor) => visitor.visitThis(this); | 301 accept(ExpressionVisitor visitor) => visitor.visitThis(this); |
287 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitThis(this, arg); | 302 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitThis(this, arg); |
288 } | 303 } |
289 | 304 |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 } | 851 } |
837 | 852 |
838 abstract class ExpressionVisitor<E> { | 853 abstract class ExpressionVisitor<E> { |
839 E visitExpression(Expression node) => node.accept(this); | 854 E visitExpression(Expression node) => node.accept(this); |
840 E visitVariableUse(VariableUse node); | 855 E visitVariableUse(VariableUse node); |
841 E visitAssign(Assign node); | 856 E visitAssign(Assign node); |
842 E visitInvokeStatic(InvokeStatic node); | 857 E visitInvokeStatic(InvokeStatic node); |
843 E visitInvokeMethod(InvokeMethod node); | 858 E visitInvokeMethod(InvokeMethod node); |
844 E visitInvokeMethodDirectly(InvokeMethodDirectly node); | 859 E visitInvokeMethodDirectly(InvokeMethodDirectly node); |
845 E visitInvokeConstructor(InvokeConstructor node); | 860 E visitInvokeConstructor(InvokeConstructor node); |
| 861 E visitConcatenateStrings(ConcatenateStrings node); |
846 E visitConstant(Constant node); | 862 E visitConstant(Constant node); |
847 E visitThis(This node); | 863 E visitThis(This node); |
848 E visitConditional(Conditional node); | 864 E visitConditional(Conditional node); |
849 E visitLogicalOperator(LogicalOperator node); | 865 E visitLogicalOperator(LogicalOperator node); |
850 E visitNot(Not node); | 866 E visitNot(Not node); |
851 E visitLiteralList(LiteralList node); | 867 E visitLiteralList(LiteralList node); |
852 E visitLiteralMap(LiteralMap node); | 868 E visitLiteralMap(LiteralMap node); |
853 E visitTypeOperator(TypeOperator node); | 869 E visitTypeOperator(TypeOperator node); |
854 E visitFunctionExpression(FunctionExpression node); | 870 E visitFunctionExpression(FunctionExpression node); |
855 E visitGetField(GetField node); | 871 E visitGetField(GetField node); |
(...skipping 11 matching lines...) Expand all Loading... |
867 } | 883 } |
868 | 884 |
869 abstract class ExpressionVisitor1<E, A> { | 885 abstract class ExpressionVisitor1<E, A> { |
870 E visitExpression(Expression node, A arg) => node.accept1(this, arg); | 886 E visitExpression(Expression node, A arg) => node.accept1(this, arg); |
871 E visitVariableUse(VariableUse node, A arg); | 887 E visitVariableUse(VariableUse node, A arg); |
872 E visitAssign(Assign node, A arg); | 888 E visitAssign(Assign node, A arg); |
873 E visitInvokeStatic(InvokeStatic node, A arg); | 889 E visitInvokeStatic(InvokeStatic node, A arg); |
874 E visitInvokeMethod(InvokeMethod node, A arg); | 890 E visitInvokeMethod(InvokeMethod node, A arg); |
875 E visitInvokeMethodDirectly(InvokeMethodDirectly node, A arg); | 891 E visitInvokeMethodDirectly(InvokeMethodDirectly node, A arg); |
876 E visitInvokeConstructor(InvokeConstructor node, A arg); | 892 E visitInvokeConstructor(InvokeConstructor node, A arg); |
| 893 E visitConcatenateStrings(ConcatenateStrings node, A arg); |
877 E visitConstant(Constant node, A arg); | 894 E visitConstant(Constant node, A arg); |
878 E visitThis(This node, A arg); | 895 E visitThis(This node, A arg); |
879 E visitConditional(Conditional node, A arg); | 896 E visitConditional(Conditional node, A arg); |
880 E visitLogicalOperator(LogicalOperator node, A arg); | 897 E visitLogicalOperator(LogicalOperator node, A arg); |
881 E visitNot(Not node, A arg); | 898 E visitNot(Not node, A arg); |
882 E visitLiteralList(LiteralList node, A arg); | 899 E visitLiteralList(LiteralList node, A arg); |
883 E visitLiteralMap(LiteralMap node, A arg); | 900 E visitLiteralMap(LiteralMap node, A arg); |
884 E visitTypeOperator(TypeOperator node, A arg); | 901 E visitTypeOperator(TypeOperator node, A arg); |
885 E visitFunctionExpression(FunctionExpression node, A arg); | 902 E visitFunctionExpression(FunctionExpression node, A arg); |
886 E visitGetField(GetField node, A arg); | 903 E visitGetField(GetField node, A arg); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 | 976 |
960 visitInvokeMethodDirectly(InvokeMethodDirectly node) { | 977 visitInvokeMethodDirectly(InvokeMethodDirectly node) { |
961 visitExpression(node.receiver); | 978 visitExpression(node.receiver); |
962 node.arguments.forEach(visitExpression); | 979 node.arguments.forEach(visitExpression); |
963 } | 980 } |
964 | 981 |
965 visitInvokeConstructor(InvokeConstructor node) { | 982 visitInvokeConstructor(InvokeConstructor node) { |
966 node.arguments.forEach(visitExpression); | 983 node.arguments.forEach(visitExpression); |
967 } | 984 } |
968 | 985 |
| 986 visitConcatenateStrings(ConcatenateStrings node) { |
| 987 node.arguments.forEach(visitExpression); |
| 988 } |
| 989 |
969 visitConstant(Constant node) {} | 990 visitConstant(Constant node) {} |
970 | 991 |
971 visitThis(This node) {} | 992 visitThis(This node) {} |
972 | 993 |
973 visitConditional(Conditional node) { | 994 visitConditional(Conditional node) { |
974 visitExpression(node.condition); | 995 visitExpression(node.condition); |
975 visitExpression(node.thenExpression); | 996 visitExpression(node.thenExpression); |
976 visitExpression(node.elseExpression); | 997 visitExpression(node.elseExpression); |
977 } | 998 } |
978 | 999 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 node.receiver = visitExpression(node.receiver); | 1165 node.receiver = visitExpression(node.receiver); |
1145 _replaceExpressions(node.arguments); | 1166 _replaceExpressions(node.arguments); |
1146 return node; | 1167 return node; |
1147 } | 1168 } |
1148 | 1169 |
1149 visitInvokeConstructor(InvokeConstructor node) { | 1170 visitInvokeConstructor(InvokeConstructor node) { |
1150 _replaceExpressions(node.arguments); | 1171 _replaceExpressions(node.arguments); |
1151 return node; | 1172 return node; |
1152 } | 1173 } |
1153 | 1174 |
| 1175 visitConcatenateStrings(ConcatenateStrings node) { |
| 1176 _replaceExpressions(node.arguments); |
| 1177 return node; |
| 1178 } |
| 1179 |
1154 visitConstant(Constant node) => node; | 1180 visitConstant(Constant node) => node; |
1155 | 1181 |
1156 visitThis(This node) => node; | 1182 visitThis(This node) => node; |
1157 | 1183 |
1158 visitConditional(Conditional node) { | 1184 visitConditional(Conditional node) { |
1159 node.condition = visitExpression(node.condition); | 1185 node.condition = visitExpression(node.condition); |
1160 node.thenExpression = visitExpression(node.thenExpression); | 1186 node.thenExpression = visitExpression(node.thenExpression); |
1161 node.elseExpression = visitExpression(node.elseExpression); | 1187 node.elseExpression = visitExpression(node.elseExpression); |
1162 return node; | 1188 return node; |
1163 } | 1189 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 | 1333 |
1308 visitUnreachable(Unreachable node) { | 1334 visitUnreachable(Unreachable node) { |
1309 return node; | 1335 return node; |
1310 } | 1336 } |
1311 | 1337 |
1312 visitApplyBuiltinOperator(ApplyBuiltinOperator node) { | 1338 visitApplyBuiltinOperator(ApplyBuiltinOperator node) { |
1313 _replaceExpressions(node.arguments); | 1339 _replaceExpressions(node.arguments); |
1314 return node; | 1340 return node; |
1315 } | 1341 } |
1316 } | 1342 } |
OLD | NEW |