| OLD | NEW |
| 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 16 matching lines...) Expand all Loading... |
| 27 sb.add(classElement.beginToken.slowToString()); | 27 sb.add(classElement.beginToken.slowToString()); |
| 28 if (classElement.beginToken.slowToString() == 'abstract') { | 28 if (classElement.beginToken.slowToString() == 'abstract') { |
| 29 sb.add(' '); | 29 sb.add(' '); |
| 30 sb.add(classElement.beginToken.next.slowToString()); // 'class' | 30 sb.add(classElement.beginToken.next.slowToString()); // 'class' |
| 31 } | 31 } |
| 32 sb.add(' '); | 32 sb.add(' '); |
| 33 sb.add(renamer.renameType(classElement.type)); | 33 sb.add(renamer.renameType(classElement.type)); |
| 34 if (classNode.typeParameters !== null) { | 34 if (classNode.typeParameters !== null) { |
| 35 sb.add(unparser.unparse(classNode.typeParameters)); | 35 sb.add(unparser.unparse(classNode.typeParameters)); |
| 36 } | 36 } |
| 37 renamer.setContext(classElement); |
| 37 if (classNode.extendsKeyword !== null) { | 38 if (classNode.extendsKeyword !== null) { |
| 38 sb.add(' '); | 39 sb.add(' '); |
| 39 classNode.extendsKeyword.value.printOn(sb); | 40 classNode.extendsKeyword.value.printOn(sb); |
| 40 sb.add(' '); | 41 sb.add(' '); |
| 41 sb.add(renamer.renameType(classElement.supertype)); | 42 sb.add(renamer.renameType(classElement.supertype)); |
| 42 } | 43 } |
| 43 if (!classNode.interfaces.isEmpty()) { | 44 if (!classNode.interfaces.isEmpty()) { |
| 44 sb.add(classElement.isInterface() ? ' extends ' : ' implements '); | 45 sb.add(classElement.isInterface() ? ' extends ' : ' implements '); |
| 45 sb.add(unparser.unparse(classNode.interfaces)); | 46 sb.add(unparser.unparse(classNode.interfaces)); |
| 46 } | 47 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 66 if (element.isField()) { | 67 if (element.isField()) { |
| 67 assert(element is VariableElement); | 68 assert(element is VariableElement); |
| 68 sb.add(unparser.unparse(element.variables.parseNode(compiler))); | 69 sb.add(unparser.unparse(element.variables.parseNode(compiler))); |
| 69 } else { | 70 } else { |
| 70 sb.add(unparser.unparse(element.parseNode(compiler))); | 71 sb.add(unparser.unparse(element.parseNode(compiler))); |
| 71 } | 72 } |
| 72 } | 73 } |
| 73 | 74 |
| 74 String toString() => sb.toString(); | 75 String toString() => sb.toString(); |
| 75 } | 76 } |
| OLD | NEW |