| 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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 accept1(ExpressionVisitor1 visitor, arg) { | 397 accept1(ExpressionVisitor1 visitor, arg) { |
| 398 return visitor.visitConditional(this, arg); | 398 return visitor.visitConditional(this, arg); |
| 399 } | 399 } |
| 400 | 400 |
| 401 String toString() => 'Conditional(condition=$condition,thenExpression=' | 401 String toString() => 'Conditional(condition=$condition,thenExpression=' |
| 402 '$thenExpression,elseExpression=$elseExpression)'; | 402 '$thenExpression,elseExpression=$elseExpression)'; |
| 403 } | 403 } |
| 404 | 404 |
| 405 /// An && or || expression. The operator is internally represented as a boolean | 405 /// An && or || expression. The operator is internally represented as a boolean |
| 406 /// [isAnd] to simplify rewriting of logical operators. | 406 /// [isAnd] to simplify rewriting of logical operators. |
| 407 /// Note the the result of && and || is one of the arguments, which might not be | |
| 408 /// boolean. 'ShortCircuitOperator' might have been a better name. | |
| 409 class LogicalOperator extends Expression { | 407 class LogicalOperator extends Expression { |
| 410 Expression left; | 408 Expression left; |
| 411 bool isAnd; | 409 bool isAnd; |
| 412 Expression right; | 410 Expression right; |
| 413 | 411 |
| 414 LogicalOperator(this.left, this.right, this.isAnd); | 412 LogicalOperator(this.left, this.right, this.isAnd); |
| 415 LogicalOperator.and(this.left, this.right) : isAnd = true; | 413 LogicalOperator.and(this.left, this.right) : isAnd = true; |
| 416 LogicalOperator.or(this.left, this.right) : isAnd = false; | 414 LogicalOperator.or(this.left, this.right) : isAnd = false; |
| 417 | 415 |
| 418 String get operator => isAnd ? '&&' : '||'; | 416 String get operator => isAnd ? '&&' : '||'; |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 Expression object; | 735 Expression object; |
| 738 Element field; | 736 Element field; |
| 739 Expression value; | 737 Expression value; |
| 740 | 738 |
| 741 SetField(this.object, this.field, this.value); | 739 SetField(this.object, this.field, this.value); |
| 742 | 740 |
| 743 accept(ExpressionVisitor visitor) => visitor.visitSetField(this); | 741 accept(ExpressionVisitor visitor) => visitor.visitSetField(this); |
| 744 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitSetField(this, arg); | 742 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitSetField(this, arg); |
| 745 } | 743 } |
| 746 | 744 |
| 747 | |
| 748 /// Read the type test property from [object]. The value is truthy/fasly rather | |
| 749 /// than bool. [object] must not be `null`. | |
| 750 class GetTypeTestProperty extends Expression { | |
| 751 Expression object; | |
| 752 DartType dartType; | |
| 753 | |
| 754 GetTypeTestProperty(this.object, this.dartType); | |
| 755 | |
| 756 accept(ExpressionVisitor visitor) => | |
| 757 visitor.visitGetTypeTestProperty(this); | |
| 758 accept1(ExpressionVisitor1 visitor, arg) => | |
| 759 visitor.visitGetTypeTestProperty(this, arg); | |
| 760 } | |
| 761 | |
| 762 | |
| 763 /// Read the value of a field, possibly provoking its initializer to evaluate, | 745 /// Read the value of a field, possibly provoking its initializer to evaluate, |
| 764 /// or tear off a static method. | 746 /// or tear off a static method. |
| 765 class GetStatic extends Expression { | 747 class GetStatic extends Expression { |
| 766 Element element; | 748 Element element; |
| 767 SourceInformation sourceInformation; | 749 SourceInformation sourceInformation; |
| 768 | 750 |
| 769 GetStatic(this.element, this.sourceInformation); | 751 GetStatic(this.element, this.sourceInformation); |
| 770 | 752 |
| 771 accept(ExpressionVisitor visitor) => visitor.visitGetStatic(this); | 753 accept(ExpressionVisitor visitor) => visitor.visitGetStatic(this); |
| 772 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitGetStatic(this, arg); | 754 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitGetStatic(this, arg); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 E visitLogicalOperator(LogicalOperator node); | 968 E visitLogicalOperator(LogicalOperator node); |
| 987 E visitNot(Not node); | 969 E visitNot(Not node); |
| 988 E visitLiteralList(LiteralList node); | 970 E visitLiteralList(LiteralList node); |
| 989 E visitLiteralMap(LiteralMap node); | 971 E visitLiteralMap(LiteralMap node); |
| 990 E visitTypeOperator(TypeOperator node); | 972 E visitTypeOperator(TypeOperator node); |
| 991 E visitFunctionExpression(FunctionExpression node); | 973 E visitFunctionExpression(FunctionExpression node); |
| 992 E visitGetField(GetField node); | 974 E visitGetField(GetField node); |
| 993 E visitSetField(SetField node); | 975 E visitSetField(SetField node); |
| 994 E visitGetStatic(GetStatic node); | 976 E visitGetStatic(GetStatic node); |
| 995 E visitSetStatic(SetStatic node); | 977 E visitSetStatic(SetStatic node); |
| 996 E visitGetTypeTestProperty(GetTypeTestProperty node); | |
| 997 E visitCreateBox(CreateBox node); | 978 E visitCreateBox(CreateBox node); |
| 998 E visitCreateInstance(CreateInstance node); | 979 E visitCreateInstance(CreateInstance node); |
| 999 E visitReifyRuntimeType(ReifyRuntimeType node); | 980 E visitReifyRuntimeType(ReifyRuntimeType node); |
| 1000 E visitReadTypeVariable(ReadTypeVariable node); | 981 E visitReadTypeVariable(ReadTypeVariable node); |
| 1001 E visitTypeExpression(TypeExpression node); | 982 E visitTypeExpression(TypeExpression node); |
| 1002 E visitCreateInvocationMirror(CreateInvocationMirror node); | 983 E visitCreateInvocationMirror(CreateInvocationMirror node); |
| 1003 E visitInterceptor(Interceptor node); | 984 E visitInterceptor(Interceptor node); |
| 1004 E visitApplyBuiltinOperator(ApplyBuiltinOperator node); | 985 E visitApplyBuiltinOperator(ApplyBuiltinOperator node); |
| 1005 E visitApplyBuiltinMethod(ApplyBuiltinMethod node); | 986 E visitApplyBuiltinMethod(ApplyBuiltinMethod node); |
| 1006 E visitForeignExpression(ForeignExpression node); | 987 E visitForeignExpression(ForeignExpression node); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1024 E visitLogicalOperator(LogicalOperator node, A arg); | 1005 E visitLogicalOperator(LogicalOperator node, A arg); |
| 1025 E visitNot(Not node, A arg); | 1006 E visitNot(Not node, A arg); |
| 1026 E visitLiteralList(LiteralList node, A arg); | 1007 E visitLiteralList(LiteralList node, A arg); |
| 1027 E visitLiteralMap(LiteralMap node, A arg); | 1008 E visitLiteralMap(LiteralMap node, A arg); |
| 1028 E visitTypeOperator(TypeOperator node, A arg); | 1009 E visitTypeOperator(TypeOperator node, A arg); |
| 1029 E visitFunctionExpression(FunctionExpression node, A arg); | 1010 E visitFunctionExpression(FunctionExpression node, A arg); |
| 1030 E visitGetField(GetField node, A arg); | 1011 E visitGetField(GetField node, A arg); |
| 1031 E visitSetField(SetField node, A arg); | 1012 E visitSetField(SetField node, A arg); |
| 1032 E visitGetStatic(GetStatic node, A arg); | 1013 E visitGetStatic(GetStatic node, A arg); |
| 1033 E visitSetStatic(SetStatic node, A arg); | 1014 E visitSetStatic(SetStatic node, A arg); |
| 1034 E visitGetTypeTestProperty(GetTypeTestProperty node, A arg); | |
| 1035 E visitCreateBox(CreateBox node, A arg); | 1015 E visitCreateBox(CreateBox node, A arg); |
| 1036 E visitCreateInstance(CreateInstance node, A arg); | 1016 E visitCreateInstance(CreateInstance node, A arg); |
| 1037 E visitReifyRuntimeType(ReifyRuntimeType node, A arg); | 1017 E visitReifyRuntimeType(ReifyRuntimeType node, A arg); |
| 1038 E visitReadTypeVariable(ReadTypeVariable node, A arg); | 1018 E visitReadTypeVariable(ReadTypeVariable node, A arg); |
| 1039 E visitTypeExpression(TypeExpression node, A arg); | 1019 E visitTypeExpression(TypeExpression node, A arg); |
| 1040 E visitCreateInvocationMirror(CreateInvocationMirror node, A arg); | 1020 E visitCreateInvocationMirror(CreateInvocationMirror node, A arg); |
| 1041 E visitInterceptor(Interceptor node, A arg); | 1021 E visitInterceptor(Interceptor node, A arg); |
| 1042 E visitApplyBuiltinOperator(ApplyBuiltinOperator node, A arg); | 1022 E visitApplyBuiltinOperator(ApplyBuiltinOperator node, A arg); |
| 1043 E visitApplyBuiltinMethod(ApplyBuiltinMethod node, A arg); | 1023 E visitApplyBuiltinMethod(ApplyBuiltinMethod node, A arg); |
| 1044 E visitForeignExpression(ForeignExpression node, A arg); | 1024 E visitForeignExpression(ForeignExpression node, A arg); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 visitExpression(node.value); | 1199 visitExpression(node.value); |
| 1220 } | 1200 } |
| 1221 | 1201 |
| 1222 visitGetStatic(GetStatic node) { | 1202 visitGetStatic(GetStatic node) { |
| 1223 } | 1203 } |
| 1224 | 1204 |
| 1225 visitSetStatic(SetStatic node) { | 1205 visitSetStatic(SetStatic node) { |
| 1226 visitExpression(node.value); | 1206 visitExpression(node.value); |
| 1227 } | 1207 } |
| 1228 | 1208 |
| 1229 visitGetTypeTestProperty(GetTypeTestProperty node) { | |
| 1230 visitExpression(node.object); | |
| 1231 } | |
| 1232 | |
| 1233 visitCreateBox(CreateBox node) { | 1209 visitCreateBox(CreateBox node) { |
| 1234 } | 1210 } |
| 1235 | 1211 |
| 1236 visitCreateInstance(CreateInstance node) { | 1212 visitCreateInstance(CreateInstance node) { |
| 1237 node.arguments.forEach(visitExpression); | 1213 node.arguments.forEach(visitExpression); |
| 1238 node.typeInformation.forEach(visitExpression); | 1214 node.typeInformation.forEach(visitExpression); |
| 1239 } | 1215 } |
| 1240 | 1216 |
| 1241 visitReifyRuntimeType(ReifyRuntimeType node) { | 1217 visitReifyRuntimeType(ReifyRuntimeType node) { |
| 1242 visitExpression(node.value); | 1218 visitExpression(node.value); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1468 return node; | 1444 return node; |
| 1469 } | 1445 } |
| 1470 | 1446 |
| 1471 visitGetStatic(GetStatic node) => node; | 1447 visitGetStatic(GetStatic node) => node; |
| 1472 | 1448 |
| 1473 visitSetStatic(SetStatic node) { | 1449 visitSetStatic(SetStatic node) { |
| 1474 node.value = visitExpression(node.value); | 1450 node.value = visitExpression(node.value); |
| 1475 return node; | 1451 return node; |
| 1476 } | 1452 } |
| 1477 | 1453 |
| 1478 visitGetTypeTestProperty(GetTypeTestProperty node) { | |
| 1479 node.object = visitExpression(node.object); | |
| 1480 return node; | |
| 1481 } | |
| 1482 | |
| 1483 visitCreateBox(CreateBox node) => node; | 1454 visitCreateBox(CreateBox node) => node; |
| 1484 | 1455 |
| 1485 visitCreateInstance(CreateInstance node) { | 1456 visitCreateInstance(CreateInstance node) { |
| 1486 _replaceExpressions(node.arguments); | 1457 _replaceExpressions(node.arguments); |
| 1487 _replaceExpressions(node.typeInformation); | 1458 _replaceExpressions(node.typeInformation); |
| 1488 return node; | 1459 return node; |
| 1489 } | 1460 } |
| 1490 | 1461 |
| 1491 visitReifyRuntimeType(ReifyRuntimeType node) { | 1462 visitReifyRuntimeType(ReifyRuntimeType node) { |
| 1492 node.value = visitExpression(node.value); | 1463 node.value = visitExpression(node.value); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1596 | 1567 |
| 1597 /// Number of uses of the current fallthrough target. | 1568 /// Number of uses of the current fallthrough target. |
| 1598 int get useCount => _stack.last.useCount; | 1569 int get useCount => _stack.last.useCount; |
| 1599 | 1570 |
| 1600 /// Indicate that a statement will fall through to the current fallthrough | 1571 /// Indicate that a statement will fall through to the current fallthrough |
| 1601 /// target. | 1572 /// target. |
| 1602 void use() { | 1573 void use() { |
| 1603 ++_stack.last.useCount; | 1574 ++_stack.last.useCount; |
| 1604 } | 1575 } |
| 1605 } | 1576 } |
| OLD | NEW |