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

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 shouldDoVisitAll(Selector selector) {
kasperl 2013/02/11 08:18:12 shouldVisitAll
ngeoffray 2013/02/11 10:20:55 Done.
41 return containsInterfaceSubtypes
42 && (selector.typeKind == TypedSelectorKind.INTERFACE
43 || selector.typeKind == TypedSelectorKind.UNKNOWN);
44 }
45
40 /** 46 /**
41 * Returns all elements that may be invoked with the given [selector]. 47 * Returns all elements that may be invoked with the given [selector].
42 */ 48 */
43 Set<Element> filterBySelector(Selector selector) { 49 Set<Element> filterBySelector(Selector selector) {
44 // TODO(kasperl): For now, we use a different implementation for 50 // TODO(kasperl): For now, we use a different implementation for
45 // filtering if the tree contains interface subtypes. 51 // filtering if the tree contains interface subtypes.
46 return containsInterfaceSubtypes 52 return shouldDoVisitAll(selector)
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 // TODO(kasperl): For now, we use a different implementation for
57 // filtering if the tree contains interface subtypes. 63 // filtering if the tree contains interface subtypes.
58 return containsInterfaceSubtypes 64 return shouldDoVisitAll(selector)
59 ? hasAnyInAll(selector) 65 ? hasAnyInAll(selector)
60 : hasAnyInHierarchy(selector); 66 : hasAnyInHierarchy(selector);
61 } 67 }
62 68
63 Set<Element> filterAllBySelector(Selector selector) { 69 Set<Element> filterAllBySelector(Selector selector) {
64 Set<Element> result = new Set<Element>(); 70 Set<Element> result = new Set<Element>();
65 if (root == null) return result; 71 if (root == null) return result;
66 root.visitRecursively((FunctionSetNode node) { 72 root.visitRecursively((FunctionSetNode node) {
67 Element member = node.membersByName[selector.name]; 73 Element member = node.membersByName[selector.name];
68 // Since we're running through the entire tree we have to use 74 // 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 } 137 }
132 138
133 class FunctionSetNode extends PartialTypeTreeNode { 139 class FunctionSetNode extends PartialTypeTreeNode {
134 140
135 final Map<SourceString, Element> membersByName; 141 final Map<SourceString, Element> membersByName;
136 142
137 FunctionSetNode(ClassElement type) : super(type), 143 FunctionSetNode(ClassElement type) : super(type),
138 membersByName = new Map<SourceString, Element>(); 144 membersByName = new Map<SourceString, Element>();
139 145
140 } 146 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698