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

Unified Diff: lib/compiler/implementation/tree/unparser.dart

Issue 10916053: Get rid of duplication of class node unparsing. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | « lib/compiler/implementation/dart_backend/emitter.dart ('k') | tests/compiler/dart2js/unparser2_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/tree/unparser.dart
diff --git a/lib/compiler/implementation/tree/unparser.dart b/lib/compiler/implementation/tree/unparser.dart
index 1e551faaf03ea6e41558011395d0ac20ac840383..7bd68bb71b4550584a9924ed269012a66a3cc7ad 100644
--- a/lib/compiler/implementation/tree/unparser.dart
+++ b/lib/compiler/implementation/tree/unparser.dart
@@ -66,34 +66,47 @@ class Unparser implements Visitor {
visit(node.expression);
}
- visitClassNode(ClassNode node) {
+ unparseClassWithBody(ClassNode node, classBodyEmitter) {
Roman 2012/09/03 09:43:23 did we agree on 'void classBodyEmitter()' ?
Anton Muhin 2012/09/03 09:52:03 Done.
addToken(node.beginToken);
+ if (node.beginToken.stringValue == 'abstract') {
+ addToken(node.beginToken.next);
+ }
visit(node.name);
if (node.typeParameters !== null) {
visit(node.typeParameters);
}
- sb.add(' ');
if (node.extendsKeyword !== null) {
+ sb.add(' ');
addToken(node.extendsKeyword);
visit(node.superclass);
+ }
+ if (!node.interfaces.isEmpty()) {
sb.add(' ');
+ visit(node.interfaces);
}
- visit(node.interfaces);
if (node.defaultClause !== null) {
+ sb.add(' default ');
visit(node.defaultClause);
- sb.add(' ');
}
- sb.add('{\n');
- NodeList body = node.body;
- if (body !== null) {
- Link nodes = body.nodes;
- if (!nodes.isEmpty()) {
- sb.add(' ');
- nodes.printOn(sb, '\n ');
+ sb.add('{');
+ classBodyEmitter();
+ sb.add('}');
+ }
+
+ visitClassNode(ClassNode node) {
+ unparseClassWithBody(node, () {
+ NodeList body = node.body;
+ if (body !== null) {
sb.add('\n');
+ Link nodes = body.nodes;
+ if (!nodes.isEmpty()) {
+ sb.add(' ');
+ nodes.printOn(sb, '\n ');
+ sb.add('\n');
+ }
}
- }
- sb.add('}\n');
+ });
+ sb.add('\n');
}
visitConditional(Conditional node) {
« no previous file with comments | « lib/compiler/implementation/dart_backend/emitter.dart ('k') | tests/compiler/dart2js/unparser2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698