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 #include "bin/dfe.h" | 5 #include "bin/dfe.h" |
6 #include "bin/dartutils.h" | 6 #include "bin/dartutils.h" |
7 #include "bin/error_exit.h" | 7 #include "bin/error_exit.h" |
8 #include "bin/file.h" | 8 #include "bin/file.h" |
9 | 9 |
10 #include "vm/kernel.h" | 10 #include "vm/kernel.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 ASSERT(!Dart_IsServiceIsolate(isolate) && !Dart_IsKernelIsolate(isolate)); | 66 ASSERT(!Dart_IsServiceIsolate(isolate) && !Dart_IsKernelIsolate(isolate)); |
67 // First check if the URL points to a Kernel IR file in which case we | 67 // First check if the URL points to a Kernel IR file in which case we |
68 // skip the compilation step and directly reload the file. | 68 // skip the compilation step and directly reload the file. |
69 const uint8_t* kernel_ir = NULL; | 69 const uint8_t* kernel_ir = NULL; |
70 intptr_t kernel_ir_size = -1; | 70 intptr_t kernel_ir_size = -1; |
71 if (!TryReadKernelFile(url_string, &kernel_ir, &kernel_ir_size)) { | 71 if (!TryReadKernelFile(url_string, &kernel_ir, &kernel_ir_size)) { |
72 // We have a source file, compile it into a kernel ir first. | 72 // We have a source file, compile it into a kernel ir first. |
73 // TODO(asiva): We will have to change this API to pass in a list of files | 73 // TODO(asiva): We will have to change this API to pass in a list of files |
74 // that have changed. For now just pass in the main url_string and have it | 74 // that have changed. For now just pass in the main url_string and have it |
75 // recompile the script. | 75 // recompile the script. |
76 Dart_KernelCompilationResult kresult = Dart_CompileToKernel(url_string); | 76 Dart_KernelCompilationResult kresult = |
77 Dart_CompileToKernel(url_string, platform_binary_filename_); | |
Siggi Cherem (dart-lang)
2017/08/16 23:29:18
Could you add a TODO here that we should be passin
aam
2017/08/17 02:10:51
Done.
| |
77 if (kresult.status != Dart_KernelCompilationStatus_Ok) { | 78 if (kresult.status != Dart_KernelCompilationStatus_Ok) { |
78 return Dart_NewApiError(kresult.error); | 79 return Dart_NewApiError(kresult.error); |
79 } | 80 } |
80 kernel_ir = kresult.kernel; | 81 kernel_ir = kresult.kernel; |
81 kernel_ir_size = kresult.kernel_size; | 82 kernel_ir_size = kresult.kernel_size; |
82 } | 83 } |
83 void* kernel_program = Dart_ReadKernelBinary(kernel_ir, kernel_ir_size); | 84 void* kernel_program = Dart_ReadKernelBinary(kernel_ir, kernel_ir_size); |
84 ASSERT(kernel_program != NULL); | 85 ASSERT(kernel_program != NULL); |
85 Dart_Handle result = Dart_LoadKernel(kernel_program); | 86 Dart_Handle result = Dart_LoadKernel(kernel_program); |
86 if (Dart_IsError(result)) { | 87 if (Dart_IsError(result)) { |
87 return result; | 88 return result; |
88 } | 89 } |
89 // Finalize loading. This will complete any futures for completed deferred | 90 // Finalize loading. This will complete any futures for completed deferred |
90 // loads. | 91 // loads. |
91 result = Dart_FinalizeLoading(true); | 92 result = Dart_FinalizeLoading(true); |
92 if (Dart_IsError(result)) { | 93 if (Dart_IsError(result)) { |
93 return result; | 94 return result; |
94 } | 95 } |
95 return Dart_Null(); | 96 return Dart_Null(); |
96 } | 97 } |
97 | 98 |
98 void* DFE::CompileAndReadScript(const char* script_uri, | 99 void* DFE::CompileAndReadScript(const char* script_uri, |
99 char** error, | 100 char** error, |
100 int* exit_code) { | 101 int* exit_code) { |
101 Dart_KernelCompilationResult result = Dart_CompileToKernel(script_uri); | 102 Dart_KernelCompilationResult result = |
103 Dart_CompileToKernel(script_uri, platform_binary_filename_); | |
102 switch (result.status) { | 104 switch (result.status) { |
103 case Dart_KernelCompilationStatus_Ok: | 105 case Dart_KernelCompilationStatus_Ok: |
104 return Dart_ReadKernelBinary(result.kernel, result.kernel_size); | 106 return Dart_ReadKernelBinary(result.kernel, result.kernel_size); |
105 case Dart_KernelCompilationStatus_Error: | 107 case Dart_KernelCompilationStatus_Error: |
106 *error = result.error; // Copy error message. | 108 *error = result.error; // Copy error message. |
107 *exit_code = kCompilationErrorExitCode; | 109 *exit_code = kCompilationErrorExitCode; |
108 break; | 110 break; |
109 case Dart_KernelCompilationStatus_Crash: | 111 case Dart_KernelCompilationStatus_Crash: |
110 *error = result.error; // Copy error message. | 112 *error = result.error; // Copy error message. |
111 *exit_code = kDartFrontendErrorExitCode; | 113 *exit_code = kDartFrontendErrorExitCode; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 *kernel_ir = buffer; | 163 *kernel_ir = buffer; |
162 return true; | 164 return true; |
163 } | 165 } |
164 } | 166 } |
165 } | 167 } |
166 return false; | 168 return false; |
167 } | 169 } |
168 | 170 |
169 } // namespace bin | 171 } // namespace bin |
170 } // namespace dart | 172 } // namespace dart |
OLD | NEW |