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

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 24d77a7b073d6b532c7faba2a1e612ca573e54d4..d01b4ce979af2d671a6568ea3d85b8a03782d696 100644
--- a/lib/compiler/implementation/dart_backend/backend.dart
+++ b/lib/compiler/implementation/dart_backend/backend.dart
@@ -71,13 +71,14 @@ class DartBackend extends Backend {
try {
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(
Roman 2012/08/10 07:27:40 This is probably controversial, but I think "typed
Anton Muhin 2012/08/10 08:33:37 Indeed. For example, I really don't like that you
- compiler, element, treeElements, typedefs)
+ compiler, element, treeElements, typedefs, classes)
.collect();
});
@@ -101,6 +102,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;
Roman 2012/08/10 07:27:40 Why not unify "classes" collection and "resolvedCl
Anton Muhin 2012/08/10 08:33:37 I am considering this too. But for now I'd prefer
Roman 2012/08/10 08:46:01 "Not knowing about the rest of system" is not quit
Anton Muhin 2012/08/10 08:56:48 I meant pretty simple thing: ReferencedElementColl
+ emitter.outputClass(classElement, emptySet);
+ });
// Now output resolved classes with inner elements we met before.
resolvedClassMembers.forEach(emitter.outputClass);
@@ -142,22 +149,31 @@ 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) {
Roman 2012/08/10 07:27:40 This IF may be changed to just "compiler.resolveTy
Anton Muhin 2012/08/10 08:33:37 Good point, done. On 2012/08/10 07:27:40, Roman w
- if (element.isTypedef()) typedefs.add(element);
+ addElement(element);
+ } else {
+ final type = compiler.resolveTypeAnnotation(this.element, typeAnnotation);
+ addElement(type.element);
}
typeAnnotation.visitChildren(this);
}
+ addElement(Element element) {
+ if (element.isTypedef()) typedefs.add(element);
+ if (element.isClass()) classes.add(element);
+ }
+
void collect() {
element.parseNode(compiler).accept(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