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 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1334 visitApplyBuiltinOperator(ApplyBuiltinOperator node) { | 1334 visitApplyBuiltinOperator(ApplyBuiltinOperator node) { |
1335 _replaceExpressions(node.arguments); | 1335 _replaceExpressions(node.arguments); |
1336 return node; | 1336 return node; |
1337 } | 1337 } |
1338 | 1338 |
1339 visitInterceptor(Interceptor node) { | 1339 visitInterceptor(Interceptor node) { |
1340 node.input = visitExpression(node.input); | 1340 node.input = visitExpression(node.input); |
1341 return node; | 1341 return node; |
1342 } | 1342 } |
1343 } | 1343 } |
| 1344 |
| 1345 class FallthroughTarget { |
| 1346 final Statement target; |
| 1347 int useCount = 0; |
| 1348 |
| 1349 FallthroughTarget(this.target); |
| 1350 } |
| 1351 |
| 1352 /// A stack machine for tracking fallthrough while traversing the Tree IR. |
| 1353 class FallthroughStack { |
| 1354 final List<FallthroughTarget> _stack = |
| 1355 <FallthroughTarget>[new FallthroughTarget(null)]; |
| 1356 |
| 1357 /// Set a new fallthrough target. |
| 1358 void push(Statement newFallthrough) { |
| 1359 _stack.add(new FallthroughTarget(newFallthrough)); |
| 1360 } |
| 1361 |
| 1362 /// Remove the current fallthrough target. |
| 1363 void pop() { |
| 1364 _stack.removeLast(); |
| 1365 } |
| 1366 |
| 1367 /// The current fallthrough target, or `null` if control will fall over |
| 1368 /// the end of the method. |
| 1369 Statement get target => _stack.last.target; |
| 1370 |
| 1371 /// Number of uses of the current fallthrough target. |
| 1372 int get useCount => _stack.last.useCount; |
| 1373 |
| 1374 /// Indicate that a statement will fall through to the current fallthrough |
| 1375 /// target. |
| 1376 void use() { |
| 1377 ++_stack.last.useCount; |
| 1378 } |
| 1379 } |
OLD | NEW |