Chromium Code Reviews| Index: lib/compiler/implementation/dart_backend/emitter.dart |
| diff --git a/lib/compiler/implementation/dart_backend/emitter.dart b/lib/compiler/implementation/dart_backend/emitter.dart |
| index 5b16c27475d5de8d44117cbefa91277823b139c0..f9de3b39afcd477d8df2f6e11867690314b08782 100644 |
| --- a/lib/compiler/implementation/dart_backend/emitter.dart |
| +++ b/lib/compiler/implementation/dart_backend/emitter.dart |
| @@ -8,7 +8,7 @@ String emitCode( |
| Map<LibraryElement, String> imports, |
| Collection<Element> topLevelElements, |
| Map<ClassElement, Collection<Element>> classMembers) { |
| - final sb = new StringBuffer(); |
| + unparser.sb = new StringBuffer(); |
|
Roman
2012/08/31 13:52:15
This hack does not look good. That 'sb' field look
Anton Muhin
2012/08/31 14:01:09
Let me disagree. Rather you original decision to
Roman
2012/08/31 15:39:00
1) Well it was not my decision :) What makes you t
Anton Muhin
2012/08/31 15:47:48
If I meet an object with the following property: u
Roman
2012/08/31 16:49:55
I see visit() as an implementation detail.
Anton Muhin
2012/08/31 18:13:23
Sure, I agree with you. I just didn't want to tou
|
| final processedVariableLists = new Set<VariableListElement>(); |
| void outputElement(Element element) { |
| @@ -22,46 +22,20 @@ String emitCode( |
| final variableList = variableElement.variables; |
| if (!processedVariableLists.contains(variableList)) { |
| processedVariableLists.add(variableList); |
| - sb.add(unparser.unparse(variableList.parseNode(compiler))); |
| + unparser.visit(variableList.parseNode(compiler)); |
| } |
| } else { |
| - sb.add(unparser.unparse(element.parseNode(compiler))); |
| + unparser.visit(element.parseNode(compiler)); |
| } |
| } |
| void outputClass(ClassElement classElement, Collection<Element> members) { |
| - ClassNode classNode = classElement.parseNode(compiler); |
| - // classElement.beginToken is 'class', 'interface', or 'abstract'. |
| - sb.add(classNode.beginToken.slowToString()); |
| - if (classNode.beginToken.slowToString() == 'abstract') { |
| - sb.add(' '); |
| - sb.add(classNode.beginToken.next.slowToString()); // 'class' |
| - } |
| - sb.add(' '); |
| - sb.add(unparser.unparse(classNode.name)); |
| - if (classNode.typeParameters !== null) { |
| - sb.add(unparser.unparse(classNode.typeParameters)); |
| - } |
| - if (classNode.extendsKeyword !== null) { |
| - sb.add(' '); |
| - classNode.extendsKeyword.value.printOn(sb); |
| - sb.add(' '); |
| - sb.add(unparser.unparse(classNode.superclass)); |
| - } |
| - if (!classNode.interfaces.isEmpty()) { |
| - sb.add(' '); |
| - sb.add(unparser.unparse(classNode.interfaces)); |
| - } |
| - if (classNode.defaultClause !== null) { |
| - sb.add(' default '); |
| - sb.add(unparser.unparse(classNode.defaultClause)); |
| - } |
| - sb.add('{'); |
| - members.forEach((element) { |
| - // TODO(smok): Filter out default constructors here. |
| - outputElement(element); |
| + unparser.emitClassWithBody(classElement.parseNode(compiler), () { |
| + members.forEach((element) { |
| + // TODO(smok): Filter out default constructors here. |
| + outputElement(element); |
| + }); |
| }); |
| - sb.add('}'); |
| } |
| final libraries = compiler.libraries; |
| @@ -72,7 +46,7 @@ String emitCode( |
| if (!uri.startsWith('dart:')) continue; |
| final lib = libraries[uri]; |
| if (imports.containsKey(lib)) { |
| - sb.add('#import("$uri", prefix: "${imports[lib]}");'); |
| + unparser.sb.add('#import("$uri", prefix: "${imports[lib]}");'); |
| } |
| } |
| @@ -84,5 +58,5 @@ String emitCode( |
| } |
| } |
| - return sb.toString(); |
| + return unparser.sb.toString(); |
| } |