| 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* ServiceRequestHandler( | 837 static const char* ServiceGetIOHandler( |
| 838 const char* name, | 838 const char* method, |
| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 DartUtils::ReadFile, | 950 DartUtils::ReadFile, |
| 951 DartUtils::WriteFile, | 951 DartUtils::WriteFile, |
| 952 DartUtils::CloseFile, | 952 DartUtils::CloseFile, |
| 953 DartUtils::EntropySource)) { | 953 DartUtils::EntropySource)) { |
| 954 fprintf(stderr, "%s", "VM initialization failed\n"); | 954 fprintf(stderr, "%s", "VM initialization failed\n"); |
| 955 fflush(stderr); | 955 fflush(stderr); |
| 956 exit(kErrorExitCode); | 956 exit(kErrorExitCode); |
| 957 } | 957 } |
| 958 | 958 |
| 959 Dart_RegisterIsolateServiceRequestCallback( | 959 Dart_RegisterIsolateServiceRequestCallback( |
| 960 "io", &ServiceRequestHandler, NULL); | 960 "getIO", &ServiceGetIOHandler, NULL); |
| 961 | 961 |
| 962 // Call CreateIsolateAndSetup which creates an isolate and loads up | 962 // Call CreateIsolateAndSetup which creates an isolate and loads up |
| 963 // the specified application script. | 963 // the specified application script. |
| 964 char* error = NULL; | 964 char* error = NULL; |
| 965 int exit_code = 0; | 965 int exit_code = 0; |
| 966 char* isolate_name = BuildIsolateName(script_name, "main"); | 966 char* isolate_name = BuildIsolateName(script_name, "main"); |
| 967 Dart_Isolate isolate = CreateIsolateAndSetupHelper(script_name, | 967 Dart_Isolate isolate = CreateIsolateAndSetupHelper(script_name, |
| 968 "main", | 968 "main", |
| 969 commandline_package_root, | 969 commandline_package_root, |
| 970 &error, | 970 &error, |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 exit(Process::GlobalExitCode()); | 1094 exit(Process::GlobalExitCode()); |
| 1095 } | 1095 } |
| 1096 | 1096 |
| 1097 } // namespace bin | 1097 } // namespace bin |
| 1098 } // namespace dart | 1098 } // namespace dart |
| 1099 | 1099 |
| 1100 int main(int argc, char** argv) { | 1100 int main(int argc, char** argv) { |
| 1101 dart::bin::main(argc, argv); | 1101 dart::bin::main(argc, argv); |
| 1102 UNREACHABLE(); | 1102 UNREACHABLE(); |
| 1103 } | 1103 } |
| OLD | NEW |