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

Unified Diff: lib/compiler/implementation/dart_backend/backend.dart

Issue 10826234: Support some usages of empty classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/dart_backend/backend.dart
diff --git a/lib/compiler/implementation/dart_backend/backend.dart b/lib/compiler/implementation/dart_backend/backend.dart
index a0d810e22b10983279c9cef523a7223057d520a0..aa5cb2c705efbc567f457035a33ae811387803c1 100644
--- a/lib/compiler/implementation/dart_backend/backend.dart
+++ b/lib/compiler/implementation/dart_backend/backend.dart
@@ -59,13 +59,14 @@ class DartBackend extends Backend {
!isDartCoreLib(compiler, element.getLibrary());
Set<TypedefElement> typedefs = new Set<TypedefElement>();
+ Set<ClassElement> classes = new Set<ClassElement>();
PlaceholderCollector collector = new PlaceholderCollector(compiler);
resolvedElements.forEach((element, treeElements) {
if (!shouldOutput(element)) return;
if (element is AbstractFieldElement) return;
collector.collect(element, treeElements);
new ReferencedElementCollector(
- compiler, element, treeElements, typedefs)
+ compiler, element, treeElements, typedefs, classes)
.collect();
});
@@ -89,6 +90,12 @@ class DartBackend extends Backend {
});
typedefs.forEach(emitter.outputElement);
+ final emptySet = new Set<Element>();
+ classes.forEach((classElement) {
+ if (!shouldOutput(classElement)) return;
+ if (resolvedClassMembers.containsKey(classElement)) return;
+ emitter.outputClass(classElement, emptySet);
+ });
// Now output resolved classes with inner elements we met before.
resolvedClassMembers.forEach(emitter.outputClass);
@@ -123,19 +130,20 @@ class ReferencedElementCollector extends AbstractVisitor {
final Element element;
final TreeElements treeElements;
final Set<TypedefElement> typedefs;
+ final Set<ClassElement> classes;
ReferencedElementCollector(
this.compiler,
this.element, this.treeElements,
- this.typedefs);
+ this.typedefs, this.classes);
visitNode(Node node) { node.visitChildren(this); }
visitTypeAnnotation(TypeAnnotation typeAnnotation) {
- Element element = treeElements[typeAnnotation];
- if (element !== null) {
- if (element.isTypedef()) typedefs.add(element);
- }
+ final type = compiler.resolveTypeAnnotation(element, typeAnnotation);
+ Element typeElement = type.element;
+ if (typeElement.isTypedef()) typedefs.add(typeElement);
+ if (typeElement.isClass()) classes.add(typeElement);
typeAnnotation.visitChildren(this);
}
« no previous file with comments | « no previous file | tests/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698