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 11 matching lines...) Expand all Loading... |
22 | 22 |
23 import 'dart:async'; | 23 import 'dart:async'; |
24 import 'dart:io'; | 24 import 'dart:io'; |
25 import 'dart:isolate'; | 25 import 'dart:isolate'; |
26 | 26 |
27 import 'package:front_end/src/fasta/vm.dart' | 27 import 'package:front_end/src/fasta/vm.dart' |
28 show CompilationResult, Status, parseScript; | 28 show CompilationResult, Status, parseScript; |
29 | 29 |
30 const bool verbose = const bool.fromEnvironment('DFE_VERBOSE'); | 30 const bool verbose = const bool.fromEnvironment('DFE_VERBOSE'); |
31 | 31 |
| 32 const bool strongMode = const bool.fromEnvironment('DFE_STRONG_MODE'); |
| 33 |
32 Future<CompilationResult> _processLoadRequestImpl(String inputFilePathOrUri) { | 34 Future<CompilationResult> _processLoadRequestImpl(String inputFilePathOrUri) { |
33 Uri scriptUri = Uri.parse(inputFilePathOrUri); | 35 Uri scriptUri = Uri.parse(inputFilePathOrUri); |
34 | 36 |
35 // Because we serve both Loader and bootstrapping requests we need to | 37 // Because we serve both Loader and bootstrapping requests we need to |
36 // duplicate the logic from _resolveScriptUri(...) here and attempt to | 38 // duplicate the logic from _resolveScriptUri(...) here and attempt to |
37 // resolve schemaless uris using current working directory. | 39 // resolve schemaless uris using current working directory. |
38 if (!scriptUri.hasScheme) { | 40 if (!scriptUri.hasScheme) { |
39 // Script does not have a scheme, assume that it is a path, | 41 // Script does not have a scheme, assume that it is a path, |
40 // resolve it against the working directory. | 42 // resolve it against the working directory. |
41 scriptUri = Uri.base.resolveUri(new Uri.file(inputFilePathOrUri)); | 43 scriptUri = Uri.base.resolveUri(new Uri.file(inputFilePathOrUri)); |
42 } | 44 } |
43 | 45 |
44 if (!scriptUri.isScheme('file')) { | 46 if (!scriptUri.isScheme('file')) { |
45 // TODO(vegorov): Reuse loader code to support other schemes. | 47 // TODO(vegorov): Reuse loader code to support other schemes. |
46 return new Future<CompilationResult>.value(new CompilationResult.error( | 48 return new Future<CompilationResult>.value(new CompilationResult.error( |
47 "Expected 'file' scheme for a script uri: got ${scriptUri.scheme}")); | 49 "Expected 'file' scheme for a script uri: got ${scriptUri.scheme}")); |
48 } | 50 } |
49 | 51 |
50 return parseScript(scriptUri, verbose: verbose); | 52 return parseScript(scriptUri, verbose: verbose, strongMode: strongMode); |
51 } | 53 } |
52 | 54 |
53 // Process a request from the runtime. See KernelIsolate::CompileToKernel in | 55 // Process a request from the runtime. See KernelIsolate::CompileToKernel in |
54 // kernel_isolate.cc and Loader::SendKernelRequest in loader.cc. | 56 // kernel_isolate.cc and Loader::SendKernelRequest in loader.cc. |
55 Future _processLoadRequest(request) async { | 57 Future _processLoadRequest(request) async { |
56 if (verbose) { | 58 if (verbose) { |
57 print("DFE: request: $request"); | 59 print("DFE: request: $request"); |
58 print("DFE: Platform.packageConfig: ${Platform.packageConfig}"); | 60 print("DFE: Platform.packageConfig: ${Platform.packageConfig}"); |
59 print("DFE: Platform.resolvedExecutable: ${Platform.resolvedExecutable}"); | 61 print("DFE: Platform.resolvedExecutable: ${Platform.resolvedExecutable}"); |
60 } | 62 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 main([args]) { | 114 main([args]) { |
113 if (args?.length == 2 && args[0] == '--train') { | 115 if (args?.length == 2 && args[0] == '--train') { |
114 // This entry point is used when creating an app snapshot. The argument | 116 // This entry point is used when creating an app snapshot. The argument |
115 // provides a script to compile to warm-up generated code. | 117 // provides a script to compile to warm-up generated code. |
116 train(args[1]); | 118 train(args[1]); |
117 } else { | 119 } else { |
118 // Entry point for the Kernel isolate. | 120 // Entry point for the Kernel isolate. |
119 return new RawReceivePort()..handler = _processLoadRequest; | 121 return new RawReceivePort()..handler = _processLoadRequest; |
120 } | 122 } |
121 } | 123 } |
OLD | NEW |