| 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 | 4 |
| 5 // IrNodes are kept in a separate library to have precise control over their | 5 // IrNodes are kept in a separate library to have precise control over their |
| 6 // dependencies on other parts of the system. | 6 // dependencies on other parts of the system. |
| 7 library dart2js.ir_nodes; | 7 library dart2js.ir_nodes; |
| 8 | 8 |
| 9 import '../constants/expressions.dart'; | 9 import '../constants/expressions.dart'; |
| 10 import '../constants/values.dart' as values show ConstantValue; | 10 import '../constants/values.dart' as values show ConstantValue; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // The head of a linked-list of occurrences, in no particular order. | 34 // The head of a linked-list of occurrences, in no particular order. |
| 35 Reference<T> firstRef; | 35 Reference<T> firstRef; |
| 36 | 36 |
| 37 bool get hasAtMostOneUse => firstRef == null || firstRef.next == null; | 37 bool get hasAtMostOneUse => firstRef == null || firstRef.next == null; |
| 38 bool get hasExactlyOneUse => firstRef != null && firstRef.next == null; | 38 bool get hasExactlyOneUse => firstRef != null && firstRef.next == null; |
| 39 bool get hasNoUses => firstRef == null; | 39 bool get hasNoUses => firstRef == null; |
| 40 bool get hasAtLeastOneUse => firstRef != null; | 40 bool get hasAtLeastOneUse => firstRef != null; |
| 41 bool get hasMultipleUses => !hasAtMostOneUse; | 41 bool get hasMultipleUses => !hasAtMostOneUse; |
| 42 | 42 |
| 43 void substituteFor(Definition<T> other) { | 43 void substituteFor(Definition<T> other) { |
| 44 if (other == this) return; |
| 44 if (other.hasNoUses) return; | 45 if (other.hasNoUses) return; |
| 45 Reference<T> previous, current = other.firstRef; | 46 Reference<T> previous, current = other.firstRef; |
| 46 do { | 47 do { |
| 47 current.definition = this; | 48 current.definition = this; |
| 48 previous = current; | 49 previous = current; |
| 49 current = current.next; | 50 current = current.next; |
| 50 } while (current != null); | 51 } while (current != null); |
| 51 previous.next = firstRef; | 52 previous.next = firstRef; |
| 52 if (firstRef != null) firstRef.previous = previous; | 53 if (firstRef != null) firstRef.previous = previous; |
| 53 firstRef = other.firstRef; | 54 firstRef = other.firstRef; |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 } | 395 } |
| 395 | 396 |
| 396 accept(Visitor visitor) => visitor.visitInvokeConstructor(this); | 397 accept(Visitor visitor) => visitor.visitInvokeConstructor(this); |
| 397 } | 398 } |
| 398 | 399 |
| 399 /// "as" casts and "is" checks. | 400 /// "as" casts and "is" checks. |
| 400 // We might want to turn "is"-checks into a [Primitive] as it can never diverge. | 401 // We might want to turn "is"-checks into a [Primitive] as it can never diverge. |
| 401 // But then we need to special-case for is-checks with an erroneous .type as | 402 // But then we need to special-case for is-checks with an erroneous .type as |
| 402 // these will throw. | 403 // these will throw. |
| 403 class TypeOperator extends Expression { | 404 class TypeOperator extends Expression { |
| 404 final Reference<Primitive> receiver; | 405 Reference<Primitive> receiver; |
| 405 final DartType type; | 406 final DartType type; |
| 406 final Reference<Continuation> continuation; | 407 final Reference<Continuation> continuation; |
| 407 // TODO(johnniwinther): Use `Operator` class to encapsule the operator type. | 408 // TODO(johnniwinther): Use `Operator` class to encapsule the operator type. |
| 408 final bool isTypeTest; | 409 final bool isTypeTest; |
| 409 | 410 |
| 410 TypeOperator(Primitive receiver, | 411 TypeOperator(Primitive receiver, |
| 411 this.type, | 412 this.type, |
| 412 Continuation cont, | 413 Continuation cont, |
| 413 {bool this.isTypeTest}) | 414 {bool this.isTypeTest}) |
| 414 : this.receiver = new Reference<Primitive>(receiver), | 415 : this.receiver = new Reference<Primitive>(receiver), |
| (...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1407 processNonTailThrow(node); | 1408 processNonTailThrow(node); |
| 1408 processReference(node.value); | 1409 processReference(node.value); |
| 1409 } | 1410 } |
| 1410 | 1411 |
| 1411 processCreateInvocationMirror(CreateInvocationMirror node) {} | 1412 processCreateInvocationMirror(CreateInvocationMirror node) {} |
| 1412 visitCreateInvocationMirror(CreateInvocationMirror node) { | 1413 visitCreateInvocationMirror(CreateInvocationMirror node) { |
| 1413 processCreateInvocationMirror(node); | 1414 processCreateInvocationMirror(node); |
| 1414 node.arguments.forEach(processReference); | 1415 node.arguments.forEach(processReference); |
| 1415 } | 1416 } |
| 1416 } | 1417 } |
| OLD | NEW |