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

Unified Diff: lib/compiler/implementation/world.dart

Issue 10832109: Refactor the way we emit no such method handlers so it's easier to optimize it later. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Improve NSM handling. Created 8 years, 5 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
« no previous file with comments | « lib/compiler/implementation/ssa/builder.dart ('k') | runtime/lib/object.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/world.dart
diff --git a/lib/compiler/implementation/world.dart b/lib/compiler/implementation/world.dart
index f616c5aa4c892251aa2f5984e0c03e6980e8324a..37fff42988ce3a6fbd4e9addec32e2cbbb974638 100644
--- a/lib/compiler/implementation/world.dart
+++ b/lib/compiler/implementation/world.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
class World {
+ Compiler compiler; // Set in populate().
final Map<ClassElement, Set<ClassElement>> subtypes;
World() : subtypes = new Map<ClassElement, Set<ClassElement>>();
@@ -28,6 +29,10 @@ class World {
addSubtypes(cls);
}
});
+
+ // Mark the world as populated.
+ assert(compiler !== null);
+ this.compiler = compiler;
}
/**
@@ -35,6 +40,7 @@ class World {
* selector named [member] on a receiver whose type is [type].
*/
MemberSet _memberSetFor(Type type, SourceString member) {
+ assert(compiler !== null);
ClassElement cls = type.element;
MemberSet result = new MemberSet(member);
Element element = cls.lookupMember(member);
@@ -69,6 +75,17 @@ class World {
});
return (fieldCount == 1 && nonFieldCount == 0) ? field : null;
}
+
+ bool mayHaveUserDefinedNoSuchMethod(Type type) {
ahe 2012/08/02 17:15:05 We should consider this class as "delete-only" as
kasperl 2012/08/03 05:21:00 Yeah, that's probably better.
+ MemberSet memberSet = _memberSetFor(type, Compiler.NO_SUCH_METHOD);
+ // TODO(kasperl): Only return true if the set contains an instance
+ // method with the right signature. Remember to disregard the
+ // implementation in Object.
+ for (Element element in memberSet.elements) {
+ if (element.getEnclosingClass() !== compiler.objectClass) return true;
+ }
+ return false;
+ }
}
/**
« no previous file with comments | « lib/compiler/implementation/ssa/builder.dart ('k') | runtime/lib/object.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698