| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 Builder createInnerBuilder() { | 76 Builder createInnerBuilder() { |
| 77 return new Builder(internalError, this); | 77 return new Builder(internalError, this); |
| 78 } | 78 } |
| 79 | 79 |
| 80 /// Variable used in [buildPhiAssignments] as a temporary when swapping | 80 /// Variable used in [buildPhiAssignments] as a temporary when swapping |
| 81 /// variables. | 81 /// variables. |
| 82 Variable phiTempVar; | 82 Variable phiTempVar; |
| 83 | 83 |
| 84 Variable addMutableVariable(cps_ir.MutableVariable irVariable) { | 84 Variable addMutableVariable(cps_ir.MutableVariable irVariable) { |
| 85 if (irVariable.host != currentElement) { | 85 assert(irVariable.host == currentElement); |
| 86 return parent.addMutableVariable(irVariable); | |
| 87 } | |
| 88 assert(!local2mutable.containsKey(irVariable)); | 86 assert(!local2mutable.containsKey(irVariable)); |
| 89 Variable variable = new Variable(currentElement, irVariable.hint); | 87 Variable variable = new Variable(currentElement, irVariable.hint); |
| 90 local2mutable[irVariable] = variable; | 88 local2mutable[irVariable] = variable; |
| 91 return variable; | 89 return variable; |
| 92 } | 90 } |
| 93 | 91 |
| 94 Variable getMutableVariable(cps_ir.MutableVariable mutableVariable) { | 92 Variable getMutableVariable(cps_ir.MutableVariable mutableVariable) { |
| 95 if (mutableVariable.host != currentElement) { | 93 if (mutableVariable.host != currentElement) { |
| 96 return parent.getMutableVariable(mutableVariable); | 94 return parent.getMutableVariable(mutableVariable)..isCaptured = true; |
| 97 } | 95 } |
| 98 return local2mutable[mutableVariable]; | 96 return local2mutable[mutableVariable]; |
| 99 } | 97 } |
| 100 | 98 |
| 101 VariableUse getMutableVariableUse( | 99 VariableUse getMutableVariableUse( |
| 102 cps_ir.Reference<cps_ir.MutableVariable> reference) { | 100 cps_ir.Reference<cps_ir.MutableVariable> reference) { |
| 103 Variable variable = getMutableVariable(reference.definition); | 101 Variable variable = getMutableVariable(reference.definition); |
| 104 return new VariableUse(variable); | 102 return new VariableUse(variable); |
| 105 } | 103 } |
| 106 | 104 |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 } | 636 } |
| 639 | 637 |
| 640 Expression visitReifyRuntimeType(cps_ir.ReifyRuntimeType node) { | 638 Expression visitReifyRuntimeType(cps_ir.ReifyRuntimeType node) { |
| 641 return new ReifyRuntimeType(getVariableUse(node.value)); | 639 return new ReifyRuntimeType(getVariableUse(node.value)); |
| 642 } | 640 } |
| 643 | 641 |
| 644 Expression visitReadTypeVariable(cps_ir.ReadTypeVariable node) { | 642 Expression visitReadTypeVariable(cps_ir.ReadTypeVariable node) { |
| 645 return new ReadTypeVariable(node.variable, getVariableUse(node.target)); | 643 return new ReadTypeVariable(node.variable, getVariableUse(node.target)); |
| 646 } | 644 } |
| 647 } | 645 } |
| OLD | NEW |