| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 Dart_EnterScope(); | 163 Dart_EnterScope(); |
| 164 | 164 |
| 165 // Load the specified script. | 165 // Load the specified script. |
| 166 library = LoadScript(script_name); | 166 library = LoadScript(script_name); |
| 167 if (Dart_IsError(library)) { | 167 if (Dart_IsError(library)) { |
| 168 const char* err_msg = Dart_GetError(library); | 168 const char* err_msg = Dart_GetError(library); |
| 169 fprintf(stderr, "Errors encountered while loading script: %s\n", err_msg); | 169 fprintf(stderr, "Errors encountered while loading script: %s\n", err_msg); |
| 170 Dart_ExitScope(); | 170 Dart_ExitScope(); |
| 171 exit(255); | 171 exit(255); |
| 172 } | 172 } |
| 173 | |
| 174 if (!Dart_IsLibrary(library)) { | 173 if (!Dart_IsLibrary(library)) { |
| 175 fprintf(stderr, | 174 fprintf(stderr, |
| 176 "Expected a library when loading script: %s", | 175 "Expected a library when loading script: %s", |
| 177 script_name); | 176 script_name); |
| 178 Dart_ExitScope(); | 177 Dart_ExitScope(); |
| 179 exit(255); | 178 exit(255); |
| 180 } | 179 } |
| 181 Builtin_ImportLibrary(library); | 180 Builtin_ImportLibrary(library); // Import builtin library. |
| 182 // Setup the native resolver for built in library functions. | |
| 183 Builtin_SetNativeResolver(); | |
| 184 | 181 |
| 185 Dart_ExitScope(); | 182 Dart_ExitScope(); |
| 186 return data; | 183 return data; |
| 187 } | 184 } |
| 188 | 185 |
| 189 | 186 |
| 190 static void PrintUsage() { | 187 static void PrintUsage() { |
| 191 fprintf(stderr, | 188 fprintf(stderr, |
| 192 "dart [<vm-flags>] <dart-script-file> [<dart-options>]\n"); | 189 "dart [<vm-flags>] <dart-script-file> [<dart-options>]\n"); |
| 193 } | 190 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 return 255; // Indicates we encountered an error. | 228 return 255; // Indicates we encountered an error. |
| 232 } | 229 } |
| 233 Dart_Isolate isolate = Dart_CreateIsolate(snapshot_buffer, | 230 Dart_Isolate isolate = Dart_CreateIsolate(snapshot_buffer, |
| 234 canonical_script_name); | 231 canonical_script_name); |
| 235 if (isolate == NULL) { | 232 if (isolate == NULL) { |
| 236 free(canonical_script_name); | 233 free(canonical_script_name); |
| 237 return 255; | 234 return 255; |
| 238 } | 235 } |
| 239 | 236 |
| 240 Dart_EnterScope(); | 237 Dart_EnterScope(); |
| 238 |
| 239 if (snapshot_buffer != NULL) { |
| 240 // Setup the native resolver as the snapshot does not carry it. |
| 241 Builtin_SetNativeResolver(); |
| 242 } |
| 243 |
| 241 if (HasCompileAll(vm_options)) { | 244 if (HasCompileAll(vm_options)) { |
| 242 Dart_Handle result = Dart_CompileAll(); | 245 Dart_Handle result = Dart_CompileAll(); |
| 243 if (Dart_IsError(result)) { | 246 if (Dart_IsError(result)) { |
| 244 fprintf(stderr, "%s\n", Dart_GetError(result)); | 247 fprintf(stderr, "%s\n", Dart_GetError(result)); |
| 245 Dart_ExitScope(); | 248 Dart_ExitScope(); |
| 246 Dart_ShutdownIsolate(); | 249 Dart_ShutdownIsolate(); |
| 247 free(canonical_script_name); | 250 free(canonical_script_name); |
| 248 return 255; // Indicates we encountered an error. | 251 return 255; // Indicates we encountered an error. |
| 249 } | 252 } |
| 250 } | 253 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 return 255; // Indicates we encountered an error. | 294 return 255; // Indicates we encountered an error. |
| 292 } | 295 } |
| 293 free(canonical_script_name); | 296 free(canonical_script_name); |
| 294 Dart_ExitScope(); | 297 Dart_ExitScope(); |
| 295 // Dump symbol information for the profiler. | 298 // Dump symbol information for the profiler. |
| 296 DumpPprofSymbolInfo(); | 299 DumpPprofSymbolInfo(); |
| 297 // Shutdown the isolate. | 300 // Shutdown the isolate. |
| 298 Dart_ShutdownIsolate(); | 301 Dart_ShutdownIsolate(); |
| 299 return 0; | 302 return 0; |
| 300 } | 303 } |
| OLD | NEW |