| 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 '../dart2jslib.dart' as dart2js show Constant, ConstructedConstant, | 9 import '../dart2jslib.dart' as dart2js show Constant, ConstructedConstant, |
| 10 StringConstant, ListConstant, MapConstant; | 10 StringConstant, ListConstant, MapConstant; |
| 11 import '../elements/elements.dart'; | 11 import '../elements/elements.dart'; |
| 12 import '../universe/universe.dart' show Selector, SelectorKind; | 12 import '../universe/universe.dart' show Selector, SelectorKind; |
| 13 import '../dart_types.dart' show DartType, GenericType; | 13 import '../dart_types.dart' show DartType, GenericType; |
| 14 import 'const_expression.dart'; | 14 import 'const_expression.dart'; |
| 15 import '../helpers/helpers.dart'; | 15 import '../helpers/helpers.dart'; |
| 16 | 16 |
| 17 abstract class Node { | 17 abstract class Node { |
| 18 static int hashCount = 0; | 18 static int hashCount = 0; |
| 19 final int hashCode = hashCount = (hashCount + 1) & 0x3fffffff; | 19 final int hashCode = hashCount = (hashCount + 1) & 0x3fffffff; |
| 20 | 20 |
| 21 /// A pointer to the parent node. Is null until set by optimization passes. |
| 22 Node parent; |
| 23 |
| 21 accept(Visitor visitor); | 24 accept(Visitor visitor); |
| 22 } | 25 } |
| 23 | 26 |
| 24 abstract class Expression extends Node { | 27 abstract class Expression extends Node { |
| 25 Expression plug(Expression expr) => throw 'impossible'; | 28 Expression plug(Expression expr) => throw 'impossible'; |
| 26 } | 29 } |
| 27 | 30 |
| 28 /// The base class of things that variables can refer to: primitives, | 31 /// The base class of things that variables can refer to: primitives, |
| 29 /// continuations, function and continuation parameters, etc. | 32 /// continuations, function and continuation parameters, etc. |
| 30 abstract class Definition extends Node { | 33 abstract class Definition extends Node { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 } | 79 } |
| 77 } | 80 } |
| 78 | 81 |
| 79 /// Operands to invocations and primitives are always variables. They point to | 82 /// Operands to invocations and primitives are always variables. They point to |
| 80 /// their definition and are doubly-linked into a list of occurrences. | 83 /// their definition and are doubly-linked into a list of occurrences. |
| 81 class Reference { | 84 class Reference { |
| 82 Definition definition; | 85 Definition definition; |
| 83 Reference prevRef = null; | 86 Reference prevRef = null; |
| 84 Reference nextRef = null; | 87 Reference nextRef = null; |
| 85 | 88 |
| 89 /// A pointer to the parent node. Is null until set by optimization passes. |
| 90 Node parent; |
| 91 |
| 86 Reference(this.definition) { | 92 Reference(this.definition) { |
| 87 nextRef = definition.firstRef; | 93 nextRef = definition.firstRef; |
| 88 if (nextRef != null) nextRef.prevRef = this; | 94 if (nextRef != null) nextRef.prevRef = this; |
| 89 definition.firstRef = this; | 95 definition.firstRef = this; |
| 90 } | 96 } |
| 91 | 97 |
| 92 /// Unlinks this reference from the list of occurrences. | 98 /// Unlinks this reference from the list of occurrences. |
| 93 void unlink() { | 99 void unlink() { |
| 94 if (prevRef != null) prevRef.nextRef = nextRef; | 100 if (prevRef != null) prevRef.nextRef = nextRef; |
| 95 else { | 101 else { |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 release(node.parameters[i]); | 891 release(node.parameters[i]); |
| 886 } | 892 } |
| 887 } | 893 } |
| 888 | 894 |
| 889 void visitIsTrue(IsTrue node) { | 895 void visitIsTrue(IsTrue node) { |
| 890 visitReference(node.value); | 896 visitReference(node.value); |
| 891 } | 897 } |
| 892 | 898 |
| 893 } | 899 } |
| 894 | 900 |
| OLD | NEW |