| 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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 if (usesInfixNotation(node.object)) { | 440 if (usesInfixNotation(node.object)) { |
| 441 object = '($object)'; | 441 object = '($object)'; |
| 442 } | 442 } |
| 443 return '$object.$field'; | 443 return '$object.$field'; |
| 444 } | 444 } |
| 445 | 445 |
| 446 String visitCreateBox(CreateBox node) { | 446 String visitCreateBox(CreateBox node) { |
| 447 return 'CreateBox'; | 447 return 'CreateBox'; |
| 448 } | 448 } |
| 449 | 449 |
| 450 String visitCreateClosureClass(CreateClosureClass node) { | 450 String visitCreateInstance(CreateInstance node) { |
| 451 String className = node.classElement.name; | 451 String className = node.classElement.name; |
| 452 String arguments = node.arguments.map(visitExpression).join(', '); | 452 String arguments = node.arguments.map(visitExpression).join(', '); |
| 453 return 'CreateClosure $className($arguments)'; | 453 return 'CreateInstance $className($arguments)'; |
| 454 } | 454 } |
| 455 | 455 |
| 456 } | 456 } |
| 457 | 457 |
| 458 /** | 458 /** |
| 459 * Invents (and remembers) names for Variables that do not have an associated | 459 * Invents (and remembers) names for Variables that do not have an associated |
| 460 * identifier. | 460 * identifier. |
| 461 * | 461 * |
| 462 * In case a variable is named v0, v1, etc, it may be assigned a different | 462 * In case a variable is named v0, v1, etc, it may be assigned a different |
| 463 * name to avoid clashing with a previously synthesized variable name. | 463 * name to avoid clashing with a previously synthesized variable name. |
| 464 */ | 464 */ |
| 465 class Names { | 465 class Names { |
| 466 final Map<Variable, String> _names = {}; | 466 final Map<Variable, String> _names = {}; |
| 467 final Set<String> _usedNames = new Set(); | 467 final Set<String> _usedNames = new Set(); |
| 468 int _counter = 0; | 468 int _counter = 0; |
| 469 | 469 |
| 470 String varName(Variable v) { | 470 String varName(Variable v) { |
| 471 String name = _names[v]; | 471 String name = _names[v]; |
| 472 if (name == null) { | 472 if (name == null) { |
| 473 String prefix = v.element == null ? 'v' : '${v.element.name}_'; | 473 String prefix = v.element == null ? 'v' : '${v.element.name}_'; |
| 474 while (name == null || _usedNames.contains(name)) { | 474 while (name == null || _usedNames.contains(name)) { |
| 475 name = "$prefix${_counter++}"; | 475 name = "$prefix${_counter++}"; |
| 476 } | 476 } |
| 477 _names[v] = name; | 477 _names[v] = name; |
| 478 _usedNames.add(name); | 478 _usedNames.add(name); |
| 479 } | 479 } |
| 480 return name; | 480 return name; |
| 481 } | 481 } |
| 482 } | 482 } |
| OLD | NEW |