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