| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 // Global flag that is used to indicate that we want to compile all the | 59 // Global flag that is used to indicate that we want to compile all the |
| 60 // dart functions and not run anything. | 60 // dart functions and not run anything. |
| 61 static bool has_compile_all = false; | 61 static bool has_compile_all = false; |
| 62 | 62 |
| 63 // Global flag that is used to indicate that we want to print the source code | 63 // Global flag that is used to indicate that we want to print the source code |
| 64 // for script that is being run. | 64 // for script that is being run. |
| 65 static bool has_print_script = false; | 65 static bool has_print_script = false; |
| 66 | 66 |
| 67 | 67 |
| 68 static const char* DEFAULT_VM_SERVICE_SERVER_IP = "127.0.0.1"; |
| 69 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 8181; |
| 68 // VM Service options. | 70 // VM Service options. |
| 69 static bool start_vm_service = false; | 71 static bool start_vm_service = false; |
| 70 static const char *vm_service_server_ip = NULL; | 72 static const char* vm_service_server_ip = DEFAULT_VM_SERVICE_SERVER_IP; |
| 71 static int vm_service_server_port = -1; | 73 // The 0 port is a magic value which results in the first available port |
| 72 static const char *DEFAULT_VM_SERVICE_SERVER_IP = "127.0.0.1"; | 74 // being allocated. |
| 73 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 8181; | 75 static int vm_service_server_port = 0; |
| 74 | 76 |
| 75 // The environment provided through the command line using -D options. | 77 // The environment provided through the command line using -D options. |
| 76 static dart::HashMap* environment = NULL; | 78 static dart::HashMap* environment = NULL; |
| 77 | 79 |
| 78 static bool IsValidFlag(const char* name, | 80 static bool IsValidFlag(const char* name, |
| 79 const char* prefix, | 81 const char* prefix, |
| 80 intptr_t prefix_length) { | 82 intptr_t prefix_length) { |
| 81 intptr_t name_length = strlen(name); | 83 intptr_t name_length = strlen(name); |
| 82 return ((name_length > prefix_length) && | 84 return ((name_length > prefix_length) && |
| 83 (strncmp(name, prefix, prefix_length) == 0)); | 85 (strncmp(name, prefix, prefix_length) == 0)); |
| (...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 | 1009 |
| 1008 // Start event handler. | 1010 // Start event handler. |
| 1009 EventHandler::Start(); | 1011 EventHandler::Start(); |
| 1010 | 1012 |
| 1011 ASSERT(Dart_CurrentIsolate() == NULL); | 1013 ASSERT(Dart_CurrentIsolate() == NULL); |
| 1012 // Start the VM service isolate, if necessary. | 1014 // Start the VM service isolate, if necessary. |
| 1013 if (start_vm_service) { | 1015 if (start_vm_service) { |
| 1014 if (!start_debugger) { | 1016 if (!start_debugger) { |
| 1015 DebuggerConnectionHandler::InitForVmService(); | 1017 DebuggerConnectionHandler::InitForVmService(); |
| 1016 } | 1018 } |
| 1017 ASSERT(vm_service_server_ip != NULL && vm_service_server_port >= 0); | 1019 bool r = VmService::Start(vm_service_server_ip, vm_service_server_port); |
| 1018 bool r = VmService::Start(vm_service_server_ip , vm_service_server_port); | |
| 1019 if (!r) { | 1020 if (!r) { |
| 1020 Log::PrintErr("Could not start VM Service isolate %s\n", | 1021 Log::PrintErr("Could not start VM Service isolate %s\n", |
| 1021 VmService::GetErrorMessage()); | 1022 VmService::GetErrorMessage()); |
| 1022 } | 1023 } |
| 1023 Dart_RegisterIsolateServiceRequestCallback( | 1024 Dart_RegisterIsolateServiceRequestCallback( |
| 1024 "io", &ServiceRequestHandler, NULL); | 1025 "io", &ServiceRequestHandler, NULL); |
| 1025 } | 1026 } |
| 1026 ASSERT(Dart_CurrentIsolate() == NULL); | 1027 ASSERT(Dart_CurrentIsolate() == NULL); |
| 1027 | 1028 |
| 1028 // Call CreateIsolateAndSetup which creates an isolate and loads up | 1029 // Call CreateIsolateAndSetup which creates an isolate and loads up |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 exit(Process::GlobalExitCode()); | 1168 exit(Process::GlobalExitCode()); |
| 1168 } | 1169 } |
| 1169 | 1170 |
| 1170 } // namespace bin | 1171 } // namespace bin |
| 1171 } // namespace dart | 1172 } // namespace dart |
| 1172 | 1173 |
| 1173 int main(int argc, char** argv) { | 1174 int main(int argc, char** argv) { |
| 1174 dart::bin::main(argc, argv); | 1175 dart::bin::main(argc, argv); |
| 1175 UNREACHABLE(); | 1176 UNREACHABLE(); |
| 1176 } | 1177 } |
| OLD | NEW |