| 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 30 matching lines...) Expand all Loading... |
| 41 // Process a request from the runtime. See KernelIsolate::CompileToKernel in | 41 // Process a request from the runtime. See KernelIsolate::CompileToKernel in |
| 42 // kernel_isolate.cc and Loader::SendKernelRequest in loader.cc. | 42 // kernel_isolate.cc and Loader::SendKernelRequest in loader.cc. |
| 43 Future _processLoadRequest(request) async { | 43 Future _processLoadRequest(request) async { |
| 44 if (verbose) print("DFE: request: $request"); | 44 if (verbose) print("DFE: request: $request"); |
| 45 | 45 |
| 46 int tag = request[0]; | 46 int tag = request[0]; |
| 47 final SendPort port = request[1]; | 47 final SendPort port = request[1]; |
| 48 final String inputFileUri = request[2]; | 48 final String inputFileUri = request[2]; |
| 49 final Uri script = Uri.base.resolve(inputFileUri); | 49 final Uri script = Uri.base.resolve(inputFileUri); |
| 50 | 50 |
| 51 FileSystem fileSystem = request.length > 3 | 51 FileSystem fileSystem = PhysicalFileSystem.instance; |
| 52 ? _buildFileSystem(request[3]) | 52 bool requireMain = true; |
| 53 : PhysicalFileSystem.instance; | 53 |
| 54 if (request.length > 3) { |
| 55 fileSystem = _buildFileSystem(request[3]); |
| 56 requireMain = false; |
| 57 } |
| 54 | 58 |
| 55 Uri packagesUri = (Platform.packageConfig != null) | 59 Uri packagesUri = (Platform.packageConfig != null) |
| 56 ? Uri.parse(Platform.packageConfig) | 60 ? Uri.parse(Platform.packageConfig) |
| 57 : null; | 61 : null; |
| 58 | 62 |
| 59 Uri sdkSummary = Uri.base | 63 Uri sdkSummary = Uri.base |
| 60 .resolveUri(new Uri.file(Platform.resolvedExecutable)) | 64 .resolveUri(new Uri.file(Platform.resolvedExecutable)) |
| 61 .resolveUri(new Uri.directory("patched_sdk")) | 65 .resolveUri(new Uri.directory("patched_sdk")) |
| 62 // TODO(sigmund): use outline.dill when the mixin transformer is modular. | 66 // TODO(sigmund): use outline.dill when the mixin transformer is modular. |
| 63 .resolve('platform.dill'); | 67 .resolve('platform.dill'); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 75 ..strongMode = strongMode | 79 ..strongMode = strongMode |
| 76 ..fileSystem = fileSystem | 80 ..fileSystem = fileSystem |
| 77 ..target = new VmFastaTarget(new TargetFlags(strongMode: strongMode)) | 81 ..target = new VmFastaTarget(new TargetFlags(strongMode: strongMode)) |
| 78 ..packagesFileUri = packagesUri | 82 ..packagesFileUri = packagesUri |
| 79 ..sdkSummary = sdkSummary | 83 ..sdkSummary = sdkSummary |
| 80 ..verbose = verbose | 84 ..verbose = verbose |
| 81 ..onError = (CompilationError e) => errors.add(e.message); | 85 ..onError = (CompilationError e) => errors.add(e.message); |
| 82 | 86 |
| 83 CompilationResult result; | 87 CompilationResult result; |
| 84 try { | 88 try { |
| 85 Program program = await kernelForProgram(script, options); | 89 Program program = requireMain |
| 90 ? await kernelForProgram(script, options) |
| 91 : await kernelForBuildUnit([script], options..chaseDependencies = true); |
| 92 |
| 86 if (errors.isNotEmpty) { | 93 if (errors.isNotEmpty) { |
| 87 result = new CompilationResult.errors(errors); | 94 result = new CompilationResult.errors(errors); |
| 88 } else { | 95 } else { |
| 89 // We serialize the program excluding platform.dill because the VM has | 96 // We serialize the program excluding platform.dill because the VM has |
| 90 // these sources built-in. Everything loaded as a summary in | 97 // these sources built-in. Everything loaded as a summary in |
| 91 // [kernelForProgram] is marked `external`, so we can use that bit to | 98 // [kernelForProgram] is marked `external`, so we can use that bit to |
| 92 // decide what to excluce. | 99 // decide what to excluce. |
| 93 // TODO(sigmund): remove the following line (Issue #30111) | 100 // TODO(sigmund): remove the following line (Issue #30111) |
| 94 program.libraries.forEach((e) => e.isExternal = false); | 101 program.libraries.forEach((e) => e.isExternal = false); |
| 95 result = new CompilationResult.ok( | 102 result = new CompilationResult.ok( |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 _CompilationCrash(this.exception, this.stack); | 248 _CompilationCrash(this.exception, this.stack); |
| 242 | 249 |
| 243 @override | 250 @override |
| 244 Status get status => Status.crash; | 251 Status get status => Status.crash; |
| 245 | 252 |
| 246 @override | 253 @override |
| 247 String get errorString => "${exception}\n${stack}"; | 254 String get errorString => "${exception}\n${stack}"; |
| 248 | 255 |
| 249 String toString() => "_CompilationCrash(${errorString})"; | 256 String toString() => "_CompilationCrash(${errorString})"; |
| 250 } | 257 } |
| OLD | NEW |