| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #include "include/dart_debugger_api.h" | 10 #include "include/dart_debugger_api.h" |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 Dart_EnterScope(); | 384 Dart_EnterScope(); |
| 385 | 385 |
| 386 if (snapshot_buffer != NULL) { | 386 if (snapshot_buffer != NULL) { |
| 387 // Setup the native resolver as the snapshot does not carry it. | 387 // Setup the native resolver as the snapshot does not carry it. |
| 388 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); | 388 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); |
| 389 Builtin::SetNativeResolver(Builtin::kIOLibrary); | 389 Builtin::SetNativeResolver(Builtin::kIOLibrary); |
| 390 } | 390 } |
| 391 | 391 |
| 392 // Prepare builtin and its dependent libraries for use to resolve URIs. | 392 // Prepare builtin and its dependent libraries for use to resolve URIs. |
| 393 Dart_Handle uri_lib = Builtin::LoadLibrary(Builtin::kUriLibrary); | 393 Dart_Handle uri_lib = Builtin::LoadLibrary(Builtin::kUriLibrary); |
| 394 if (Dart_IsError(uri_lib)) { |
| 395 *error = strdup(Dart_GetError(uri_lib)); |
| 396 return false; |
| 397 } |
| 394 Dart_Handle builtin_lib = Builtin::LoadLibrary(Builtin::kBuiltinLibrary); | 398 Dart_Handle builtin_lib = Builtin::LoadLibrary(Builtin::kBuiltinLibrary); |
| 395 Dart_LibraryImportLibrary(builtin_lib, uri_lib); | 399 if (Dart_IsError(builtin_lib)) { |
| 400 *error = strdup(Dart_GetError(builtin_lib)); |
| 401 return false; |
| 402 } |
| 403 Dart_Handle library = Dart_LibraryImportLibrary(builtin_lib, uri_lib); |
| 404 if (Dart_IsError(library)) { |
| 405 *error = strdup(Dart_GetError(library)); |
| 406 return false; |
| 407 } |
| 396 | 408 |
| 397 // Load the specified application script into the newly created isolate. | 409 // Load the specified application script into the newly created isolate. |
| 398 Dart_Handle library = LoadScript(builtin_lib, import_map_options); | 410 library = LoadScript(builtin_lib, import_map_options); |
| 399 if (Dart_IsError(library)) { | 411 if (Dart_IsError(library)) { |
| 400 *error = strdup(Dart_GetError(library)); | 412 *error = strdup(Dart_GetError(library)); |
| 401 Dart_ExitScope(); | 413 Dart_ExitScope(); |
| 402 Dart_ShutdownIsolate(); | 414 Dart_ShutdownIsolate(); |
| 403 return false; | 415 return false; |
| 404 } | 416 } |
| 405 if (!Dart_IsLibrary(library)) { | 417 if (!Dart_IsLibrary(library)) { |
| 406 char errbuf[256]; | 418 char errbuf[256]; |
| 407 snprintf(errbuf, sizeof(errbuf), | 419 snprintf(errbuf, sizeof(errbuf), |
| 408 "Expected a library when loading script: %s", | 420 "Expected a library when loading script: %s", |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 EventHandler::Terminate(); | 614 EventHandler::Terminate(); |
| 603 // Terminate process exit-code handler. | 615 // Terminate process exit-code handler. |
| 604 Process::TerminateExitCodeHandler(); | 616 Process::TerminateExitCodeHandler(); |
| 605 | 617 |
| 606 free(const_cast<char*>(original_script_name)); | 618 free(const_cast<char*>(original_script_name)); |
| 607 free(const_cast<char*>(original_working_directory)); | 619 free(const_cast<char*>(original_working_directory)); |
| 608 free(const_cast<char*>(original_script_url)); | 620 free(const_cast<char*>(original_script_url)); |
| 609 | 621 |
| 610 return 0; | 622 return 0; |
| 611 } | 623 } |
| OLD | NEW |