| 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 } | 385 } |
| 386 Dart_Handle result = Dart_ListSetAt(dart_arguments, i, argument_value); | 386 Dart_Handle result = Dart_ListSetAt(dart_arguments, i, argument_value); |
| 387 if (Dart_IsError(result)) { | 387 if (Dart_IsError(result)) { |
| 388 return result; | 388 return result; |
| 389 } | 389 } |
| 390 } | 390 } |
| 391 return dart_arguments; | 391 return dart_arguments; |
| 392 } | 392 } |
| 393 | 393 |
| 394 | 394 |
| 395 static Dart_Handle SetupRuntimeOptions(CommandLineOptions* options) { | |
| 396 Dart_Handle dart_arguments = CreateRuntimeOptions(options); | |
| 397 if (Dart_IsError(dart_arguments)) { | |
| 398 return dart_arguments; | |
| 399 } | |
| 400 Dart_Handle io_lib_url = DartUtils::NewString("dart:io"); | |
| 401 if (Dart_IsError(io_lib_url)) { | |
| 402 return io_lib_url; | |
| 403 } | |
| 404 Dart_Handle io_lib = Dart_LookupLibrary(io_lib_url); | |
| 405 if (Dart_IsError(io_lib)) { | |
| 406 return io_lib; | |
| 407 } | |
| 408 Dart_Handle runtime_options_class_name = DartUtils::NewString("_OptionsImpl"); | |
| 409 if (Dart_IsError(runtime_options_class_name)) { | |
| 410 return runtime_options_class_name; | |
| 411 } | |
| 412 Dart_Handle runtime_options_type = Dart_GetType( | |
| 413 io_lib, runtime_options_class_name, 0, NULL); | |
| 414 if (Dart_IsError(runtime_options_type)) { | |
| 415 return runtime_options_type; | |
| 416 } | |
| 417 Dart_Handle native_name = DartUtils::NewString("_nativeArguments"); | |
| 418 if (Dart_IsError(native_name)) { | |
| 419 return native_name; | |
| 420 } | |
| 421 | |
| 422 return Dart_SetField(runtime_options_type, native_name, dart_arguments); | |
| 423 } | |
| 424 | |
| 425 | |
| 426 #define CHECK_RESULT(result) \ | 395 #define CHECK_RESULT(result) \ |
| 427 if (Dart_IsError(result)) { \ | 396 if (Dart_IsError(result)) { \ |
| 428 *error = strdup(Dart_GetError(result)); \ | 397 *error = strdup(Dart_GetError(result)); \ |
| 429 *is_compile_error = Dart_IsCompilationError(result); \ | 398 *is_compile_error = Dart_IsCompilationError(result); \ |
| 430 Dart_ExitScope(); \ | 399 Dart_ExitScope(); \ |
| 431 Dart_ShutdownIsolate(); \ | 400 Dart_ShutdownIsolate(); \ |
| 432 return NULL; \ | 401 return NULL; \ |
| 433 } \ | 402 } \ |
| 434 | 403 |
| 435 | 404 |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 } | 823 } |
| 855 } | 824 } |
| 856 | 825 |
| 857 if (has_check_function_fingerprints) { | 826 if (has_check_function_fingerprints) { |
| 858 result = Dart_CheckFunctionFingerprints(); | 827 result = Dart_CheckFunctionFingerprints(); |
| 859 if (Dart_IsError(result)) { | 828 if (Dart_IsError(result)) { |
| 860 return DartErrorExit(result); | 829 return DartErrorExit(result); |
| 861 } | 830 } |
| 862 } | 831 } |
| 863 | 832 |
| 864 // Create a dart options object that can be accessed from dart code. | |
| 865 Dart_Handle options_result = SetupRuntimeOptions(&dart_options); | |
| 866 if (Dart_IsError(options_result)) { | |
| 867 return DartErrorExit(options_result); | |
| 868 } | |
| 869 // Lookup the library of the root script. | 833 // Lookup the library of the root script. |
| 870 Dart_Handle library = Dart_RootLibrary(); | 834 Dart_Handle library = Dart_RootLibrary(); |
| 871 if (Dart_IsNull(library)) { | 835 if (Dart_IsNull(library)) { |
| 872 return ErrorExit(kErrorExitCode, | 836 return ErrorExit(kErrorExitCode, |
| 873 "Unable to find root library for '%s'\n", | 837 "Unable to find root library for '%s'\n", |
| 874 script_name); | 838 script_name); |
| 875 } | 839 } |
| 876 // Set debug breakpoint if specified on the command line. | 840 // Set debug breakpoint if specified on the command line. |
| 877 if (breakpoint_at != NULL) { | 841 if (breakpoint_at != NULL) { |
| 878 result = SetBreakpoint(breakpoint_at, library); | 842 result = SetBreakpoint(breakpoint_at, library); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 | 908 |
| 945 return Process::GlobalExitCode(); | 909 return Process::GlobalExitCode(); |
| 946 } | 910 } |
| 947 | 911 |
| 948 } // namespace bin | 912 } // namespace bin |
| 949 } // namespace dart | 913 } // namespace dart |
| 950 | 914 |
| 951 int main(int argc, char** argv) { | 915 int main(int argc, char** argv) { |
| 952 return dart::bin::main(argc, argv); | 916 return dart::bin::main(argc, argv); |
| 953 } | 917 } |
| OLD | NEW |