| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 &script_name) < 0) { | 247 &script_name) < 0) { |
| 248 PrintUsage(); | 248 PrintUsage(); |
| 249 return 255; | 249 return 255; |
| 250 } | 250 } |
| 251 | 251 |
| 252 if (snapshot_filename == NULL) { | 252 if (snapshot_filename == NULL) { |
| 253 fprintf(stderr, "No snapshot output file specified\n"); | 253 fprintf(stderr, "No snapshot output file specified\n"); |
| 254 return 255; | 254 return 255; |
| 255 } | 255 } |
| 256 | 256 |
| 257 // Initialize the Dart VM (TODO(asiva) - remove const_cast once | 257 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); |
| 258 // dart API is fixed to take a const char** in Dart_Initialize). | 258 Dart_Initialize(SnapshotCreateCallback); |
| 259 Dart_Initialize(vm_options.count(), | |
| 260 vm_options.arguments(), | |
| 261 SnapshotCreateCallback); | |
| 262 | 259 |
| 263 // Create an isolate. As a side effect, SnapshotCreateCallback | 260 // Create an isolate. As a side effect, SnapshotCreateCallback |
| 264 // gets called, which loads the script (if one is specified), its libraries | 261 // gets called, which loads the script (if one is specified), its libraries |
| 265 // and writes out a snapshot. | 262 // and writes out a snapshot. |
| 266 Dart_Isolate isolate = Dart_CreateIsolate(NULL, script_name); | 263 Dart_Isolate isolate = Dart_CreateIsolate(NULL, script_name); |
| 267 if (isolate == NULL) { | 264 if (isolate == NULL) { |
| 268 return 255; | 265 return 255; |
| 269 } | 266 } |
| 270 | 267 |
| 271 // Shutdown the isolate. | 268 // Shutdown the isolate. |
| 272 Dart_ShutdownIsolate(); | 269 Dart_ShutdownIsolate(); |
| 273 return 0; | 270 return 0; |
| 274 } | 271 } |
| OLD | NEW |