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

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

Issue 2484913004: Fix crashing bug for closures of the form () { return; } (Closed)
Patch Set: Only re-export the main methods. The ddc codegen doesn't depend on any other methods being exported… 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 | « no previous file | 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..4d492fe622d32b0de3ea9d5488214a323c50d16d 100644
--- a/pkg/dev_compiler/lib/src/compiler/code_generator.dart
+++ b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
@@ -517,35 +517,28 @@ 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
+ // publically exposed JS API for a library.
+ var export = exportedNames.get('main');
- // Don't allow redefining names from this library.
- if (currentNames.containsKey(export.name)) continue;
+ if (export == null) return;
+ if (export is PropertyAccessorElement) {
+ export = (export as PropertyAccessorElement).variable;
+ }
- 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);
+ // 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 | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698