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 | 4 |
5 /// This is an interface to the Dart Kernel parser and Kernel binary generator. | 5 /// This is an interface to the Dart Kernel parser and Kernel binary generator. |
6 /// | 6 /// |
7 /// It is used by the kernel-isolate to load Dart source code and generate | 7 /// It is used by the kernel-isolate to load Dart source code and generate |
8 /// Kernel binary format. | 8 /// Kernel binary format. |
9 /// | 9 /// |
10 /// This is either invoked as the root script of the Kernel isolate when used | 10 /// This is either invoked as the root script of the Kernel isolate when used |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 import 'package:kernel/binary/ast_to_binary.dart'; | 28 import 'package:kernel/binary/ast_to_binary.dart'; |
29 import 'package:kernel/kernel.dart'; | 29 import 'package:kernel/kernel.dart'; |
30 import 'package:kernel/target/targets.dart'; | 30 import 'package:kernel/target/targets.dart'; |
31 | 31 |
32 import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget; | 32 import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget; |
33 import 'package:front_end/src/fasta/translate_uri.dart' show TranslateUri; | 33 import 'package:front_end/src/fasta/translate_uri.dart' show TranslateUri; |
34 import 'package:front_end/src/fasta/ticker.dart' show Ticker; | 34 import 'package:front_end/src/fasta/ticker.dart' show Ticker; |
35 import 'package:front_end/src/fasta/kernel/kernel_target.dart' | 35 import 'package:front_end/src/fasta/kernel/kernel_target.dart' |
36 show KernelTarget; | 36 show KernelTarget; |
37 import 'package:front_end/src/fasta/ast_kind.dart' show AstKind; | |
38 import 'package:front_end/src/fasta/errors.dart' show InputError; | 37 import 'package:front_end/src/fasta/errors.dart' show InputError; |
39 | 38 |
40 const bool verbose = const bool.fromEnvironment('DFE_VERBOSE'); | 39 const bool verbose = const bool.fromEnvironment('DFE_VERBOSE'); |
41 | 40 |
42 class DataSink implements Sink<List<int>> { | 41 class DataSink implements Sink<List<int>> { |
43 final BytesBuilder builder = new BytesBuilder(); | 42 final BytesBuilder builder = new BytesBuilder(); |
44 | 43 |
45 void add(List<int> data) { | 44 void add(List<int> data) { |
46 builder.add(data); | 45 builder.add(data); |
47 } | 46 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 final uriTranslator = | 114 final uriTranslator = |
116 await TranslateUri.parse(null, new Uri.file(packageConfig)); | 115 await TranslateUri.parse(null, new Uri.file(packageConfig)); |
117 final Ticker ticker = new Ticker(isVerbose: verbose); | 116 final Ticker ticker = new Ticker(isVerbose: verbose); |
118 final DillTarget dillTarget = new DillTarget(ticker, uriTranslator); | 117 final DillTarget dillTarget = new DillTarget(ticker, uriTranslator); |
119 dillTarget.read(new Uri.directory(sdkPath).resolve('platform.dill')); | 118 dillTarget.read(new Uri.directory(sdkPath).resolve('platform.dill')); |
120 final KernelTarget kernelTarget = new KernelTarget(dillTarget, uriTranslator); | 119 final KernelTarget kernelTarget = new KernelTarget(dillTarget, uriTranslator); |
121 try { | 120 try { |
122 kernelTarget.read(fileName); | 121 kernelTarget.read(fileName); |
123 await dillTarget.writeOutline(null); | 122 await dillTarget.writeOutline(null); |
124 program = await kernelTarget.writeOutline(null); | 123 program = await kernelTarget.writeOutline(null); |
125 program = await kernelTarget.writeProgram(null, AstKind.Kernel); | 124 program = await kernelTarget.writeProgram(null); |
126 if (kernelTarget.errors.isNotEmpty) { | 125 if (kernelTarget.errors.isNotEmpty) { |
127 return new CompilationError(kernelTarget.errors | 126 return new CompilationError(kernelTarget.errors |
128 .map((err) => err.toString()) | 127 .map((err) => err.toString()) |
129 .toList(growable: false)); | 128 .toList(growable: false)); |
130 } | 129 } |
131 } on InputError catch (e) { | 130 } on InputError catch (e) { |
132 return new CompilationError(<String>[e.format()]); | 131 return new CompilationError(<String>[e.format()]); |
133 } | 132 } |
134 | 133 |
135 // Perform target-specific transformations. | 134 // Perform target-specific transformations. |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 if (await new File.fromUri(packagesFile).exists()) { | 268 if (await new File.fromUri(packagesFile).exists()) { |
270 return packagesFile; | 269 return packagesFile; |
271 } | 270 } |
272 if (dir.parent.path == dir.path) { | 271 if (dir.parent.path == dir.path) { |
273 break; | 272 break; |
274 } | 273 } |
275 dir = dir.parent; | 274 dir = dir.parent; |
276 } | 275 } |
277 return null; | 276 return null; |
278 } | 277 } |
OLD | NEW |