| 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 #include <stdlib.h> | 5 #include <stdlib.h> |
| 6 #include <string.h> | 6 #include <string.h> |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
| 10 | 10 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 // Parse command line arguments. | 211 // Parse command line arguments. |
| 212 if (ParseArguments(argc, | 212 if (ParseArguments(argc, |
| 213 argv, | 213 argv, |
| 214 &vm_options, | 214 &vm_options, |
| 215 &script_name, | 215 &script_name, |
| 216 &dart_options) < 0) { | 216 &dart_options) < 0) { |
| 217 PrintUsage(); | 217 PrintUsage(); |
| 218 return 255; | 218 return 255; |
| 219 } | 219 } |
| 220 | 220 |
| 221 // Initialize the Dart VM. | 221 // Initialize the Dart VM (TODO(asiva) - remove const_cast once |
| 222 // dart API is fixed to take a const char** in Dart_Initialize). |
| 222 Dart_Initialize(vm_options.count(), | 223 Dart_Initialize(vm_options.count(), |
| 223 vm_options.arguments(), | 224 const_cast<char**>(vm_options.arguments()), |
| 224 MainIsolateInitCallback); | 225 MainIsolateInitCallback); |
| 225 | 226 |
| 226 // Create an isolate. As a side effect, MainIsolateInitCallback | 227 // Create an isolate. As a side effect, MainIsolateInitCallback |
| 227 // gets called, which loads the scripts and libraries. | 228 // gets called, which loads the scripts and libraries. |
| 228 char* canonical_script_name = File::GetCanonicalPath(script_name); | 229 char* canonical_script_name = File::GetCanonicalPath(script_name); |
| 229 if (canonical_script_name == NULL) { | 230 if (canonical_script_name == NULL) { |
| 230 fprintf(stderr, "Unable to find '%s'\n", script_name); | 231 fprintf(stderr, "Unable to find '%s'\n", script_name); |
| 231 return 255; // Indicates we encountered an error. | 232 return 255; // Indicates we encountered an error. |
| 232 } | 233 } |
| 233 Dart_Isolate isolate = Dart_CreateIsolate(snapshot_buffer, | 234 Dart_Isolate isolate = Dart_CreateIsolate(snapshot_buffer, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 return 255; // Indicates we encountered an error. | 292 return 255; // Indicates we encountered an error. |
| 292 } | 293 } |
| 293 free(canonical_script_name); | 294 free(canonical_script_name); |
| 294 Dart_ExitScope(); | 295 Dart_ExitScope(); |
| 295 // Dump symbol information for the profiler. | 296 // Dump symbol information for the profiler. |
| 296 DumpPprofSymbolInfo(); | 297 DumpPprofSymbolInfo(); |
| 297 // Shutdown the isolate. | 298 // Shutdown the isolate. |
| 298 Dart_ShutdownIsolate(); | 299 Dart_ShutdownIsolate(); |
| 299 return 0; | 300 return 0; |
| 300 } | 301 } |
| OLD | NEW |