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

Side by Side Diff: lib/compiler/implementation/dart_backend/emitter.dart

Issue 10834330: Clean-up of getCompilationUnit. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | lib/compiler/implementation/elements/elements.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Dart backend helper for converting program IR back to source code. 6 * Dart backend helper for converting program IR back to source code.
7 */ 7 */
8 class Emitter { 8 class Emitter {
9 9
10 final Compiler compiler; 10 final Compiler compiler;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 Unparser unparser = new Unparser.withRenamer(renamer.rename); 59 Unparser unparser = new Unparser.withRenamer(renamer.rename);
60 // TODO(smok): Figure out why AbstractFieldElement appears here, 60 // TODO(smok): Figure out why AbstractFieldElement appears here,
61 // we have used getters/setters resolved instead of it. 61 // we have used getters/setters resolved instead of it.
62 if (element is SynthesizedConstructorElement 62 if (element is SynthesizedConstructorElement
63 || element is AbstractFieldElement) return; 63 || element is AbstractFieldElement) return;
64 if (element.isField()) { 64 if (element.isField()) {
65 assert(element is VariableElement); 65 assert(element is VariableElement);
66 // Different VariableElement's may refer to the same VariableListElement. 66 // Different VariableElement's may refer to the same VariableListElement.
67 // Output this list only once. 67 // Output this list only once.
68 // TODO: only emit used variables. 68 // TODO: only emit used variables.
69 final variableList = (element as VariableElement).variables; 69 VariableElement variableElement = element;
70 final variableList = variableElement.variables;
70 if (!processedVariableLists.contains(variableList)) { 71 if (!processedVariableLists.contains(variableList)) {
71 processedVariableLists.add(variableList); 72 processedVariableLists.add(variableList);
72 sb.add(unparser.unparse(variableList.parseNode(compiler))); 73 sb.add(unparser.unparse(variableList.parseNode(compiler)));
73 } 74 }
74 } else { 75 } else {
75 sb.add(unparser.unparse(element.parseNode(compiler))); 76 sb.add(unparser.unparse(element.parseNode(compiler)));
76 } 77 }
77 } 78 }
78 79
79 String toString() { 80 String toString() {
80 final result = new StringBuffer(); 81 final result = new StringBuffer();
81 final libraries = compiler.libraries; 82 final libraries = compiler.libraries;
82 for (final uri in libraries.getKeys()) { 83 for (final uri in libraries.getKeys()) {
83 // Same library element may be a value for different uris as of now 84 // Same library element may be a value for different uris as of now
84 // e.g., core libraryElement is a value for both keys 'dart:core' 85 // e.g., core libraryElement is a value for both keys 'dart:core'
85 // and full file name. Only care about uris with dart scheme. 86 // and full file name. Only care about uris with dart scheme.
86 if (!uri.startsWith('dart:')) continue; 87 if (!uri.startsWith('dart:')) continue;
87 final lib = libraries[uri]; 88 final lib = libraries[uri];
88 if (renamer.imports.containsKey(lib)) { 89 if (renamer.imports.containsKey(lib)) {
89 result.add('#import("$uri", prefix: "${renamer.imports[lib]}");'); 90 result.add('#import("$uri", prefix: "${renamer.imports[lib]}");');
90 } 91 }
91 } 92 }
92 result.add(sb); 93 result.add(sb);
93 return result.toString(); 94 return result.toString();
94 } 95 }
95 } 96 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/elements/elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698