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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart

Issue 14636002: Make TypeMask an interface and start hiding implementation details of FlatTypeMask. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart (revision 22167)
+++ sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart (working copy)
@@ -2254,32 +2254,16 @@
DartType objectType = objectClass.computeType(compiler);
for (Selector selector in selectors) {
- // Introduce a helper function that determines if the given
- // class has a member that matches the current name and
- // selector (grabbed from the scope).
- bool hasMatchingMember(ClassElement holder) {
- Element element = holder.lookupSelector(selector);
- return (element != null)
- ? selector.applies(element, compiler)
- : false;
- }
-
// If the selector is typed, we check to see if that type may
// have a user-defined noSuchMethod implementation. If not, we
// skip the selector altogether.
- // TODO(kasperl): This shouldn't depend on the internals of
- // the type mask. Move more of this code to the type mask.
- ClassElement receiverClass = objectClass;
TypeMask mask = selector.mask;
- if (mask != null) {
- // If the mask is empty it doesn't contain a noSuchMethod
- // handler -- not even if it is nullable.
- if (mask.isEmpty) continue;
- receiverClass = mask.base.element;
+ if (mask == null) {
+ mask = new TypeMask.subclass(compiler.objectClass.rawType);
}
- // If the receiver class is guaranteed to have a member that
+ // If the receiver is guaranteed to have a member that
// matches what we're looking for, there's no need to
// introduce a noSuchMethod handler. It will never be called.
//
@@ -2294,7 +2278,6 @@
// because objects of type B implement foo. On the other hand,
// if we end up calling foo on something of type C we have to
// add a handler for it.
- if (hasMatchingMember(receiverClass)) continue;
// If the holders of all user-defined noSuchMethod
// implementations that might be applicable to the receiver
@@ -2321,9 +2304,8 @@
// If we're calling bar on an object of type A we do need the
// handler because we may have to call B.noSuchMethod since B
// does not implement bar.
- Iterable<ClassElement> holders =
- compiler.world.locateNoSuchMethodHolders(selector);
- if (holders.every(hasMatchingMember)) continue;
+
kasperl 2013/05/01 13:01:04 Very nice. I'd remove this newline though.
ngeoffray 2013/05/01 13:16:40 Done.
+ if (mask.willHit(selector, compiler)) continue;
String jsName = namer.invocationMirrorInternalName(selector);
addedJsNames[jsName] = selector;
}

Powered by Google App Engine
This is Rietveld 408576698