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

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, 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
Index: lib/compiler/implementation/tree/unparser.dart
diff --git a/lib/compiler/implementation/tree/unparser.dart b/lib/compiler/implementation/tree/unparser.dart
index fe6a4935ff48e0803ebcb9ca0d85f2a0f394c300..37dcbf13573c4e8d6cf6a687837808b0b7e5b430 100644
--- a/lib/compiler/implementation/tree/unparser.dart
+++ b/lib/compiler/implementation/tree/unparser.dart
@@ -57,34 +57,47 @@ class Unparser implements Visitor {
visit(node.expression);
}
- visitClassNode(ClassNode node) {
+ emitClassWithBody(ClassNode node, classBodyEmitter) {
Roman 2012/08/31 13:52:15 Can you please specify the full signature for 'cla
Anton Muhin 2012/08/31 14:01:09 If emitClassWithBody(ClassNode node, void classBod
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) {
+ emitClassWithBody(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) {

Powered by Google App Engine
This is Rietveld 408576698