| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library kernel.ast_to_text; | 4 library kernel.ast_to_text; |
| 5 | 5 |
| 6 import '../ast.dart'; | 6 import '../ast.dart'; |
| 7 import '../import_table.dart'; | 7 import '../import_table.dart'; |
| 8 | 8 |
| 9 class Namer<T> { | 9 class Namer<T> { |
| 10 int index = 0; | 10 int index = 0; |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 var importPath = imports.getImportPath(library); | 276 var importPath = imports.getImportPath(library); |
| 277 if (importPath == "") { | 277 if (importPath == "") { |
| 278 var prefix = | 278 var prefix = |
| 279 syntheticNames.nameLibraryPrefix(library, proposedName: 'self'); | 279 syntheticNames.nameLibraryPrefix(library, proposedName: 'self'); |
| 280 endLine('import self as $prefix;'); | 280 endLine('import self as $prefix;'); |
| 281 } else { | 281 } else { |
| 282 var prefix = syntheticNames.nameLibraryPrefix(library); | 282 var prefix = syntheticNames.nameLibraryPrefix(library); |
| 283 endLine('import "$importPath" as $prefix;'); | 283 endLine('import "$importPath" as $prefix;'); |
| 284 } | 284 } |
| 285 } | 285 } |
| 286 | |
| 287 // TODO(scheglov): Do we want to print dependencies? dartbug.com/30224 | 286 // TODO(scheglov): Do we want to print dependencies? dartbug.com/30224 |
| 288 if (library.additionalExports.isNotEmpty) { | |
| 289 write('additionalExports = ('); | |
| 290 for (var reference in library.additionalExports) { | |
| 291 var node = reference.node; | |
| 292 if (node is Class) { | |
| 293 Library nodeLibrary = node.enclosingLibrary; | |
| 294 String prefix = syntheticNames.nameLibraryPrefix(nodeLibrary); | |
| 295 write(prefix + '::' + node.name); | |
| 296 } else if (node is Field) { | |
| 297 Library nodeLibrary = node.enclosingLibrary; | |
| 298 String prefix = syntheticNames.nameLibraryPrefix(nodeLibrary); | |
| 299 write(prefix + '::' + node.name.name); | |
| 300 } else if (node is Procedure) { | |
| 301 Library nodeLibrary = node.enclosingLibrary; | |
| 302 String prefix = syntheticNames.nameLibraryPrefix(nodeLibrary); | |
| 303 write(prefix + '::' + node.name.name); | |
| 304 } else if (node is Typedef) { | |
| 305 Library nodeLibrary = node.enclosingLibrary; | |
| 306 String prefix = syntheticNames.nameLibraryPrefix(nodeLibrary); | |
| 307 write(prefix + '::' + node.name); | |
| 308 } else { | |
| 309 throw new UnimplementedError('${node.runtimeType}'); | |
| 310 } | |
| 311 } | |
| 312 endLine(')'); | |
| 313 } | |
| 314 | |
| 315 endLine(); | 287 endLine(); |
| 316 var inner = new Printer._inner(this, imports); | 288 var inner = new Printer._inner(this, imports); |
| 317 library.typedefs.forEach(inner.writeNode); | 289 library.typedefs.forEach(inner.writeNode); |
| 318 library.classes.forEach(inner.writeNode); | 290 library.classes.forEach(inner.writeNode); |
| 319 library.fields.forEach(inner.writeNode); | 291 library.fields.forEach(inner.writeNode); |
| 320 library.procedures.forEach(inner.writeNode); | 292 library.procedures.forEach(inner.writeNode); |
| 321 } | 293 } |
| 322 | 294 |
| 323 void writeProgramFile(Program program) { | 295 void writeProgramFile(Program program) { |
| 324 ImportTable imports = new ProgramImportTable(program); | 296 ImportTable imports = new ProgramImportTable(program); |
| (...skipping 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1700 } | 1672 } |
| 1701 throw 'illegal ProcedureKind: $kind'; | 1673 throw 'illegal ProcedureKind: $kind'; |
| 1702 } | 1674 } |
| 1703 | 1675 |
| 1704 class ExpressionPrinter { | 1676 class ExpressionPrinter { |
| 1705 final Printer writeer; | 1677 final Printer writeer; |
| 1706 final int minimumPrecedence; | 1678 final int minimumPrecedence; |
| 1707 | 1679 |
| 1708 ExpressionPrinter(this.writeer, this.minimumPrecedence); | 1680 ExpressionPrinter(this.writeer, this.minimumPrecedence); |
| 1709 } | 1681 } |
| OLD | NEW |