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

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

Issue 10695171: dart2dart fix "get" appearing before type in typed getter. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/compiler/dart2js/unparser_test.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 DiagnosticListener listener; 10 final Compiler compiler;
11 final StringBuffer sb; 11 final StringBuffer sb;
12 12
13 Emitter(this.listener) : sb = new StringBuffer(); 13 Emitter(this.compiler) : sb = new StringBuffer();
14 14
15 /** 15 /**
16 * Outputs given class element with selected inner elements. 16 * Outputs given class element with selected inner elements.
17 */ 17 */
18 void outputClass(ClassElement classElement, Set<Element> innerElements) { 18 void outputClass(ClassElement classElement, Set<Element> innerElements) {
19 // TODO(smok): Very soon properly print out correct class declaration with 19 // TODO(smok): Very soon properly print out correct class declaration with
20 // extends, implements, etc. 20 // extends, implements, etc.
21 sb.add('class '); 21 sb.add('class ');
22 sb.add(classElement.name.slowToString()); 22 sb.add(classElement.name.slowToString());
23 sb.add('{'); 23 sb.add('{');
(...skipping 16 matching lines...) Expand all
40 // Figure out type. 40 // Figure out type.
41 if (element is VariableElement) { 41 if (element is VariableElement) {
42 VariableListElement variables = element.variables; 42 VariableListElement variables = element.variables;
43 if (variables.type !== null) { 43 if (variables.type !== null) {
44 sb.add(variables.type); 44 sb.add(variables.type);
45 sb.add(' '); 45 sb.add(' ');
46 } 46 }
47 } 47 }
48 // TODO(smok): Maybe not rely on node unparsing, 48 // TODO(smok): Maybe not rely on node unparsing,
49 // but unparse initializer manually. 49 // but unparse initializer manually.
50 sb.add(element.parseNode(listener).unparse()); 50 sb.add(element.parseNode(compiler).unparse());
51 sb.add(';'); 51 sb.add(';');
52 } else if (element.isSetter() || element.isGetter()) {
Anton Muhin 2012/07/12 08:58:02 can you fix it in the unparser?
Roman 2012/07/12 09:25:40 Done!
53 if (element.type !== null) {
54 assert(element.type is FunctionType);
55 if (element.type.returnType !== compiler.types.dynamicType) {
56 element.type.returnType.name.printOn(sb);
57 sb.add(' ');
58 }
59 }
60 sb.add(element.isGetter() ? 'get' : 'set');
61 sb.add(' ');
62 element.name.printOn(sb);
63 FunctionExpression node = element.parseNode(compiler);
64 sb.add(node.parameters.unparse());
65 sb.add(node.body.unparse());
52 } else { 66 } else {
53 if (element.isSetter()) { 67 sb.add(element.parseNode(compiler).unparse());
54 sb.add('set ');
55 } else if (element.isGetter()) {
56 sb.add('get ');
57 }
58 sb.add(element.parseNode(listener).unparse());
59 } 68 }
60 } 69 }
61 70
62 String toString() => sb.toString(); 71 String toString() => sb.toString();
63 } 72 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698