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

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

Issue 10795064: dart2dart: Introduce Renamer that is used by renaming unparser (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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/dart_backend/emitter.dart
diff --git a/lib/compiler/implementation/dart_backend/emitter.dart b/lib/compiler/implementation/dart_backend/emitter.dart
index 8d177aa82afbf6f4ed5f02f756afe6cace6b72a3..46094f2aef550bffc6afeab7df77f18cdd778548 100644
--- a/lib/compiler/implementation/dart_backend/emitter.dart
+++ b/lib/compiler/implementation/dart_backend/emitter.dart
@@ -9,25 +9,34 @@ class Emitter {
final Compiler compiler;
final StringBuffer sb;
+ Renamer renamer;
Anton Muhin 2012/07/23 11:23:10 make it final?
Roman 2012/07/23 15:34:15 Done.
- Emitter(this.compiler) : sb = new StringBuffer();
+ Emitter(this.compiler) : sb = new StringBuffer() {
+ renamer = new ConflictingRenamer(compiler);
+ }
/**
* Outputs given class element with selected inner elements.
*/
void outputClass(ClassElement classElement, Set<Element> innerElements) {
+ Unparser unparser = new RenamingUnparser(renamer);
+ renamer.setContext(classElement.getCompilationUnit());
ClassNode classNode = classElement.parseNode(compiler);
- sb.add(classElement.beginToken.slowToString()); // 'class' or 'interface'.
+ // classElement.beginToken is 'class', 'interface', or 'abstract'.
+ sb.add(classElement.beginToken.slowToString());
+ if (classElement.beginToken.slowToString() == 'abstract') {
Anton Muhin 2012/07/23 11:23:10 please, a separate change
Roman 2012/07/23 15:34:15 Done.
+ sb.add(' class');
+ }
sb.add(' ');
- sb.add(classNode.name.unparse());
+ sb.add(renamer.renameType(classElement.type));
if (classNode.typeParameters !== null) {
- sb.add(classNode.typeParameters.unparse());
+ sb.add(unparser.unparse(classNode.typeParameters));
}
if (classNode.extendsKeyword !== null) {
sb.add(' ');
classNode.extendsKeyword.value.printOn(sb);
sb.add(' ');
- sb.add(classNode.superclass.unparse());
+ sb.add(renamer.renameType(classElement.supertype));
}
if (!classNode.interfaces.isEmpty()) {
sb.add(classElement.isInterface() ? ' extends ' : ' implements ');
@@ -35,7 +44,7 @@ class Emitter {
}
if (classNode.defaultClause !== null) {
sb.add(' default ');
- sb.add(classNode.defaultClause.unparse());
+ sb.add(unparser.unparse(classNode.defaultClause));
}
sb.add('{');
innerElements.forEach((element) {
@@ -46,15 +55,17 @@ class Emitter {
}
void outputElement(Element element) {
+ Unparser unparser = new RenamingUnparser(renamer);
+ renamer.setContext(element);
// TODO(smok): Figure out why AbstractFieldElement appears here,
// we have used getters/setters resolved instead of it.
if (element is SynthesizedConstructorElement
|| element is AbstractFieldElement) return;
if (element.isField()) {
assert(element is VariableElement);
- sb.add(element.variables.parseNode(compiler).unparse());
+ sb.add(unparser.unparse(element.variables.parseNode(compiler)));
} else {
- sb.add(element.parseNode(compiler).unparse());
+ sb.add(unparser.unparse(element.parseNode(compiler)));
}
}

Powered by Google App Engine
This is Rietveld 408576698