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

Side by Side Diff: pkg/kernel/lib/text/ast_to_text.dart

Issue 3008763002: Store actual Reference(s) for additional exports. (Closed)
Patch Set: Created 3 years, 3 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
OLDNEW
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
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
286 // TODO(scheglov): Do we want to print dependencies? dartbug.com/30224 287 // TODO(scheglov): Do we want to print dependencies? dartbug.com/30224
288 if (library.additionalExports.isNotEmpty) {
289 write('additionalExports = (');
290 if (library.additionalExports.length > 5) {
291 write('too many items');
ahe 2017/08/29 11:04:23 I don't think we should truncate the output.
scheglov 2017/08/29 15:16:26 Done.
292 } else {
293 for (var reference in library.additionalExports) {
294 var node = reference.node;
295 if (node is Class) {
296 Library nodeLibrary = node.enclosingLibrary;
297 String prefix = syntheticNames.nameLibraryPrefix(nodeLibrary);
298 write(prefix + '::' + node.name);
299 } else if (node is Field) {
300 Library nodeLibrary = node.enclosingLibrary;
301 String prefix = syntheticNames.nameLibraryPrefix(nodeLibrary);
302 write(prefix + '::' + node.name.name);
303 } else if (node is Procedure) {
304 Library nodeLibrary = node.enclosingLibrary;
305 String prefix = syntheticNames.nameLibraryPrefix(nodeLibrary);
306 write(prefix + '::' + node.name.name);
307 } else if (node is Typedef) {
308 Library nodeLibrary = node.enclosingLibrary;
309 String prefix = syntheticNames.nameLibraryPrefix(nodeLibrary);
310 write(prefix + '::' + node.name);
311 } else {
312 throw new UnimplementedError('${node.runtimeType}');
313 }
314 }
315 }
316 endLine(')');
317 }
318
287 endLine(); 319 endLine();
288 var inner = new Printer._inner(this, imports); 320 var inner = new Printer._inner(this, imports);
289 library.typedefs.forEach(inner.writeNode); 321 library.typedefs.forEach(inner.writeNode);
290 library.classes.forEach(inner.writeNode); 322 library.classes.forEach(inner.writeNode);
291 library.fields.forEach(inner.writeNode); 323 library.fields.forEach(inner.writeNode);
292 library.procedures.forEach(inner.writeNode); 324 library.procedures.forEach(inner.writeNode);
293 } 325 }
294 326
295 void writeProgramFile(Program program) { 327 void writeProgramFile(Program program) {
296 ImportTable imports = new ProgramImportTable(program); 328 ImportTable imports = new ProgramImportTable(program);
(...skipping 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 } 1704 }
1673 throw 'illegal ProcedureKind: $kind'; 1705 throw 'illegal ProcedureKind: $kind';
1674 } 1706 }
1675 1707
1676 class ExpressionPrinter { 1708 class ExpressionPrinter {
1677 final Printer writeer; 1709 final Printer writeer;
1678 final int minimumPrecedence; 1710 final int minimumPrecedence;
1679 1711
1680 ExpressionPrinter(this.writeer, this.minimumPrecedence); 1712 ExpressionPrinter(this.writeer, this.minimumPrecedence);
1681 } 1713 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698