OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 /// API for compiling Dart source code to .dill (Kernel IR) files. | 5 /// API for compiling Dart source code to .dill (Kernel IR) files. |
6 library front_end.vm; | 6 library front_end.vm; |
7 // TODO(ahe): Convert this file to use the API in `../../kernel_generator.dart` | 7 // TODO(ahe): Convert this file to use the API in `../../kernel_generator.dart` |
8 // and `../../compiler_options.dart`. | 8 // and `../../compiler_options.dart`. |
9 | 9 |
10 import 'dart:async' show Future; | 10 import 'dart:async' show Future; |
11 | 11 |
12 import 'dart:io' show File, Platform; | 12 import 'dart:io' show File, Platform; |
13 | 13 |
14 import 'dart:typed_data' show Uint8List; | 14 import 'dart:typed_data' show Uint8List; |
15 | 15 |
16 import 'package:front_end/file_system.dart'; | 16 import 'package:front_end/file_system.dart'; |
17 import 'package:front_end/physical_file_system.dart'; | 17 import 'package:front_end/physical_file_system.dart'; |
18 | 18 |
19 import 'fasta.dart' as fasta; | 19 import 'fasta.dart' as fasta; |
20 | 20 |
| 21 import 'package:kernel/target/targets.dart' show TargetFlags; |
| 22 import 'package:kernel/target/vm_fasta.dart' show VmFastaTarget; |
| 23 |
21 /// Compilation status codes. | 24 /// Compilation status codes. |
22 /// | 25 /// |
23 /// Note: The [index] property of these constants must match | 26 /// Note: The [index] property of these constants must match |
24 /// `Dart_KernelCompilationStatus` in | 27 /// `Dart_KernelCompilationStatus` in |
25 /// [dart_api.h](../../../../runtime/include/dart_api.h). | 28 /// [dart_api.h](../../../../runtime/include/dart_api.h). |
26 enum Status { | 29 enum Status { |
27 /// Compilation was successful. | 30 /// Compilation was successful. |
28 ok, | 31 ok, |
29 | 32 |
30 /// Compilation failed with a compile time error. | 33 /// Compilation failed with a compile time error. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 80 |
78 if (verbose) { | 81 if (verbose) { |
79 print("""DFE: Requesting compilation { | 82 print("""DFE: Requesting compilation { |
80 scriptUri: ${script} | 83 scriptUri: ${script} |
81 packagesUri: ${packagesUri} | 84 packagesUri: ${packagesUri} |
82 patchedSdk: ${patchedSdk} | 85 patchedSdk: ${patchedSdk} |
83 }"""); | 86 }"""); |
84 } | 87 } |
85 | 88 |
86 try { | 89 try { |
87 return await fasta.parseScriptInFileSystem( | 90 return await fasta.parseScriptInFileSystem(script, fileSystem, packagesUri, |
88 script, fileSystem, packagesUri, patchedSdk, | 91 patchedSdk, new VmFastaTarget(new TargetFlags(strongMode: strongMode)), |
89 verbose: verbose, strongMode: strongMode); | 92 verbose: verbose); |
90 } catch (err, stack) { | 93 } catch (err, stack) { |
91 return new CompilationResult.crash(err, stack); | 94 return new CompilationResult.crash(err, stack); |
92 } | 95 } |
93 } | 96 } |
94 | 97 |
95 class _CompilationOk extends CompilationResult { | 98 class _CompilationOk extends CompilationResult { |
96 final Uint8List bytes; | 99 final Uint8List bytes; |
97 | 100 |
98 _CompilationOk(this.bytes) : super._(); | 101 _CompilationOk(this.bytes) : super._(); |
99 | 102 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 if (await fileSystem.entityForUri(packagesFile).exists()) { | 156 if (await fileSystem.entityForUri(packagesFile).exists()) { |
154 return packagesFile; | 157 return packagesFile; |
155 } | 158 } |
156 if (dir.parent.path == dir.path) { | 159 if (dir.parent.path == dir.path) { |
157 break; | 160 break; |
158 } | 161 } |
159 dir = dir.parent; | 162 dir = dir.parent; |
160 } | 163 } |
161 return null; | 164 return null; |
162 } | 165 } |
OLD | NEW |