Index: sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart b/sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart |
index d9a6f1bfb6f8d8f51b3a6eb7586029354e9e828e..3ec88381f3f306ecb5a9c095e3f8c62c0b6fad08 100644 |
--- a/sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart |
+++ b/sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart |
@@ -264,15 +264,20 @@ class DartBackend extends Backend { |
fixedMemberNames.add('srcType'); |
fixedMemberNames.add('dstType'); |
+ if (useMirrorHelperLibrary) { |
+ useMirrorHelperLibrary = compiler.mirrorsLibrary != null; |
+ } |
+ |
/** |
* Tells whether we should output given element. Corelib classes like |
* Object should not be in the resulting code. |
*/ |
bool shouldOutput(Element element) { |
- return !identical(element.kind, ElementKind.VOID) |
+ return (!identical(element.kind, ElementKind.VOID) |
ahe
2013/08/19 15:34:06
Since you're changing this line, would you mind up
zarah
2013/08/20 14:08:17
Done.
|
&& isUserLibrary(element.getLibrary()) |
&& !element.isSynthesized |
- && element is !AbstractFieldElement; |
+ && element is !AbstractFieldElement) |
+ || element == compiler.mirrorHelperFunction; |
} |
final elementAsts = new Map<Element, ElementAst>(); |
@@ -397,7 +402,14 @@ class DartBackend extends Backend { |
// some unused identifier. |
collector.unresolvedNodes.add(synthesizedIdentifier); |
makePlaceholders(element) { |
- collector.collect(element); |
+ if (useMirrorHelperLibrary && |
+ element.getLibrary() == compiler.mirrorHelperLibrary) { |
+ useMirrorHelperLibrary = false; |
+ collector.collect(element); |
+ useMirrorHelperLibrary = true; |
ahe
2013/08/19 15:34:06
I would store the old value. It is always good whe
zarah
2013/08/20 14:08:17
Done.
|
+ } else { |
+ collector.collect(element); |
+ } |
if (element.isClass()) { |
classMembers[element].forEach(makePlaceholders); |
} |
@@ -450,8 +462,8 @@ class DartBackend extends Backend { |
} |
} |
- if (useMirrorHelperLibrary && compiler.mirrorsLibrary != null) { |
- MirrorRenamer.addMirrorHelperImport(imports); |
+ if (useMirrorHelperLibrary) { |
+ MirrorRenamer.addRenames(renames, topLevelNodes, compiler); |
} |
final unparser = new EmitterUnparser(renames); |
@@ -480,11 +492,32 @@ class DartBackend extends Backend { |
log(String message) => compiler.log('[DartBackend] $message'); |
+ void onLibraryLoaded(LibraryElement library, Uri uri) { |
+ if (useMirrorHelperLibrary && library == compiler.mirrorsLibrary) { |
+ compiler.mirrorHelperLibrary = compiler.scanBuiltinLibrary( |
+ MirrorRenamer.MIRROR_HELPER_LIBRARY_NAME); |
+ compiler.mirrorHelperFunction = compiler.mirrorHelperLibrary.find( |
+ const SourceString(MirrorRenamer.MIRROR_HELPER_GET_NAME_FUNCTION)); |
+ } |
+ } |
void registerStaticSend(Element element, Node node) { |
ahe
2013/08/19 15:34:06
Add newline before this method.
zarah
2013/08/20 14:08:17
Done.
|
- if (useMirrorHelperLibrary && compiler.mirrorsLibrary != null) { |
- MirrorRenamer.handleStaticSend(renames, element, node, compiler); |
+ if (useMirrorHelperLibrary) { |
+ MirrorRenamer.registerStaticSend(element, node, compiler); |
} |
} |
+ |
+ void registerHelperFunction(Element element, Node node) { |
+ if (element.getLibrary() == compiler.mirrorHelperLibrary) { |
+ MirrorRenamer.registerHelperFunction(element, node, compiler); |
+ } |
+ } |
+ |
+ void registerStaticUse(Element element, Enqueuer enqueuer) { |
+ if (useMirrorHelperLibrary && |
+ element == compiler.mirrorSystemGetNameFunction) { |
+ enqueuer.addToWorkList(compiler.mirrorHelperFunction); |
+ } |
ahe
2013/08/19 15:34:06
Indentation.
zarah
2013/08/20 14:08:17
Done.
|
+ } |
} |
class EmitterUnparser extends Unparser { |