| 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 import 'optimization/optimization.dart'; | 10 import 'optimization/optimization.dart'; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 _addBlock(bodyBlock); | 134 _addBlock(bodyBlock); |
| 135 visitStatement(node.body); | 135 visitStatement(node.body); |
| 136 | 136 |
| 137 _addBlock(nextBlock); | 137 _addBlock(nextBlock); |
| 138 visitStatement(node.next); | 138 visitStatement(node.next); |
| 139 | 139 |
| 140 ifTargets[node.body] = bodyBlock; | 140 ifTargets[node.body] = bodyBlock; |
| 141 ifTargets[node.next] = nextBlock; | 141 ifTargets[node.next] = nextBlock; |
| 142 } | 142 } |
| 143 | 143 |
| 144 visitTry(Try node) { |
| 145 // It's not obvious how we want to represent try statements here. |
| 146 // TODO(kmillikin). |
| 147 } |
| 148 |
| 144 visitExpressionStatement(ExpressionStatement node) { | 149 visitExpressionStatement(ExpressionStatement node) { |
| 145 _addStatement(node); | 150 _addStatement(node); |
| 146 visitStatement(node.next); | 151 visitStatement(node.next); |
| 147 } | 152 } |
| 148 | 153 |
| 149 visitFunctionDeclaration(FunctionDeclaration node) { | 154 visitFunctionDeclaration(FunctionDeclaration node) { |
| 150 _addStatement(node); | 155 _addStatement(node); |
| 151 visitStatement(node.next); | 156 visitStatement(node.next); |
| 152 } | 157 } |
| 153 | 158 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 } | 273 } |
| 269 | 274 |
| 270 visitWhileCondition(WhileCondition node) { | 275 visitWhileCondition(WhileCondition node) { |
| 271 String bodyTarget = collector.ifTargets[node.body].name; | 276 String bodyTarget = collector.ifTargets[node.body].name; |
| 272 String nextTarget = collector.ifTargets[node.next].name; | 277 String nextTarget = collector.ifTargets[node.next].name; |
| 273 printStatement(null, "while ${expr(node.condition)}"); | 278 printStatement(null, "while ${expr(node.condition)}"); |
| 274 printStatement(null, "do $bodyTarget"); | 279 printStatement(null, "do $bodyTarget"); |
| 275 printStatement(null, "then $nextTarget" ); | 280 printStatement(null, "then $nextTarget" ); |
| 276 } | 281 } |
| 277 | 282 |
| 283 visitTry(Try node) { |
| 284 // It's not obvious how we want to represent try statements here. |
| 285 // TODO(kmillikin). |
| 286 } |
| 287 |
| 278 visitExpressionStatement(ExpressionStatement node) { | 288 visitExpressionStatement(ExpressionStatement node) { |
| 279 printStatement(null, expr(node.expression)); | 289 printStatement(null, expr(node.expression)); |
| 280 } | 290 } |
| 281 | 291 |
| 282 visitFunctionDeclaration(FunctionDeclaration node) { | 292 visitFunctionDeclaration(FunctionDeclaration node) { |
| 283 printStatement(null, 'function ${node.definition.element.name}'); | 293 printStatement(null, 'function ${node.definition.element.name}'); |
| 284 } | 294 } |
| 285 | 295 |
| 286 visitSetField(SetField node) { | 296 visitSetField(SetField node) { |
| 287 String object = expr(node.object); | 297 String object = expr(node.object); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 String prefix = v.element == null ? 'v' : '${v.element.name}_'; | 484 String prefix = v.element == null ? 'v' : '${v.element.name}_'; |
| 475 while (name == null || _usedNames.contains(name)) { | 485 while (name == null || _usedNames.contains(name)) { |
| 476 name = "$prefix${_counter++}"; | 486 name = "$prefix${_counter++}"; |
| 477 } | 487 } |
| 478 _names[v] = name; | 488 _names[v] = name; |
| 479 _usedNames.add(name); | 489 _usedNames.add(name); |
| 480 } | 490 } |
| 481 return name; | 491 return name; |
| 482 } | 492 } |
| 483 } | 493 } |
| OLD | NEW |