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

Unified Diff: pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart

Issue 1004833002: dart2js: Emit libraries that are only used for typedefs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 | « no previous file | tests/lib/mirrors/typedef_deferred_library_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
diff --git a/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart b/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
index ce3e760d3db6a388b64dea8705616005e28b727c..ac38a05dbcb82b7a0ab68fcbf2b4ea8a5432f2af 100644
--- a/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
@@ -1129,7 +1129,7 @@ class OldEmitter implements Emitter {
output.add(N);
}
- void writeLibraryDescriptors(CodeOutput output, LibraryElement library) {
+ void writeLibraryDescriptor(CodeOutput output, LibraryElement library) {
var uri = "";
if (!compiler.enableMinification || backend.mustPreserveUris) {
uri = library.canonicalUri;
@@ -1432,10 +1432,27 @@ class OldEmitter implements Emitter {
CodeBuffer libraryBuffer = new CodeBuffer();
for (LibraryElement library in Elements.sortedByPosition(libraries)) {
- writeLibraryDescriptors(libraryBuffer, library);
+ writeLibraryDescriptor(libraryBuffer, library);
elementDescriptors.remove(library);
}
+ if (elementDescriptors.isNotEmpty) {
+ List<Element> remainingLibraries = elementDescriptors.keys
+ .where((Element e) => e is LibraryElement)
+ .toList();
+
+ // The remaining descriptors are only accessible through reflection.
+ // The program builder does not collect libraries that only
+ // contain typedefs that are used for reflection.
+ for (LibraryElement element in remainingLibraries) {
+ assert(element is LibraryElement || compiler.hasIncrementalSupport);
+ if (element is LibraryElement) {
+ writeLibraryDescriptor(libraryBuffer, element);
+ elementDescriptors.remove(element);
+ }
+ }
+ }
+
bool needsNativeSupport = program.needsNativeSupport;
mainOutput
..addBuffer(
@@ -1705,7 +1722,7 @@ function(originalDescriptor, name, holder, isStatic, globalFunctionsAccess) {
CodeBuffer buffer = new CodeBuffer();
outputBuffers[outputUnit] = buffer;
for (LibraryElement library in Elements.sortedByPosition(libraries)) {
- writeLibraryDescriptors(buffer, library);
+ writeLibraryDescriptor(buffer, library);
elementDescriptors.remove(library);
}
}
« no previous file with comments | « no previous file | tests/lib/mirrors/typedef_deferred_library_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698