Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/universe/function_set.dart

Issue 12207081: Add a type kind to TypedSelector. A typed selector can either be (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 part of universe; 5 part of universe;
6 6
7 // TODO(kasperl): This actually holds getters and setters just fine 7 // TODO(kasperl): This actually holds getters and setters just fine
8 // too and stricly they aren't functions. Maybe this needs a better 8 // too and stricly they aren't functions. Maybe this needs a better
9 // name -- something like ElementSet seems a bit too generic. 9 // name -- something like ElementSet seems a bit too generic.
10 class FunctionSet extends PartialTypeTree { 10 class FunctionSet extends PartialTypeTree {
(...skipping 19 matching lines...) Expand all
30 30
31 // TODO(kasperl): Allow static members too? 31 // TODO(kasperl): Allow static members too?
32 bool contains(Element element) { 32 bool contains(Element element) {
33 assert(element.isMember()); 33 assert(element.isMember());
34 FunctionSetNode node = findNode(element.getEnclosingClass(), false); 34 FunctionSetNode node = findNode(element.getEnclosingClass(), false);
35 return (node != null) 35 return (node != null)
36 ? node.membersByName.containsKey(element.name) 36 ? node.membersByName.containsKey(element.name)
37 : false; 37 : false;
38 } 38 }
39 39
40 bool shouldVisitAll(Selector selector) {
41 // TODO(kasperl): For now, we use a different implementation for
42 // filtering if the tree contains interface subtypes.
43 return containsInterfaceSubtypes
44 && (selector.typeKind == TypedSelectorKind.INTERFACE
45 || selector.typeKind == TypedSelectorKind.UNKNOWN);
46 }
47
40 /** 48 /**
41 * Returns all elements that may be invoked with the given [selector]. 49 * Returns all elements that may be invoked with the given [selector].
42 */ 50 */
43 Set<Element> filterBySelector(Selector selector) { 51 Set<Element> filterBySelector(Selector selector) {
44 // TODO(kasperl): For now, we use a different implementation for 52 return shouldVisitAll(selector)
45 // filtering if the tree contains interface subtypes.
46 return containsInterfaceSubtypes
47 ? filterAllBySelector(selector) 53 ? filterAllBySelector(selector)
48 : filterHierarchyBySelector(selector); 54 : filterHierarchyBySelector(selector);
49 } 55 }
50 56
51 /** 57 /**
52 * Returns whether the set has any element matching the given 58 * Returns whether the set has any element matching the given
53 * [selector]. 59 * [selector].
54 */ 60 */
55 bool hasAnyElementMatchingSelector(Selector selector) { 61 bool hasAnyElementMatchingSelector(Selector selector) {
56 // TODO(kasperl): For now, we use a different implementation for 62 return shouldVisitAll(selector)
57 // filtering if the tree contains interface subtypes.
58 return containsInterfaceSubtypes
59 ? hasAnyInAll(selector) 63 ? hasAnyInAll(selector)
60 : hasAnyInHierarchy(selector); 64 : hasAnyInHierarchy(selector);
61 } 65 }
62 66
63 Set<Element> filterAllBySelector(Selector selector) { 67 Set<Element> filterAllBySelector(Selector selector) {
64 Set<Element> result = new Set<Element>(); 68 Set<Element> result = new Set<Element>();
65 if (root == null) return result; 69 if (root == null) return result;
66 root.visitRecursively((FunctionSetNode node) { 70 root.visitRecursively((FunctionSetNode node) {
67 Element member = node.membersByName[selector.name]; 71 Element member = node.membersByName[selector.name];
68 // Since we're running through the entire tree we have to use 72 // Since we're running through the entire tree we have to use
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 135 }
132 136
133 class FunctionSetNode extends PartialTypeTreeNode { 137 class FunctionSetNode extends PartialTypeTreeNode {
134 138
135 final Map<SourceString, Element> membersByName; 139 final Map<SourceString, Element> membersByName;
136 140
137 FunctionSetNode(ClassElement type) : super(type), 141 FunctionSetNode(ClassElement type) : super(type),
138 membersByName = new Map<SourceString, Element>(); 142 membersByName = new Map<SourceString, Element>();
139 143
140 } 144 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698