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

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

Issue 2665723002: Implement canonical name scheme in kernel. (Closed)
Patch Set: Address Kevin's comments Created 3 years, 10 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
« no previous file with comments | « pkg/kernel/lib/frontend/accessors.dart ('k') | pkg/kernel/lib/repository.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) 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 4
5 /// Conventions for paths: 5 /// Conventions for paths:
6 /// 6 ///
7 /// - Use the [Uri] class for paths that may have the `file`, `dart` or 7 /// - Use the [Uri] class for paths that may have the `file`, `dart` or
8 /// `package` scheme. Never use [Uri] for relative paths. 8 /// `package` scheme. Never use [Uri] for relative paths.
9 /// - Use [String]s for all filenames and paths that have no scheme prefix. 9 /// - Use [String]s for all filenames and paths that have no scheme prefix.
10 /// - Never translate a `dart:` or `package:` URI into a `file:` URI, instead 10 /// - Never translate a `dart:` or `package:` URI into a `file:` URI, instead
11 /// translate it to a [String] if the file system path is needed. 11 /// translate it to a [String] if the file system path is needed.
12 /// - Only use [File] from dart:io at the last moment when it is needed. 12 /// - Only use [File] from dart:io at the last moment when it is needed.
13 /// 13 ///
14 library kernel; 14 library kernel;
15 15
16 import 'ast.dart'; 16 import 'ast.dart';
17 import 'binary/ast_to_binary.dart'; 17 import 'binary/ast_to_binary.dart';
18 import 'binary/loader.dart'; 18 import 'binary/ast_from_binary.dart';
19 import 'dart:async'; 19 import 'dart:async';
20 import 'dart:io'; 20 import 'dart:io';
21 import 'repository.dart';
22 import 'text/ast_to_text.dart'; 21 import 'text/ast_to_text.dart';
23 22
24 export 'ast.dart'; 23 export 'ast.dart';
25 export 'repository.dart';
26 24
27 Program loadProgramFromBinary(String path, [Repository repository]) { 25 Program loadProgramFromBinary(String path, [Program program]) {
28 repository ??= new Repository(); 26 program ??= new Program();
29 return new BinaryLoader(repository).loadProgram(path); 27 new BinaryBuilder(new File(path).readAsBytesSync()).readProgram(program);
28 return program;
30 } 29 }
31 30
32 Future writeProgramToBinary(Program program, String path) { 31 Future writeProgramToBinary(Program program, String path) {
33 var sink = new File(path).openWrite(); 32 var sink = new File(path).openWrite();
34 var future; 33 var future;
35 try { 34 try {
36 new BinaryPrinter(sink).writeProgramFile(program); 35 new BinaryPrinter(sink).writeProgramFile(program);
37 } finally { 36 } finally {
38 future = sink.close(); 37 future = sink.close();
39 } 38 }
(...skipping 14 matching lines...) Expand all
54 {String path, bool showExternal: false, bool showOffsets: false}) { 53 {String path, bool showExternal: false, bool showOffsets: false}) {
55 StringBuffer buffer = new StringBuffer(); 54 StringBuffer buffer = new StringBuffer();
56 new Printer(buffer, showExternal: showExternal, showOffsets: showOffsets) 55 new Printer(buffer, showExternal: showExternal, showOffsets: showOffsets)
57 .writeProgramFile(program); 56 .writeProgramFile(program);
58 if (path == null) { 57 if (path == null) {
59 print(buffer); 58 print(buffer);
60 } else { 59 } else {
61 new File(path).writeAsStringSync('$buffer'); 60 new File(path).writeAsStringSync('$buffer');
62 } 61 }
63 } 62 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/frontend/accessors.dart ('k') | pkg/kernel/lib/repository.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698