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

Unified Diff: lib/compiler/implementation/js_backend/selector_map.dart

Issue 10919003: Fix issue with the partial type tree and implemented interfaces. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix comment. Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: lib/compiler/implementation/js_backend/selector_map.dart
diff --git a/lib/compiler/implementation/js_backend/selector_map.dart b/lib/compiler/implementation/js_backend/selector_map.dart
index c4afd32bcb322524ce7ae2312af053d547faee24..532acf862e2f52e01f2a423b63b1bd52d1b77006 100644
--- a/lib/compiler/implementation/js_backend/selector_map.dart
+++ b/lib/compiler/implementation/js_backend/selector_map.dart
@@ -6,7 +6,7 @@ class SelectorMap<T> extends PartialTypeTree {
SelectorMap(Compiler compiler) : super(compiler);
- SelectorMapNode<T> newNode(ClassElement type)
+ SelectorMapNode<T> newSpecializedNode(ClassElement type)
=> new SelectorMapNode<T>(type);
T operator [](Selector selector) {
@@ -69,6 +69,33 @@ class SelectorMap<T> extends PartialTypeTree {
void visitMatching(Element member, bool visit(Selector selector, T value)) {
assert(member.isMember());
if (root === null) return;
+ // TODO(kasperl): For now, we use a different implementation for
+ // visiting if the tree contains interface subtypes.
+ if (containsInterfaceSubtypes) {
+ visitAllMatching(member, visit);
+ } else {
+ visitHierarchyMatching(member, visit);
+ }
+ }
+
+ void visitAllMatching(Element member, bool visit(selector, value)) {
+ root.visitRecursively((SelectorMapNode<T> node) {
+ Link<SelectorValue<T>> selectors = node.selectorsByName[member.name];
+ if (selectors === null) return true;
+ for (Link link = selectors; !link.isEmpty(); link = link.tail) {
+ SelectorValue<T> existing = link.head;
+ Selector selector = existing.selector;
+ // Since we're running through the entire tree we have to use
+ // the applies method that takes types into account.
+ if (selector.applies(member, compiler)) {
+ if (!visit(selector, existing.value)) return false;
+ }
+ }
+ return true;
+ });
+ }
+
+ void visitHierarchyMatching(Element member, bool visit(selector, value)) {
visitHierarchy(member.getEnclosingClass(), (SelectorMapNode<T> node) {
Link<SelectorValue<T>> selectors = node.selectorsByName[member.name];
if (selectors === null) return true;
« no previous file with comments | « lib/compiler/implementation/js_backend/partial_type_tree.dart ('k') | tests/compiler/dart2js_extra/dart2js_extra.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698