| 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 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 | 943 |
| 944 accept(StatementVisitor visitor) { | 944 accept(StatementVisitor visitor) { |
| 945 return visitor.visitYield(this); | 945 return visitor.visitYield(this); |
| 946 } | 946 } |
| 947 | 947 |
| 948 accept1(StatementVisitor1 visitor, arg) { | 948 accept1(StatementVisitor1 visitor, arg) { |
| 949 return visitor.visitYield(this, arg); | 949 return visitor.visitYield(this, arg); |
| 950 } | 950 } |
| 951 } | 951 } |
| 952 | 952 |
| 953 class NullCheck extends Statement { | 953 class ReceiverCheck extends Statement { |
| 954 Expression condition; | 954 Expression condition; |
| 955 Expression value; | 955 Expression value; |
| 956 Selector selector; | 956 Selector selector; |
| 957 bool useSelector; | 957 bool useSelector; |
| 958 bool useInvoke; |
| 958 Statement next; | 959 Statement next; |
| 959 SourceInformation sourceInformation; | 960 SourceInformation sourceInformation; |
| 960 | 961 |
| 961 NullCheck({this.condition, this.value, this.selector, this.useSelector, | 962 ReceiverCheck({this.condition, this.value, this.selector, this.useSelector, |
| 962 this.next, this.sourceInformation}); | 963 this.useInvoke, this.next, this.sourceInformation}); |
| 963 | 964 |
| 964 accept(StatementVisitor visitor) { | 965 accept(StatementVisitor visitor) { |
| 965 return visitor.visitNullCheck(this); | 966 return visitor.visitReceiverCheck(this); |
| 966 } | 967 } |
| 967 | 968 |
| 968 accept1(StatementVisitor1 visitor, arg) { | 969 accept1(StatementVisitor1 visitor, arg) { |
| 969 return visitor.visitNullCheck(this, arg); | 970 return visitor.visitReceiverCheck(this, arg); |
| 970 } | 971 } |
| 971 } | 972 } |
| 972 | 973 |
| 973 abstract class ExpressionVisitor<E> { | 974 abstract class ExpressionVisitor<E> { |
| 974 E visitExpression(Expression node) => node.accept(this); | 975 E visitExpression(Expression node) => node.accept(this); |
| 975 E visitVariableUse(VariableUse node); | 976 E visitVariableUse(VariableUse node); |
| 976 E visitAssign(Assign node); | 977 E visitAssign(Assign node); |
| 977 E visitInvokeStatic(InvokeStatic node); | 978 E visitInvokeStatic(InvokeStatic node); |
| 978 E visitInvokeMethod(InvokeMethod node); | 979 E visitInvokeMethod(InvokeMethod node); |
| 979 E visitInvokeMethodDirectly(InvokeMethodDirectly node); | 980 E visitInvokeMethodDirectly(InvokeMethodDirectly node); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 S visitBreak(Break node); | 1053 S visitBreak(Break node); |
| 1053 S visitContinue(Continue node); | 1054 S visitContinue(Continue node); |
| 1054 S visitIf(If node); | 1055 S visitIf(If node); |
| 1055 S visitWhileTrue(WhileTrue node); | 1056 S visitWhileTrue(WhileTrue node); |
| 1056 S visitFor(For node); | 1057 S visitFor(For node); |
| 1057 S visitExpressionStatement(ExpressionStatement node); | 1058 S visitExpressionStatement(ExpressionStatement node); |
| 1058 S visitTry(Try node); | 1059 S visitTry(Try node); |
| 1059 S visitUnreachable(Unreachable node); | 1060 S visitUnreachable(Unreachable node); |
| 1060 S visitForeignStatement(ForeignStatement node); | 1061 S visitForeignStatement(ForeignStatement node); |
| 1061 S visitYield(Yield node); | 1062 S visitYield(Yield node); |
| 1062 S visitNullCheck(NullCheck node); | 1063 S visitReceiverCheck(ReceiverCheck node); |
| 1063 } | 1064 } |
| 1064 | 1065 |
| 1065 abstract class StatementVisitor1<S, A> { | 1066 abstract class StatementVisitor1<S, A> { |
| 1066 S visitStatement(Statement node, A arg) => node.accept1(this, arg); | 1067 S visitStatement(Statement node, A arg) => node.accept1(this, arg); |
| 1067 S visitLabeledStatement(LabeledStatement node, A arg); | 1068 S visitLabeledStatement(LabeledStatement node, A arg); |
| 1068 S visitReturn(Return node, A arg); | 1069 S visitReturn(Return node, A arg); |
| 1069 S visitThrow(Throw node, A arg); | 1070 S visitThrow(Throw node, A arg); |
| 1070 S visitBreak(Break node, A arg); | 1071 S visitBreak(Break node, A arg); |
| 1071 S visitContinue(Continue node, A arg); | 1072 S visitContinue(Continue node, A arg); |
| 1072 S visitIf(If node, A arg); | 1073 S visitIf(If node, A arg); |
| 1073 S visitWhileTrue(WhileTrue node, A arg); | 1074 S visitWhileTrue(WhileTrue node, A arg); |
| 1074 S visitFor(For node, A arg); | 1075 S visitFor(For node, A arg); |
| 1075 S visitExpressionStatement(ExpressionStatement node, A arg); | 1076 S visitExpressionStatement(ExpressionStatement node, A arg); |
| 1076 S visitTry(Try node, A arg); | 1077 S visitTry(Try node, A arg); |
| 1077 S visitUnreachable(Unreachable node, A arg); | 1078 S visitUnreachable(Unreachable node, A arg); |
| 1078 S visitForeignStatement(ForeignStatement node, A arg); | 1079 S visitForeignStatement(ForeignStatement node, A arg); |
| 1079 S visitYield(Yield node, A arg); | 1080 S visitYield(Yield node, A arg); |
| 1080 S visitNullCheck(NullCheck node, A arg); | 1081 S visitReceiverCheck(ReceiverCheck node, A arg); |
| 1081 } | 1082 } |
| 1082 | 1083 |
| 1083 abstract class RecursiveVisitor implements StatementVisitor, ExpressionVisitor { | 1084 abstract class RecursiveVisitor implements StatementVisitor, ExpressionVisitor { |
| 1084 visitExpression(Expression e) => e.accept(this); | 1085 visitExpression(Expression e) => e.accept(this); |
| 1085 visitStatement(Statement s) => s.accept(this); | 1086 visitStatement(Statement s) => s.accept(this); |
| 1086 | 1087 |
| 1087 visitVariable(Variable variable) {} | 1088 visitVariable(Variable variable) {} |
| 1088 | 1089 |
| 1089 visitVariableUse(VariableUse node) { | 1090 visitVariableUse(VariableUse node) { |
| 1090 visitVariable(node.variable); | 1091 visitVariable(node.variable); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1279 | 1280 |
| 1280 visitAwait(Await node) { | 1281 visitAwait(Await node) { |
| 1281 visitExpression(node.input); | 1282 visitExpression(node.input); |
| 1282 } | 1283 } |
| 1283 | 1284 |
| 1284 visitYield(Yield node) { | 1285 visitYield(Yield node) { |
| 1285 visitExpression(node.input); | 1286 visitExpression(node.input); |
| 1286 visitStatement(node.next); | 1287 visitStatement(node.next); |
| 1287 } | 1288 } |
| 1288 | 1289 |
| 1289 visitNullCheck(NullCheck node) { | 1290 visitReceiverCheck(ReceiverCheck node) { |
| 1290 if (node.condition != null) visitExpression(node.condition); | 1291 if (node.condition != null) visitExpression(node.condition); |
| 1291 visitExpression(node.value); | 1292 visitExpression(node.value); |
| 1292 visitStatement(node.next); | 1293 visitStatement(node.next); |
| 1293 } | 1294 } |
| 1294 } | 1295 } |
| 1295 | 1296 |
| 1296 abstract class Transformer implements ExpressionVisitor<Expression>, | 1297 abstract class Transformer implements ExpressionVisitor<Expression>, |
| 1297 StatementVisitor<Statement> { | 1298 StatementVisitor<Statement> { |
| 1298 Expression visitExpression(Expression e) => e.accept(this); | 1299 Expression visitExpression(Expression e) => e.accept(this); |
| 1299 Statement visitStatement(Statement s) => s.accept(this); | 1300 Statement visitStatement(Statement s) => s.accept(this); |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1539 node.input = visitExpression(node.input); | 1540 node.input = visitExpression(node.input); |
| 1540 return node; | 1541 return node; |
| 1541 } | 1542 } |
| 1542 | 1543 |
| 1543 visitYield(Yield node) { | 1544 visitYield(Yield node) { |
| 1544 node.input = visitExpression(node.input); | 1545 node.input = visitExpression(node.input); |
| 1545 node.next = visitStatement(node.next); | 1546 node.next = visitStatement(node.next); |
| 1546 return node; | 1547 return node; |
| 1547 } | 1548 } |
| 1548 | 1549 |
| 1549 visitNullCheck(NullCheck node) { | 1550 visitReceiverCheck(ReceiverCheck node) { |
| 1550 if (node.condition != null) { | 1551 if (node.condition != null) { |
| 1551 node.condition = visitExpression(node.condition); | 1552 node.condition = visitExpression(node.condition); |
| 1552 } | 1553 } |
| 1553 node.value = visitExpression(node.value); | 1554 node.value = visitExpression(node.value); |
| 1554 node.next = visitStatement(node.next); | 1555 node.next = visitStatement(node.next); |
| 1555 return node; | 1556 return node; |
| 1556 } | 1557 } |
| 1557 } | 1558 } |
| 1558 | 1559 |
| 1559 class FallthroughTarget { | 1560 class FallthroughTarget { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1584 | 1585 |
| 1585 /// Number of uses of the current fallthrough target. | 1586 /// Number of uses of the current fallthrough target. |
| 1586 int get useCount => _stack.last.useCount; | 1587 int get useCount => _stack.last.useCount; |
| 1587 | 1588 |
| 1588 /// Indicate that a statement will fall through to the current fallthrough | 1589 /// Indicate that a statement will fall through to the current fallthrough |
| 1589 /// target. | 1590 /// target. |
| 1590 void use() { | 1591 void use() { |
| 1591 ++_stack.last.useCount; | 1592 ++_stack.last.useCount; |
| 1592 } | 1593 } |
| 1593 } | 1594 } |
| OLD | NEW |