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

Unified Diff: pkg/dev_compiler/lib/src/compiler/code_generator.dart

Issue 2500283002: Only re-export the main methods. The ddc codegen doesn't depend on any other methods being exported… (Closed)
Patch Set: added updated sdks Created 4 years, 1 month 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 | « pkg/dev_compiler/lib/js/legacy/dart_sdk.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dev_compiler/lib/src/compiler/code_generator.dart
diff --git a/pkg/dev_compiler/lib/src/compiler/code_generator.dart b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
index 98afa9f74fd645b5b9c08106d0d5abc876b4b053..3e523c972323e4cb6818ef4f50274dbe505db7aa 100644
--- a/pkg/dev_compiler/lib/src/compiler/code_generator.dart
+++ b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
@@ -517,35 +517,32 @@ class CodeGenerator extends GeneralizingAstVisitor
// modules we import, so we will never go down this code path for them.
_moduleItems
.add(js.statement('#.# = #;', [libraryName, name.selector, name]));
- } else {
- // top-level fields, getters, setters need to copy the property
- // descriptor.
- _moduleItems.add(_callHelperStatement(
- 'export(#, #, #);', [libraryName, name.receiver, name.selector]));
}
}
- for (var export in exportedNames.definedNames.values) {
- if (export is PropertyAccessorElement) {
- export = (export as PropertyAccessorElement).variable;
- }
+ // We only need to export main as it is the only method party of the
+ // publicly exposed JS API for a library.
+ // TODO(jacobr): add a library level annotation indicating that all
+ // contents of a library need to be exposed to JS.
+ // https://github.com/dart-lang/sdk/issues/26368
- // Don't allow redefining names from this library.
- if (currentNames.containsKey(export.name)) continue;
+ var export = exportedNames.get('main');
- if (export.isSynthetic && export is PropertyInducingElement) {
- _emitDeclaration(export.getter);
- _emitDeclaration(export.setter);
- } else {
- _emitDeclaration(export);
- }
- if (export is ClassElement && export.typeParameters.isNotEmpty) {
- // Export the generic name as well.
- // TODO(jmesserly): revisit generic classes
- emitExport(export, suffix: r'$');
- }
- emitExport(export);
+ if (export == null) return;
+ if (export is PropertyAccessorElement) {
+ export = (export as PropertyAccessorElement).variable;
+ }
+
+ // Don't allow redefining names from this library.
+ if (currentNames.containsKey(export.name)) return;
+
+ if (export.isSynthetic && export is PropertyInducingElement) {
+ _emitDeclaration(export.getter);
+ _emitDeclaration(export.setter);
+ } else {
+ _emitDeclaration(export);
}
+ emitExport(export);
}
@override
« no previous file with comments | « pkg/dev_compiler/lib/js/legacy/dart_sdk.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698