| 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 25 matching lines...) Expand all Loading... |
| 36 sb.add(unparser.unparse(classNode.typeParameters)); | 36 sb.add(unparser.unparse(classNode.typeParameters)); |
| 37 } | 37 } |
| 38 renamer.setContext(classElement); | 38 renamer.setContext(classElement); |
| 39 if (classNode.extendsKeyword !== null) { | 39 if (classNode.extendsKeyword !== null) { |
| 40 sb.add(' '); | 40 sb.add(' '); |
| 41 classNode.extendsKeyword.value.printOn(sb); | 41 classNode.extendsKeyword.value.printOn(sb); |
| 42 sb.add(' '); | 42 sb.add(' '); |
| 43 sb.add(unparser.unparse(classNode.superclass)); | 43 sb.add(unparser.unparse(classNode.superclass)); |
| 44 } | 44 } |
| 45 if (!classNode.interfaces.isEmpty()) { | 45 if (!classNode.interfaces.isEmpty()) { |
| 46 sb.add(classElement.isInterface() ? ' extends ' : ' implements '); | 46 sb.add(' '); |
| 47 sb.add(unparser.unparse(classNode.interfaces)); | 47 sb.add(unparser.unparse(classNode.interfaces)); |
| 48 } | 48 } |
| 49 if (classNode.defaultClause !== null) { | 49 if (classNode.defaultClause !== null) { |
| 50 sb.add(' default '); | 50 sb.add(' default '); |
| 51 sb.add(unparser.unparse(classNode.defaultClause)); | 51 sb.add(unparser.unparse(classNode.defaultClause)); |
| 52 } | 52 } |
| 53 sb.add('{'); | 53 sb.add('{'); |
| 54 innerElements.forEach((element) { | 54 innerElements.forEach((element) { |
| 55 // TODO(smok): Filter out default constructors here. | 55 // TODO(smok): Filter out default constructors here. |
| 56 outputElement(element); | 56 outputElement(element); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 if (!uri.startsWith('dart:')) continue; | 90 if (!uri.startsWith('dart:')) continue; |
| 91 final lib = libraries[uri]; | 91 final lib = libraries[uri]; |
| 92 if (renamer.imports.containsKey(lib)) { | 92 if (renamer.imports.containsKey(lib)) { |
| 93 result.add('#import("$uri", prefix: "${renamer.imports[lib]}");'); | 93 result.add('#import("$uri", prefix: "${renamer.imports[lib]}");'); |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 result.add(sb); | 96 result.add(sb); |
| 97 return result.toString(); | 97 return result.toString(); |
| 98 } | 98 } |
| 99 } | 99 } |
| OLD | NEW |