OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 class PartialTypeTree { | 5 class PartialTypeTree { |
6 | 6 |
7 final Compiler compiler; | 7 final Compiler compiler; |
8 PartialTypeTreeNode root; | 8 PartialTypeTreeNode root; |
9 | 9 |
10 PartialTypeTree(this.compiler); | 10 PartialTypeTree(this.compiler); |
11 | 11 |
12 abstract PartialTypeTreeNode newNode(ClassElement type); | 12 abstract PartialTypeTreeNode newNode(ClassElement type); |
13 | 13 |
14 // TODO(kasperl): Move this to the Selector class? | 14 // TODO(kasperl): Move this to the Selector class? |
15 ClassElement selectorType(Selector selector) { | 15 ClassElement selectorType(Selector selector) { |
16 Type type = selector.receiverType; | 16 DartType type = selector.receiverType; |
17 return (type !== null) ? type.element : compiler.objectClass; | 17 return (type !== null) ? type.element : compiler.objectClass; |
18 } | 18 } |
19 | 19 |
20 /** | 20 /** |
21 * Finds the tree node corresponding to the given [type]. If [insert] | 21 * Finds the tree node corresponding to the given [type]. If [insert] |
22 * is true, we always return a node that matches the type by | 22 * is true, we always return a node that matches the type by |
23 * inserting a new node if necessary. If [insert] is false, we | 23 * inserting a new node if necessary. If [insert] is false, we |
24 * return null if we cannot find a node that matches the [type]. | 24 * return null if we cannot find a node that matches the [type]. |
25 */ | 25 */ |
26 PartialTypeTreeNode findNode(ClassElement type, bool insert) { | 26 PartialTypeTreeNode findNode(ClassElement type, bool insert) { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 bool visitRecursively(bool visit(PartialTypeTreeNode node)) { | 120 bool visitRecursively(bool visit(PartialTypeTreeNode node)) { |
121 if (!visit(this)) return false; | 121 if (!visit(this)) return false; |
122 for (Link link = children; !link.isEmpty(); link = link.tail) { | 122 for (Link link = children; !link.isEmpty(); link = link.tail) { |
123 PartialTypeTreeNode child = link.head; | 123 PartialTypeTreeNode child = link.head; |
124 if (!child.visitRecursively(visit)) return false; | 124 if (!child.visitRecursively(visit)) return false; |
125 } | 125 } |
126 return true; | 126 return true; |
127 } | 127 } |
128 | 128 |
129 } | 129 } |
OLD | NEW |