| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 CURRENT_ELEMENT_SPANNABLE, | 106 CURRENT_ELEMENT_SPANNABLE, |
| 107 "Reference to ${reference.definition} has no register"); | 107 "Reference to ${reference.definition} has no register"); |
| 108 } | 108 } |
| 109 ++variable.readCount; | 109 ++variable.readCount; |
| 110 return variable; | 110 return variable; |
| 111 } | 111 } |
| 112 | 112 |
| 113 ExecutableDefinition build(cps_ir.ExecutableDefinition node) { | 113 ExecutableDefinition build(cps_ir.ExecutableDefinition node) { |
| 114 if (node is cps_ir.FieldDefinition) { | 114 if (node is cps_ir.FieldDefinition) { |
| 115 return buildField(node); | 115 return buildField(node); |
| 116 } else if (node is cps_ir.ConstructorDefinition) { |
| 117 return buildConstructor(node); |
| 116 } else { | 118 } else { |
| 117 assert(dart2js.invariant( | 119 assert(dart2js.invariant( |
| 118 CURRENT_ELEMENT_SPANNABLE, | 120 CURRENT_ELEMENT_SPANNABLE, |
| 119 node is cps_ir.FunctionDefinition, | 121 node is cps_ir.FunctionDefinition, |
| 120 message: 'expected FunctionDefinition or FieldDefinition, ' | 122 message: 'expected FunctionDefinition or FieldDefinition, ' |
| 121 ' found $node')); | 123 ' found $node')); |
| 122 return buildFunction(node); | 124 return buildFunction(node); |
| 123 } | 125 } |
| 124 return null; | |
| 125 } | 126 } |
| 126 | 127 |
| 127 FieldDefinition buildField(cps_ir.FieldDefinition node) { | 128 FieldDefinition buildField(cps_ir.FieldDefinition node) { |
| 128 Statement body; | 129 Statement body; |
| 129 if (node.hasInitializer) { | 130 if (node.hasInitializer) { |
| 130 currentElement = node.element; | 131 currentElement = node.element; |
| 131 returnContinuation = node.body.returnContinuation; | 132 returnContinuation = node.body.returnContinuation; |
| 132 | 133 |
| 133 phiTempVar = new Variable(node.element, null); | 134 phiTempVar = new Variable(node.element, null); |
| 134 | 135 |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 // visited. | 545 // visited. |
| 545 internalError(CURRENT_ELEMENT_SPANNABLE, 'Unexpected IR node: $node.'); | 546 internalError(CURRENT_ELEMENT_SPANNABLE, 'Unexpected IR node: $node.'); |
| 546 return null; | 547 return null; |
| 547 } | 548 } |
| 548 | 549 |
| 549 Expression visitIsTrue(cps_ir.IsTrue node) { | 550 Expression visitIsTrue(cps_ir.IsTrue node) { |
| 550 return getVariableReference(node.value); | 551 return getVariableReference(node.value); |
| 551 } | 552 } |
| 552 } | 553 } |
| 553 | 554 |
| OLD | NEW |