| 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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 @override | 502 @override |
| 503 String visitTypeExpression(TypeExpression node) { | 503 String visitTypeExpression(TypeExpression node) { |
| 504 return node.dartType.toString(); | 504 return node.dartType.toString(); |
| 505 } | 505 } |
| 506 | 506 |
| 507 @override | 507 @override |
| 508 String visitCreateInvocationMirror(CreateInvocationMirror node) { | 508 String visitCreateInvocationMirror(CreateInvocationMirror node) { |
| 509 String args = node.arguments.map(visitExpression).join(', '); | 509 String args = node.arguments.map(visitExpression).join(', '); |
| 510 return 'CreateInvocationMirror(${node.selector.name}, $args)'; | 510 return 'CreateInvocationMirror(${node.selector.name}, $args)'; |
| 511 } | 511 } |
| 512 |
| 513 @override |
| 514 String visitApplyBuiltinOperator(ApplyBuiltinOperator node) { |
| 515 String args = node.arguments.map(visitExpression).join(', '); |
| 516 return 'ApplyBuiltinOperator ${node.operator} ($args)'; |
| 517 } |
| 512 } | 518 } |
| 513 | 519 |
| 514 /** | 520 /** |
| 515 * Invents (and remembers) names for Variables that do not have an associated | 521 * Invents (and remembers) names for Variables that do not have an associated |
| 516 * identifier. | 522 * identifier. |
| 517 * | 523 * |
| 518 * In case a variable is named v0, v1, etc, it may be assigned a different | 524 * In case a variable is named v0, v1, etc, it may be assigned a different |
| 519 * name to avoid clashing with a previously synthesized variable name. | 525 * name to avoid clashing with a previously synthesized variable name. |
| 520 */ | 526 */ |
| 521 class Names { | 527 class Names { |
| 522 final Map<Variable, String> _names = {}; | 528 final Map<Variable, String> _names = {}; |
| 523 final Set<String> _usedNames = new Set(); | 529 final Set<String> _usedNames = new Set(); |
| 524 int _counter = 0; | 530 int _counter = 0; |
| 525 | 531 |
| 526 String varName(Variable v) { | 532 String varName(Variable v) { |
| 527 String name = _names[v]; | 533 String name = _names[v]; |
| 528 if (name == null) { | 534 if (name == null) { |
| 529 String prefix = v.element == null ? 'v' : '${v.element.name}_'; | 535 String prefix = v.element == null ? 'v' : '${v.element.name}_'; |
| 530 while (name == null || _usedNames.contains(name)) { | 536 while (name == null || _usedNames.contains(name)) { |
| 531 name = "$prefix${_counter++}"; | 537 name = "$prefix${_counter++}"; |
| 532 } | 538 } |
| 533 _names[v] = name; | 539 _names[v] = name; |
| 534 _usedNames.add(name); | 540 _usedNames.add(name); |
| 535 } | 541 } |
| 536 return name; | 542 return name; |
| 537 } | 543 } |
| 538 } | 544 } |
| OLD | NEW |