| 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 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 visitWhileTrue(WhileTrue node) { | 1101 visitWhileTrue(WhileTrue node) { |
| 1102 visitStatement(node.body); | 1102 visitStatement(node.body); |
| 1103 } | 1103 } |
| 1104 | 1104 |
| 1105 visitWhileCondition(WhileCondition node) { | 1105 visitWhileCondition(WhileCondition node) { |
| 1106 visitExpression(node.condition); | 1106 visitExpression(node.condition); |
| 1107 visitStatement(node.body); | 1107 visitStatement(node.body); |
| 1108 visitStatement(node.next); | 1108 visitStatement(node.next); |
| 1109 } | 1109 } |
| 1110 | 1110 |
| 1111 visitExpressionStatement(ExpressionStatement node) { | 1111 visitExpressionStatement(ExpressionStatement inputNode) { |
| 1112 visitExpression(node.expression); | 1112 // Iterate over chains of expression statements to avoid deep recursion. |
| 1113 visitStatement(node.next); | 1113 Statement node = inputNode; |
| 1114 while (node is ExpressionStatement) { |
| 1115 ExpressionStatement stmt = node; |
| 1116 visitExpression(stmt.expression); |
| 1117 node = stmt.next; |
| 1118 } |
| 1119 visitStatement(node); |
| 1114 } | 1120 } |
| 1115 | 1121 |
| 1116 visitTry(Try node) { | 1122 visitTry(Try node) { |
| 1117 visitStatement(node.tryBody); | 1123 visitStatement(node.tryBody); |
| 1118 visitStatement(node.catchBody); | 1124 visitStatement(node.catchBody); |
| 1119 } | 1125 } |
| 1120 | 1126 |
| 1121 visitGetField(GetField node) { | 1127 visitGetField(GetField node) { |
| 1122 visitExpression(node.object); | 1128 visitExpression(node.object); |
| 1123 } | 1129 } |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 } | 1325 } |
| 1320 | 1326 |
| 1321 visitWhileCondition(WhileCondition node) { | 1327 visitWhileCondition(WhileCondition node) { |
| 1322 node.condition = visitExpression(node.condition); | 1328 node.condition = visitExpression(node.condition); |
| 1323 node.body = visitStatement(node.body); | 1329 node.body = visitStatement(node.body); |
| 1324 node.next = visitStatement(node.next); | 1330 node.next = visitStatement(node.next); |
| 1325 return node; | 1331 return node; |
| 1326 } | 1332 } |
| 1327 | 1333 |
| 1328 visitExpressionStatement(ExpressionStatement node) { | 1334 visitExpressionStatement(ExpressionStatement node) { |
| 1329 node.expression = visitExpression(node.expression); | 1335 // Iterate over chains of expression statements to avoid deep recursion. |
| 1336 Statement first = node; |
| 1337 while (true) { |
| 1338 node.expression = visitExpression(node.expression); |
| 1339 if (node.next is ExpressionStatement) { |
| 1340 node = node.next; |
| 1341 } else { |
| 1342 break; |
| 1343 } |
| 1344 } |
| 1330 node.next = visitStatement(node.next); | 1345 node.next = visitStatement(node.next); |
| 1331 return node; | 1346 return first; |
| 1332 } | 1347 } |
| 1333 | 1348 |
| 1334 visitTry(Try node) { | 1349 visitTry(Try node) { |
| 1335 node.tryBody = visitStatement(node.tryBody); | 1350 node.tryBody = visitStatement(node.tryBody); |
| 1336 node.catchBody = visitStatement(node.catchBody); | 1351 node.catchBody = visitStatement(node.catchBody); |
| 1337 return node; | 1352 return node; |
| 1338 } | 1353 } |
| 1339 | 1354 |
| 1340 visitGetField(GetField node) { | 1355 visitGetField(GetField node) { |
| 1341 node.object = visitExpression(node.object); | 1356 node.object = visitExpression(node.object); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1453 | 1468 |
| 1454 /// Number of uses of the current fallthrough target. | 1469 /// Number of uses of the current fallthrough target. |
| 1455 int get useCount => _stack.last.useCount; | 1470 int get useCount => _stack.last.useCount; |
| 1456 | 1471 |
| 1457 /// Indicate that a statement will fall through to the current fallthrough | 1472 /// Indicate that a statement will fall through to the current fallthrough |
| 1458 /// target. | 1473 /// target. |
| 1459 void use() { | 1474 void use() { |
| 1460 ++_stack.last.useCount; | 1475 ++_stack.last.useCount; |
| 1461 } | 1476 } |
| 1462 } | 1477 } |
| OLD | NEW |