Chromium Code Reviews| Index: pkg/compiler/lib/src/dart_backend/backend.dart |
| diff --git a/pkg/compiler/lib/src/dart_backend/backend.dart b/pkg/compiler/lib/src/dart_backend/backend.dart |
| index 174c58b99a97eb0f904308c538b12a60111466d9..9c04d6beb32f0bc30b03f1f47d27d001d917e73e 100644 |
| --- a/pkg/compiler/lib/src/dart_backend/backend.dart |
| +++ b/pkg/compiler/lib/src/dart_backend/backend.dart |
| @@ -47,6 +47,11 @@ class DartBackend extends Backend { |
| final Set<ClassElement> usedTypeLiterals = new Set<ClassElement>(); |
| + /// The set of visible platform classes that are implementated by instantiated |
|
floitsch
2014/11/21 12:14:49
implemented
Johnni Winther
2014/11/21 13:20:31
Done.
|
| + /// user classes. |
| + final Set<ClassElement> _userImplementedPlatformClasses = |
| + new Set<ClassElement>(); |
| + |
| /** |
| * Tells whether it is safe to remove type declarations from variables, |
| * functions parameters. It becomes not safe if: |
| @@ -261,6 +266,7 @@ class DartBackend extends Backend { |
| log(String message) => compiler.log('[DartBackend] $message'); |
| + @override |
| Future onLibrariesLoaded(LoadedLibraries loadedLibraries) { |
| // All platform classes must be resolved to ensure that their member names |
| // are preserved. |
| @@ -287,6 +293,7 @@ class DartBackend extends Backend { |
| return new Future.value(); |
| } |
| + @override |
| void registerStaticUse(Element element, Enqueuer enqueuer) { |
| if (element == compiler.mirrorSystemGetNameFunction) { |
| FunctionElement getNameFunction = mirrorRenamer.getNameFunction; |
| @@ -295,6 +302,44 @@ class DartBackend extends Backend { |
| } |
| } |
| } |
| + |
| + @override |
| + void registerInstantiatedType(InterfaceType type, Registry registry) { |
| + ClassElement cls = type.element; |
| + if (!cls.library.isPlatformLibrary) { |
| + for (Link<DartType> link = cls.allSupertypes; |
|
floitsch
2014/11/21 12:14:49
Give a general description of what you trying to a
Johnni Winther
2014/11/21 13:20:31
Done.
|
| + !link.isEmpty; |
| + link = link.tail) { |
| + InterfaceType supertype = link.head; |
| + ClassElement superclass = supertype.element; |
| + LibraryElement library = superclass.library; |
| + if (library.isPlatformLibrary) { |
| + if (_userImplementedPlatformClasses.add(superclass)) { |
| + // Register selectors for all instance methods since these might |
| + // be called on user classes from within the platform |
| + // implementation. |
| + superclass.forEachLocalMember((Element element) { |
| + if (element.isConstructor || element.isStatic) return; |
| + |
| + FunctionElement function = element.asFunctionElement(); |
| + if (function != null) { |
| + function.computeSignature(compiler); |
| + } |
| + Selector selector = new Selector.fromElement(element); |
| + if (selector.isGetter) { |
| + registry.registerDynamicGetter(selector); |
| + } else if (selector.isSetter) { |
| + registry.registerDynamicSetter(selector); |
| + } else { |
| + registry.registerDynamicInvocation(selector); |
| + } |
| + }); |
| + } |
| + } |
| + } |
| + } |
| + |
| + } |
| } |
| class DartResolutionCallbacks extends ResolutionCallbacks { |