| 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_builder; | 5 library tree_ir_builder; |
| 6 | 6 |
| 7 import '../dart2jslib.dart' as dart2js; | 7 import '../dart2jslib.dart' as dart2js; |
| 8 import '../dart_types.dart'; | 8 import '../dart_types.dart'; |
| 9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
| 10 import '../cps_ir/cps_ir_nodes.dart' as cps_ir; | 10 import '../cps_ir/cps_ir_nodes.dart' as cps_ir; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 Variable variable = new Variable(currentElement, irVariable.hint); | 80 Variable variable = new Variable(currentElement, irVariable.hint); |
| 81 local2mutable[irVariable] = variable; | 81 local2mutable[irVariable] = variable; |
| 82 return variable; | 82 return variable; |
| 83 } | 83 } |
| 84 | 84 |
| 85 Variable getMutableVariableReference( | 85 Variable getMutableVariableReference( |
| 86 cps_ir.Reference<cps_ir.MutableVariable> reference) { | 86 cps_ir.Reference<cps_ir.MutableVariable> reference) { |
| 87 if (reference.definition.host != currentElement) { | 87 if (reference.definition.host != currentElement) { |
| 88 return parent.getMutableVariableReference(reference); | 88 return parent.getMutableVariableReference(reference); |
| 89 } | 89 } |
| 90 return local2mutable[reference.definition]; | 90 Variable variable = local2mutable[reference.definition]; |
| 91 ++variable.readCount; |
| 92 return variable; |
| 91 } | 93 } |
| 92 | 94 |
| 93 /// Obtains the variable representing the given primitive. Returns null for | 95 /// Obtains the variable representing the given primitive. Returns null for |
| 94 /// primitives that have no reference and do not need a variable. | 96 /// primitives that have no reference and do not need a variable. |
| 95 Variable getVariable(cps_ir.Primitive primitive) { | 97 Variable getVariable(cps_ir.Primitive primitive) { |
| 96 if (primitive.registerIndex == null) { | 98 if (primitive.registerIndex == null) { |
| 97 return null; // variable is unused | 99 return null; // variable is unused |
| 98 } | 100 } |
| 99 List<Variable> variables = local2variables.putIfAbsent(primitive.hint, | 101 List<Variable> variables = local2variables.putIfAbsent(primitive.hint, |
| 100 () => <Variable>[]); | 102 () => <Variable>[]); |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 // visited. | 589 // visited. |
| 588 internalError(CURRENT_ELEMENT_SPANNABLE, 'Unexpected IR node: $node.'); | 590 internalError(CURRENT_ELEMENT_SPANNABLE, 'Unexpected IR node: $node.'); |
| 589 return null; | 591 return null; |
| 590 } | 592 } |
| 591 | 593 |
| 592 Expression visitIsTrue(cps_ir.IsTrue node) { | 594 Expression visitIsTrue(cps_ir.IsTrue node) { |
| 593 return getVariableReference(node.value); | 595 return getVariableReference(node.value); |
| 594 } | 596 } |
| 595 } | 597 } |
| 596 | 598 |
| OLD | NEW |