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_tracer; | 5 library tree_ir_tracer; |
6 | 6 |
7 import 'dart:async' show EventSink; | 7 import 'dart:async' show EventSink; |
8 import '../tracer.dart'; | 8 import '../tracer.dart'; |
9 import 'tree_ir_nodes.dart'; | 9 import 'tree_ir_nodes.dart'; |
10 | 10 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 Block continueTarget = new Block(); | 120 Block continueTarget = new Block(); |
121 _addGotoStatement(continueTarget); | 121 _addGotoStatement(continueTarget); |
122 | 122 |
123 continueTargets[node.label] = continueTarget; | 123 continueTargets[node.label] = continueTarget; |
124 blocks.last.addEdgeTo(continueTarget); | 124 blocks.last.addEdgeTo(continueTarget); |
125 _addBlock(continueTarget); | 125 _addBlock(continueTarget); |
126 _addStatement(node); | 126 _addStatement(node); |
127 visitStatement(node.body); | 127 visitStatement(node.body); |
128 } | 128 } |
129 | 129 |
130 visitWhileCondition(WhileCondition node) { | 130 visitFor(For node) { |
131 Block whileBlock = new Block(); | 131 Block whileBlock = new Block(); |
132 _addGotoStatement(whileBlock); | 132 _addGotoStatement(whileBlock); |
133 | 133 |
134 _addBlock(whileBlock); | 134 _addBlock(whileBlock); |
135 _addStatement(node); | 135 _addStatement(node); |
136 whileBlock.statements.add(node); | 136 whileBlock.statements.add(node); |
137 blocks.last.addEdgeTo(whileBlock); | 137 blocks.last.addEdgeTo(whileBlock); |
138 | 138 |
139 Block bodyBlock = new Block(); | 139 Block bodyBlock = new Block(); |
140 Block nextBlock = new Block(); | 140 Block nextBlock = new Block(); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 String condition = expr(node.condition); | 290 String condition = expr(node.condition); |
291 String thenTarget = collector.substatements[node.thenStatement].name; | 291 String thenTarget = collector.substatements[node.thenStatement].name; |
292 String elseTarget = collector.substatements[node.elseStatement].name; | 292 String elseTarget = collector.substatements[node.elseStatement].name; |
293 printStatement(null, "if $condition then $thenTarget else $elseTarget"); | 293 printStatement(null, "if $condition then $thenTarget else $elseTarget"); |
294 } | 294 } |
295 | 295 |
296 visitWhileTrue(WhileTrue node) { | 296 visitWhileTrue(WhileTrue node) { |
297 printStatement(null, "while true do"); | 297 printStatement(null, "while true do"); |
298 } | 298 } |
299 | 299 |
300 visitWhileCondition(WhileCondition node) { | 300 visitFor(For node) { |
301 String bodyTarget = collector.substatements[node.body].name; | 301 String bodyTarget = collector.substatements[node.body].name; |
302 String nextTarget = collector.substatements[node.next].name; | 302 String nextTarget = collector.substatements[node.next].name; |
| 303 String updates = node.updates.map(expr).join(', '); |
303 printStatement(null, "while ${expr(node.condition)}"); | 304 printStatement(null, "while ${expr(node.condition)}"); |
304 printStatement(null, "do $bodyTarget"); | 305 printStatement(null, "do $bodyTarget"); |
| 306 printStatement(null, "updates ($updates)"); |
305 printStatement(null, "then $nextTarget" ); | 307 printStatement(null, "then $nextTarget" ); |
306 } | 308 } |
307 | 309 |
308 visitTry(Try node) { | 310 visitTry(Try node) { |
309 String tryTarget = collector.substatements[node.tryBody].name; | 311 String tryTarget = collector.substatements[node.tryBody].name; |
310 String catchParams = node.catchParameters.map(names.varName).join(','); | 312 String catchParams = node.catchParameters.map(names.varName).join(','); |
311 String catchTarget = collector.substatements[node.catchBody].name; | 313 String catchTarget = collector.substatements[node.catchBody].name; |
312 printStatement(null, 'try $tryTarget catch($catchParams) $catchTarget'); | 314 printStatement(null, 'try $tryTarget catch($catchParams) $catchTarget'); |
313 } | 315 } |
314 | 316 |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 String prefix = v.element == null ? 'v' : '${v.element.name}_'; | 589 String prefix = v.element == null ? 'v' : '${v.element.name}_'; |
588 while (name == null || _usedNames.contains(name)) { | 590 while (name == null || _usedNames.contains(name)) { |
589 name = "$prefix${_counter++}"; | 591 name = "$prefix${_counter++}"; |
590 } | 592 } |
591 _names[v] = name; | 593 _names[v] = name; |
592 _usedNames.add(name); | 594 _usedNames.add(name); |
593 } | 595 } |
594 return name; | 596 return name; |
595 } | 597 } |
596 } | 598 } |
OLD | NEW |