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

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

Issue 10905019: Separate Dart backend specific logic from basic Unparser. (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/dart_backend/emitter.dart
diff --git a/lib/compiler/implementation/dart_backend/emitter.dart b/lib/compiler/implementation/dart_backend/emitter.dart
index 5b16c27475d5de8d44117cbefa91277823b139c0..a19d34546e5cb1beaa8f7946cd16caf2d572650a 100644
--- a/lib/compiler/implementation/dart_backend/emitter.dart
+++ b/lib/compiler/implementation/dart_backend/emitter.dart
@@ -2,13 +2,36 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+class EmitterUnparser extends Unparser {
+ final Map<Node, String> renames;
+
+ EmitterUnparser(this.renames);
+
+ visit(Node node) {
+ if (node !== null && renames.containsKey(node)) {
+ sb.add(renames[node]);
+ } else {
+ super.visit(node);
+ }
+ }
+
+ unparseSendReceiver(Send node, [bool spacesNeeded=false]) {
+ // TODO(smok): Remove ugly hack for library preferences.
Roman 2012/10/01 14:10:34 library prefixes?
+ // Check that renamer does not want to omit receiver at all,
+ // in that case we don't need spaces or dot.
+ if (node.receiver !== null && renames[node.receiver] == '') return;
+ super.unparseSendReceiver(node, spacesNeeded);
+ }
+}
+
String emitCode(
Compiler compiler,
- Unparser unparser,
+ Map<Node, String> renames,
Map<LibraryElement, String> imports,
Collection<Element> topLevelElements,
Map<ClassElement, Collection<Element>> classMembers) {
final sb = new StringBuffer();
+ final unparser = new EmitterUnparser(renames);
final processedVariableLists = new Set<VariableListElement>();
void outputElement(Element element) {
« no previous file with comments | « lib/compiler/implementation/dart_backend/backend.dart ('k') | lib/compiler/implementation/tree/unparser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698