| 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 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 } | 827 } |
| 828 | 828 |
| 829 | 829 |
| 830 class DartScope { | 830 class DartScope { |
| 831 public: | 831 public: |
| 832 DartScope() { Dart_EnterScope(); } | 832 DartScope() { Dart_EnterScope(); } |
| 833 ~DartScope() { Dart_ExitScope(); } | 833 ~DartScope() { Dart_ExitScope(); } |
| 834 }; | 834 }; |
| 835 | 835 |
| 836 | 836 |
| 837 static const char* ServiceGetIOHandler( | 837 static const char* ServiceRequestHandler( |
| 838 const char* method, | 838 const char* name, |
| 839 const char** param_keys, | 839 const char** param_keys, |
| 840 const char** param_values, | 840 const char** param_values, |
| 841 intptr_t num_params, | 841 intptr_t num_params, |
| 842 void* user_data) { | 842 void* user_data) { |
| 843 DartScope scope; | 843 DartScope scope; |
| 844 // TODO(ajohnsen): Store the library/function in isolate data or user_data. | 844 // TODO(ajohnsen): Store the library/function in isolate data or user_data. |
| 845 Dart_Handle dart_io_str = Dart_NewStringFromCString("dart:io"); | 845 Dart_Handle dart_io_str = Dart_NewStringFromCString("dart:io"); |
| 846 if (Dart_IsError(dart_io_str)) return ServiceRequestError(dart_io_str); | 846 if (Dart_IsError(dart_io_str)) return ServiceRequestError(dart_io_str); |
| 847 Dart_Handle io_lib = Dart_LookupLibrary(dart_io_str); | 847 Dart_Handle io_lib = Dart_LookupLibrary(dart_io_str); |
| 848 if (Dart_IsError(io_lib)) return ServiceRequestError(io_lib); | 848 if (Dart_IsError(io_lib)) return ServiceRequestError(io_lib); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 DartUtils::ReadFile, | 945 DartUtils::ReadFile, |
| 946 DartUtils::WriteFile, | 946 DartUtils::WriteFile, |
| 947 DartUtils::CloseFile, | 947 DartUtils::CloseFile, |
| 948 DartUtils::EntropySource)) { | 948 DartUtils::EntropySource)) { |
| 949 fprintf(stderr, "%s", "VM initialization failed\n"); | 949 fprintf(stderr, "%s", "VM initialization failed\n"); |
| 950 fflush(stderr); | 950 fflush(stderr); |
| 951 exit(kErrorExitCode); | 951 exit(kErrorExitCode); |
| 952 } | 952 } |
| 953 | 953 |
| 954 Dart_RegisterIsolateServiceRequestCallback( | 954 Dart_RegisterIsolateServiceRequestCallback( |
| 955 "getIO", &ServiceGetIOHandler, NULL); | 955 "io", &ServiceRequestHandler, NULL); |
| 956 | 956 |
| 957 // Call CreateIsolateAndSetup which creates an isolate and loads up | 957 // Call CreateIsolateAndSetup which creates an isolate and loads up |
| 958 // the specified application script. | 958 // the specified application script. |
| 959 char* error = NULL; | 959 char* error = NULL; |
| 960 int exit_code = 0; | 960 int exit_code = 0; |
| 961 char* isolate_name = BuildIsolateName(script_name, "main"); | 961 char* isolate_name = BuildIsolateName(script_name, "main"); |
| 962 Dart_Isolate isolate = CreateIsolateAndSetupHelper(script_name, | 962 Dart_Isolate isolate = CreateIsolateAndSetupHelper(script_name, |
| 963 "main", | 963 "main", |
| 964 commandline_package_root, | 964 commandline_package_root, |
| 965 &error, | 965 &error, |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 exit(Process::GlobalExitCode()); | 1089 exit(Process::GlobalExitCode()); |
| 1090 } | 1090 } |
| 1091 | 1091 |
| 1092 } // namespace bin | 1092 } // namespace bin |
| 1093 } // namespace dart | 1093 } // namespace dart |
| 1094 | 1094 |
| 1095 int main(int argc, char** argv) { | 1095 int main(int argc, char** argv) { |
| 1096 dart::bin::main(argc, argv); | 1096 dart::bin::main(argc, argv); |
| 1097 UNREACHABLE(); | 1097 UNREACHABLE(); |
| 1098 } | 1098 } |
| OLD | NEW |