OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // Generate a snapshot file after loading all the scripts specified on the | 5 // Generate a snapshot file after loading all the scripts specified on the |
6 // command line. | 6 // command line. |
7 | 7 |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1224 #endif | 1224 #endif |
1225 } | 1225 } |
1226 | 1226 |
1227 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); | 1227 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); |
1228 | 1228 |
1229 // Initialize the Dart VM. | 1229 // Initialize the Dart VM. |
1230 // Note: We don't expect isolates to be created from dart code during | 1230 // Note: We don't expect isolates to be created from dart code during |
1231 // core library snapshot generation. However for the case when a full | 1231 // core library snapshot generation. However for the case when a full |
1232 // snasphot is generated from a script (app_script_name != NULL) we will | 1232 // snasphot is generated from a script (app_script_name != NULL) we will |
1233 // need the service isolate to resolve URI and load code. | 1233 // need the service isolate to resolve URI and load code. |
1234 char* error = Dart_Initialize( | 1234 |
1235 NULL, | 1235 Dart_InitializeParams init_params; |
1236 NULL, | 1236 memset(&init_params, 0, sizeof(init_params)); |
1237 NULL, | 1237 init_params.version = DART_INITIALIZE_PARAMS_CURRENT_VERSION; |
1238 (app_script_name != NULL) ? CreateServiceIsolate : NULL, | 1238 if (app_script_name != NULL) { |
1239 NULL, | 1239 init_params.create = CreateServiceIsolate; |
1240 NULL, | 1240 } |
1241 NULL, | 1241 init_params.file_open = DartUtils::OpenFile; |
1242 NULL, | 1242 init_params.file_read = DartUtils::ReadFile; |
1243 DartUtils::OpenFile, | 1243 init_params.file_write = DartUtils::WriteFile; |
1244 DartUtils::ReadFile, | 1244 init_params.file_close = DartUtils::CloseFile; |
1245 DartUtils::WriteFile, | 1245 init_params.entropy_source = DartUtils::EntropySource; |
1246 DartUtils::CloseFile, | 1246 |
1247 DartUtils::EntropySource, | 1247 char* error = Dart_Initialize(&init_params); |
1248 NULL); | |
1249 if (error != NULL) { | 1248 if (error != NULL) { |
1250 Log::PrintErr("VM initialization failed: %s\n", error); | 1249 Log::PrintErr("VM initialization failed: %s\n", error); |
1251 free(error); | 1250 free(error); |
1252 return 255; | 1251 return 255; |
1253 } | 1252 } |
1254 | 1253 |
1255 IsolateData* isolate_data = new IsolateData(NULL, | 1254 IsolateData* isolate_data = new IsolateData(NULL, |
1256 commandline_package_root, | 1255 commandline_package_root, |
1257 commandline_packages_file); | 1256 commandline_packages_file); |
1258 Dart_Isolate isolate = Dart_CreateIsolate( | 1257 Dart_Isolate isolate = Dart_CreateIsolate( |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1355 EventHandler::Stop(); | 1354 EventHandler::Stop(); |
1356 return 0; | 1355 return 0; |
1357 } | 1356 } |
1358 | 1357 |
1359 } // namespace bin | 1358 } // namespace bin |
1360 } // namespace dart | 1359 } // namespace dart |
1361 | 1360 |
1362 int main(int argc, char** argv) { | 1361 int main(int argc, char** argv) { |
1363 return dart::bin::main(argc, argv); | 1362 return dart::bin::main(argc, argv); |
1364 } | 1363 } |
OLD | NEW |