| 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/values.dart' as values; | 7 import '../constants/values.dart' as values; |
| 8 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; | 8 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; |
| 9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
| 10 import '../io/source_information.dart' show SourceInformation; | 10 import '../io/source_information.dart' show SourceInformation; |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 | 261 |
| 262 accept(ExpressionVisitor visitor) { | 262 accept(ExpressionVisitor visitor) { |
| 263 return visitor.visitInvokeConstructor(this); | 263 return visitor.visitInvokeConstructor(this); |
| 264 } | 264 } |
| 265 | 265 |
| 266 accept1(ExpressionVisitor1 visitor, arg) { | 266 accept1(ExpressionVisitor1 visitor, arg) { |
| 267 return visitor.visitInvokeConstructor(this, arg); | 267 return visitor.visitInvokeConstructor(this, arg); |
| 268 } | 268 } |
| 269 } | 269 } |
| 270 | 270 |
| 271 /// Call a method using a one-shot interceptor. |
| 272 /// |
| 273 /// There is no explicit receiver, the first argument serves that purpose. |
| 274 class OneShotInterceptor extends Expression implements Invoke { |
| 275 final Selector selector; |
| 276 final TypeMask mask; |
| 277 final List<Expression> arguments; |
| 278 final SourceInformation sourceInformation; |
| 279 |
| 280 OneShotInterceptor(this.selector, |
| 281 this.mask, |
| 282 this.arguments, |
| 283 this.sourceInformation); |
| 284 |
| 285 accept(ExpressionVisitor visitor) => visitor.visitOneShotInterceptor(this); |
| 286 accept1(ExpressionVisitor1 visitor, arg) { |
| 287 return visitor.visitOneShotInterceptor(this, arg); |
| 288 } |
| 289 } |
| 290 |
| 271 /** | 291 /** |
| 272 * A constant. | 292 * A constant. |
| 273 */ | 293 */ |
| 274 class Constant extends Expression { | 294 class Constant extends Expression { |
| 275 final values.ConstantValue value; | 295 final values.ConstantValue value; |
| 276 final SourceInformation sourceInformation; | 296 final SourceInformation sourceInformation; |
| 277 | 297 |
| 278 Constant(this.value, {this.sourceInformation}); | 298 Constant(this.value, {this.sourceInformation}); |
| 279 | 299 |
| 280 Constant.bool(values.BoolConstantValue constantValue) | 300 Constant.bool(values.BoolConstantValue constantValue) |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 } | 1006 } |
| 987 | 1007 |
| 988 abstract class ExpressionVisitor<E> { | 1008 abstract class ExpressionVisitor<E> { |
| 989 E visitExpression(Expression node) => node.accept(this); | 1009 E visitExpression(Expression node) => node.accept(this); |
| 990 E visitVariableUse(VariableUse node); | 1010 E visitVariableUse(VariableUse node); |
| 991 E visitAssign(Assign node); | 1011 E visitAssign(Assign node); |
| 992 E visitInvokeStatic(InvokeStatic node); | 1012 E visitInvokeStatic(InvokeStatic node); |
| 993 E visitInvokeMethod(InvokeMethod node); | 1013 E visitInvokeMethod(InvokeMethod node); |
| 994 E visitInvokeMethodDirectly(InvokeMethodDirectly node); | 1014 E visitInvokeMethodDirectly(InvokeMethodDirectly node); |
| 995 E visitInvokeConstructor(InvokeConstructor node); | 1015 E visitInvokeConstructor(InvokeConstructor node); |
| 1016 E visitOneShotInterceptor(OneShotInterceptor node); |
| 996 E visitConstant(Constant node); | 1017 E visitConstant(Constant node); |
| 997 E visitThis(This node); | 1018 E visitThis(This node); |
| 998 E visitConditional(Conditional node); | 1019 E visitConditional(Conditional node); |
| 999 E visitLogicalOperator(LogicalOperator node); | 1020 E visitLogicalOperator(LogicalOperator node); |
| 1000 E visitNot(Not node); | 1021 E visitNot(Not node); |
| 1001 E visitLiteralList(LiteralList node); | 1022 E visitLiteralList(LiteralList node); |
| 1002 E visitLiteralMap(LiteralMap node); | 1023 E visitLiteralMap(LiteralMap node); |
| 1003 E visitTypeOperator(TypeOperator node); | 1024 E visitTypeOperator(TypeOperator node); |
| 1004 E visitGetField(GetField node); | 1025 E visitGetField(GetField node); |
| 1005 E visitSetField(SetField node); | 1026 E visitSetField(SetField node); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1023 } | 1044 } |
| 1024 | 1045 |
| 1025 abstract class ExpressionVisitor1<E, A> { | 1046 abstract class ExpressionVisitor1<E, A> { |
| 1026 E visitExpression(Expression node, A arg) => node.accept1(this, arg); | 1047 E visitExpression(Expression node, A arg) => node.accept1(this, arg); |
| 1027 E visitVariableUse(VariableUse node, A arg); | 1048 E visitVariableUse(VariableUse node, A arg); |
| 1028 E visitAssign(Assign node, A arg); | 1049 E visitAssign(Assign node, A arg); |
| 1029 E visitInvokeStatic(InvokeStatic node, A arg); | 1050 E visitInvokeStatic(InvokeStatic node, A arg); |
| 1030 E visitInvokeMethod(InvokeMethod node, A arg); | 1051 E visitInvokeMethod(InvokeMethod node, A arg); |
| 1031 E visitInvokeMethodDirectly(InvokeMethodDirectly node, A arg); | 1052 E visitInvokeMethodDirectly(InvokeMethodDirectly node, A arg); |
| 1032 E visitInvokeConstructor(InvokeConstructor node, A arg); | 1053 E visitInvokeConstructor(InvokeConstructor node, A arg); |
| 1054 E visitOneShotInterceptor(OneShotInterceptor node, A arg); |
| 1033 E visitConstant(Constant node, A arg); | 1055 E visitConstant(Constant node, A arg); |
| 1034 E visitThis(This node, A arg); | 1056 E visitThis(This node, A arg); |
| 1035 E visitConditional(Conditional node, A arg); | 1057 E visitConditional(Conditional node, A arg); |
| 1036 E visitLogicalOperator(LogicalOperator node, A arg); | 1058 E visitLogicalOperator(LogicalOperator node, A arg); |
| 1037 E visitNot(Not node, A arg); | 1059 E visitNot(Not node, A arg); |
| 1038 E visitLiteralList(LiteralList node, A arg); | 1060 E visitLiteralList(LiteralList node, A arg); |
| 1039 E visitLiteralMap(LiteralMap node, A arg); | 1061 E visitLiteralMap(LiteralMap node, A arg); |
| 1040 E visitTypeOperator(TypeOperator node, A arg); | 1062 E visitTypeOperator(TypeOperator node, A arg); |
| 1041 E visitGetField(GetField node, A arg); | 1063 E visitGetField(GetField node, A arg); |
| 1042 E visitSetField(SetField node, A arg); | 1064 E visitSetField(SetField node, A arg); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 | 1145 |
| 1124 visitInvokeMethodDirectly(InvokeMethodDirectly node) { | 1146 visitInvokeMethodDirectly(InvokeMethodDirectly node) { |
| 1125 visitExpression(node.receiver); | 1147 visitExpression(node.receiver); |
| 1126 node.arguments.forEach(visitExpression); | 1148 node.arguments.forEach(visitExpression); |
| 1127 } | 1149 } |
| 1128 | 1150 |
| 1129 visitInvokeConstructor(InvokeConstructor node) { | 1151 visitInvokeConstructor(InvokeConstructor node) { |
| 1130 node.arguments.forEach(visitExpression); | 1152 node.arguments.forEach(visitExpression); |
| 1131 } | 1153 } |
| 1132 | 1154 |
| 1155 visitOneShotInterceptor(OneShotInterceptor node) { |
| 1156 node.arguments.forEach(visitExpression); |
| 1157 } |
| 1158 |
| 1133 visitConstant(Constant node) {} | 1159 visitConstant(Constant node) {} |
| 1134 | 1160 |
| 1135 visitThis(This node) {} | 1161 visitThis(This node) {} |
| 1136 | 1162 |
| 1137 visitConditional(Conditional node) { | 1163 visitConditional(Conditional node) { |
| 1138 visitExpression(node.condition); | 1164 visitExpression(node.condition); |
| 1139 visitExpression(node.thenExpression); | 1165 visitExpression(node.thenExpression); |
| 1140 visitExpression(node.elseExpression); | 1166 visitExpression(node.elseExpression); |
| 1141 } | 1167 } |
| 1142 | 1168 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1350 node.receiver = visitExpression(node.receiver); | 1376 node.receiver = visitExpression(node.receiver); |
| 1351 _replaceExpressions(node.arguments); | 1377 _replaceExpressions(node.arguments); |
| 1352 return node; | 1378 return node; |
| 1353 } | 1379 } |
| 1354 | 1380 |
| 1355 visitInvokeConstructor(InvokeConstructor node) { | 1381 visitInvokeConstructor(InvokeConstructor node) { |
| 1356 _replaceExpressions(node.arguments); | 1382 _replaceExpressions(node.arguments); |
| 1357 return node; | 1383 return node; |
| 1358 } | 1384 } |
| 1359 | 1385 |
| 1386 visitOneShotInterceptor(OneShotInterceptor node) { |
| 1387 _replaceExpressions(node.arguments); |
| 1388 return node; |
| 1389 } |
| 1390 |
| 1360 visitConstant(Constant node) => node; | 1391 visitConstant(Constant node) => node; |
| 1361 | 1392 |
| 1362 visitThis(This node) => node; | 1393 visitThis(This node) => node; |
| 1363 | 1394 |
| 1364 visitConditional(Conditional node) { | 1395 visitConditional(Conditional node) { |
| 1365 node.condition = visitExpression(node.condition); | 1396 node.condition = visitExpression(node.condition); |
| 1366 node.thenExpression = visitExpression(node.thenExpression); | 1397 node.thenExpression = visitExpression(node.thenExpression); |
| 1367 node.elseExpression = visitExpression(node.elseExpression); | 1398 node.elseExpression = visitExpression(node.elseExpression); |
| 1368 return node; | 1399 return node; |
| 1369 } | 1400 } |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1609 | 1640 |
| 1610 /// Number of uses of the current fallthrough target. | 1641 /// Number of uses of the current fallthrough target. |
| 1611 int get useCount => _stack.last.useCount; | 1642 int get useCount => _stack.last.useCount; |
| 1612 | 1643 |
| 1613 /// Indicate that a statement will fall through to the current fallthrough | 1644 /// Indicate that a statement will fall through to the current fallthrough |
| 1614 /// target. | 1645 /// target. |
| 1615 void use() { | 1646 void use() { |
| 1616 ++_stack.last.useCount; | 1647 ++_stack.last.useCount; |
| 1617 } | 1648 } |
| 1618 } | 1649 } |
| OLD | NEW |