| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 return variables[primitive.registerIndex]; | 118 return variables[primitive.registerIndex]; |
| 119 } | 119 } |
| 120 | 120 |
| 121 /// Obtains a reference to the tree Variable corresponding to the IR primitive | 121 /// Obtains a reference to the tree Variable corresponding to the IR primitive |
| 122 /// referred to by [reference]. | 122 /// referred to by [reference]. |
| 123 /// This increments the reference count for the given variable, so the | 123 /// This increments the reference count for the given variable, so the |
| 124 /// returned expression must be used in the tree. | 124 /// returned expression must be used in the tree. |
| 125 VariableUse getVariableUse(cps_ir.Reference<cps_ir.Primitive> reference) { | 125 VariableUse getVariableUse(cps_ir.Reference<cps_ir.Primitive> reference) { |
| 126 Variable variable = getVariable(reference.definition); | 126 Variable variable = getVariable(reference.definition); |
| 127 if (variable == null) { | 127 if (variable == null) { |
| 128 // Note: this may fail because you forgot to implement a visit-function |
| 129 // in the RegisterAllocator. |
| 128 internalError( | 130 internalError( |
| 129 CURRENT_ELEMENT_SPANNABLE, | 131 CURRENT_ELEMENT_SPANNABLE, |
| 130 "Reference to ${reference.definition} has no register"); | 132 "Reference to ${reference.definition} has no register"); |
| 131 } | 133 } |
| 132 return new VariableUse(variable); | 134 return new VariableUse(variable); |
| 133 } | 135 } |
| 134 | 136 |
| 135 ExecutableDefinition build(cps_ir.ExecutableDefinition node) { | 137 ExecutableDefinition build(cps_ir.ExecutableDefinition node) { |
| 136 if (node is cps_ir.FieldDefinition) { | 138 if (node is cps_ir.FieldDefinition) { |
| 137 return buildField(node); | 139 return buildField(node); |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 | 629 |
| 628 visitMutableVariable(cps_ir.MutableVariable node) { | 630 visitMutableVariable(cps_ir.MutableVariable node) { |
| 629 // These occur as parameters or bound by LetMutable. They are not visited | 631 // These occur as parameters or bound by LetMutable. They are not visited |
| 630 // directly. | 632 // directly. |
| 631 unexpectedNode(node); | 633 unexpectedNode(node); |
| 632 } | 634 } |
| 633 | 635 |
| 634 Expression visitIsTrue(cps_ir.IsTrue node) { | 636 Expression visitIsTrue(cps_ir.IsTrue node) { |
| 635 return getVariableUse(node.value); | 637 return getVariableUse(node.value); |
| 636 } | 638 } |
| 639 |
| 640 Expression visitReifyRuntimeType(cps_ir.ReifyRuntimeType node) { |
| 641 return new ReifyRuntimeType(getVariableUse(node.value)); |
| 642 } |
| 643 |
| 644 Expression visitReadTypeVariable(cps_ir.ReadTypeVariable node) { |
| 645 return new ReadTypeVariable(node.variable, getVariableUse(node.target)); |
| 646 } |
| 637 } | 647 } |
| 638 | |
| OLD | NEW |