| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library dart2js.ir_nodes; | 4 library dart2js.ir_nodes; |
| 5 | 5 |
| 6 import '../constants/values.dart' as values show ConstantValue; | 6 import '../constants/values.dart' as values show ConstantValue; |
| 7 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; | 7 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; |
| 8 import '../elements/elements.dart'; | 8 import '../elements/elements.dart'; |
| 9 import '../io/source_information.dart' show SourceInformation; | 9 import '../io/source_information.dart' show SourceInformation; |
| 10 import '../types/types.dart' show TypeMask; | 10 import '../types/types.dart' show TypeMask; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 /// Unlinks this reference from the list of occurrences. | 121 /// Unlinks this reference from the list of occurrences. |
| 122 void unlink() { | 122 void unlink() { |
| 123 if (previous == null) { | 123 if (previous == null) { |
| 124 assert(definition.firstRef == this); | 124 assert(definition.firstRef == this); |
| 125 definition.firstRef = next; | 125 definition.firstRef = next; |
| 126 } else { | 126 } else { |
| 127 previous.next = next; | 127 previous.next = next; |
| 128 } | 128 } |
| 129 if (next != null) next.previous = previous; | 129 if (next != null) next.previous = previous; |
| 130 } | 130 } |
| 131 |
| 132 /// Changes the definition referenced by this object and updates |
| 133 /// the reference chains accordingly. |
| 134 void changeTo(Definition<T> newDefinition) { |
| 135 unlink(); |
| 136 previous = null; |
| 137 definition = newDefinition; |
| 138 next = definition.firstRef; |
| 139 if (next != null) next.previous = this; |
| 140 definition.firstRef = this; |
| 141 } |
| 131 } | 142 } |
| 132 | 143 |
| 133 /// Evaluates a primitive and binds it to variable: `let val x = V in E`. | 144 /// Evaluates a primitive and binds it to variable: `let val x = V in E`. |
| 134 /// | 145 /// |
| 135 /// The bound value is in scope in the body. | 146 /// The bound value is in scope in the body. |
| 136 /// | 147 /// |
| 137 /// During one-pass construction a LetPrim with an empty body is used to | 148 /// During one-pass construction a LetPrim with an empty body is used to |
| 138 /// represent the one-hole context `let val x = V in []`. | 149 /// represent the one-hole context `let val x = V in []`. |
| 139 class LetPrim extends Expression implements InteriorNode { | 150 class LetPrim extends Expression implements InteriorNode { |
| 140 Primitive primitive; | 151 Primitive primitive; |
| (...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1429 const RemovalVisitor(); | 1440 const RemovalVisitor(); |
| 1430 | 1441 |
| 1431 processReference(Reference reference) { | 1442 processReference(Reference reference) { |
| 1432 reference.unlink(); | 1443 reference.unlink(); |
| 1433 } | 1444 } |
| 1434 | 1445 |
| 1435 static void remove(Node node) { | 1446 static void remove(Node node) { |
| 1436 (const RemovalVisitor()).visit(node); | 1447 (const RemovalVisitor()).visit(node); |
| 1437 } | 1448 } |
| 1438 } | 1449 } |
| OLD | NEW |