| 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" |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 namespace bin { | 13 namespace bin { |
| 14 | 14 |
| 15 const char kPlatformBinaryName[] = "platform.dill"; | 15 const char kPlatformBinaryName[] = "platform.dill"; |
| 16 const char kVMServiceIOBinaryName[] = "vmservice_io.dill"; | 16 const char kVMServiceIOBinaryName[] = "vmservice_io.dill"; |
| 17 | 17 |
| 18 DFE::DFE() | 18 DFE::DFE() |
| 19 : frontend_filename_(NULL), | 19 : frontend_filename_(NULL), |
| 20 platform_binary_filename_(NULL), | 20 platform_binary_filename_(NULL), |
| 21 vmservice_io_binary_filename_(NULL), | 21 vmservice_io_binary_filename_(NULL), |
| 22 kernel_platform_(NULL), | 22 kernel_platform_(NULL), |
| 23 kernel_vmservice_io_(NULL) {} | 23 kernel_vmservice_io_(NULL), |
| 24 kernel_file_specified_(false) {} |
| 24 | 25 |
| 25 DFE::~DFE() { | 26 DFE::~DFE() { |
| 26 frontend_filename_ = NULL; | 27 frontend_filename_ = NULL; |
| 27 | 28 |
| 28 if (platform_binary_filename_ != NULL) { | 29 if (platform_binary_filename_ != NULL) { |
| 29 delete platform_binary_filename_; | 30 delete platform_binary_filename_; |
| 30 platform_binary_filename_ = NULL; | 31 platform_binary_filename_ = NULL; |
| 31 } | 32 } |
| 32 | 33 |
| 33 if (kernel_platform_ != NULL) { | 34 if (kernel_platform_ != NULL) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // recompile the script. | 71 // recompile the script. |
| 71 Dart_KernelCompilationResult kresult = Dart_CompileToKernel(url_string); | 72 Dart_KernelCompilationResult kresult = Dart_CompileToKernel(url_string); |
| 72 if (kresult.status != Dart_KernelCompilationStatus_Ok) { | 73 if (kresult.status != Dart_KernelCompilationStatus_Ok) { |
| 73 return Dart_NewApiError(kresult.error); | 74 return Dart_NewApiError(kresult.error); |
| 74 } | 75 } |
| 75 kernel_ir = kresult.kernel; | 76 kernel_ir = kresult.kernel; |
| 76 kernel_ir_size = kresult.kernel_size; | 77 kernel_ir_size = kresult.kernel_size; |
| 77 } | 78 } |
| 78 void* kernel_program = Dart_ReadKernelBinary(kernel_ir, kernel_ir_size); | 79 void* kernel_program = Dart_ReadKernelBinary(kernel_ir, kernel_ir_size); |
| 79 ASSERT(kernel_program != NULL); | 80 ASSERT(kernel_program != NULL); |
| 80 Dart_Handle url = Dart_NewStringFromCString(url_string); | 81 Dart_Handle result = Dart_LoadKernel(kernel_program); |
| 81 Dart_Handle result = Dart_LoadScript( | |
| 82 url, Dart_Null(), reinterpret_cast<Dart_Handle>(kernel_program), 0, 0); | |
| 83 if (Dart_IsError(result)) { | 82 if (Dart_IsError(result)) { |
| 84 return result; | 83 return result; |
| 85 } | 84 } |
| 86 // Finalize loading. This will complete any futures for completed deferred | 85 // Finalize loading. This will complete any futures for completed deferred |
| 87 // loads. | 86 // loads. |
| 88 result = Dart_FinalizeLoading(true); | 87 result = Dart_FinalizeLoading(true); |
| 89 if (Dart_IsError(result)) { | 88 if (Dart_IsError(result)) { |
| 90 return result; | 89 return result; |
| 91 } | 90 } |
| 92 return Dart_Null(); | 91 return Dart_Null(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 *kernel_ir = buffer; | 160 *kernel_ir = buffer; |
| 162 return true; | 161 return true; |
| 163 } | 162 } |
| 164 } | 163 } |
| 165 } | 164 } |
| 166 return false; | 165 return false; |
| 167 } | 166 } |
| 168 | 167 |
| 169 } // namespace bin | 168 } // namespace bin |
| 170 } // namespace dart | 169 } // namespace dart |
| OLD | NEW |