| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 // Value of the --package-root flag. | 53 // Value of the --package-root flag. |
| 54 // (This pointer points into an argv buffer and does not need to be | 54 // (This pointer points into an argv buffer and does not need to be |
| 55 // free'd.) | 55 // free'd.) |
| 56 static const char* package_root = NULL; | 56 static const char* package_root = NULL; |
| 57 | 57 |
| 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 // Global flag that is used to indicate that we want to check function | |
| 63 // fingerprints. | |
| 64 static bool has_check_function_fingerprints = false; | |
| 65 | 62 |
| 66 // 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 |
| 67 // for script that is being run. | 64 // for script that is being run. |
| 68 static bool has_print_script = false; | 65 static bool has_print_script = false; |
| 69 | 66 |
| 70 | 67 |
| 71 // VM Service options. | 68 // VM Service options. |
| 72 static bool start_vm_service = false; | 69 static bool start_vm_service = false; |
| 73 static int vm_service_server_port = -1; | 70 static int vm_service_server_port = -1; |
| 74 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 8181; | 71 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 8181; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 static bool ProcessCompileAllOption(const char* arg) { | 177 static bool ProcessCompileAllOption(const char* arg) { |
| 181 ASSERT(arg != NULL); | 178 ASSERT(arg != NULL); |
| 182 if (*arg != '\0') { | 179 if (*arg != '\0') { |
| 183 return false; | 180 return false; |
| 184 } | 181 } |
| 185 has_compile_all = true; | 182 has_compile_all = true; |
| 186 return true; | 183 return true; |
| 187 } | 184 } |
| 188 | 185 |
| 189 | 186 |
| 190 static bool ProcessFingerprintedFunctions(const char* arg) { | |
| 191 ASSERT(arg != NULL); | |
| 192 if (*arg != '\0') { | |
| 193 return false; | |
| 194 } | |
| 195 has_check_function_fingerprints = true; | |
| 196 return true; | |
| 197 } | |
| 198 | |
| 199 | |
| 200 static bool ProcessDebugOption(const char* port) { | 187 static bool ProcessDebugOption(const char* port) { |
| 201 // TODO(hausner): Add support for specifying an IP address on which | 188 // TODO(hausner): Add support for specifying an IP address on which |
| 202 // the debugger should listen. | 189 // the debugger should listen. |
| 203 ASSERT(port != NULL); | 190 ASSERT(port != NULL); |
| 204 debug_port = -1; | 191 debug_port = -1; |
| 205 if (*port == '\0') { | 192 if (*port == '\0') { |
| 206 debug_port = DEFAULT_DEBUG_PORT; | 193 debug_port = DEFAULT_DEBUG_PORT; |
| 207 } else { | 194 } else { |
| 208 if ((*port == '=') || (*port == ':')) { | 195 if ((*port == '=') || (*port == ':')) { |
| 209 debug_port = atoi(port + 1); | 196 debug_port = atoi(port + 1); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 { "--verbose", ProcessVerboseOption }, | 278 { "--verbose", ProcessVerboseOption }, |
| 292 { "-v", ProcessVerboseOption }, | 279 { "-v", ProcessVerboseOption }, |
| 293 { "--package-root=", ProcessPackageRootOption }, | 280 { "--package-root=", ProcessPackageRootOption }, |
| 294 { "-D", ProcessEnvironmentOption }, | 281 { "-D", ProcessEnvironmentOption }, |
| 295 // VM specific options to the standalone dart program. | 282 // VM specific options to the standalone dart program. |
| 296 { "--break-at=", ProcessBreakpointOption }, | 283 { "--break-at=", ProcessBreakpointOption }, |
| 297 { "--compile_all", ProcessCompileAllOption }, | 284 { "--compile_all", ProcessCompileAllOption }, |
| 298 { "--debug", ProcessDebugOption }, | 285 { "--debug", ProcessDebugOption }, |
| 299 { "--snapshot=", ProcessGenScriptSnapshotOption }, | 286 { "--snapshot=", ProcessGenScriptSnapshotOption }, |
| 300 { "--print-script", ProcessPrintScriptOption }, | 287 { "--print-script", ProcessPrintScriptOption }, |
| 301 { "--check-function-fingerprints", ProcessFingerprintedFunctions }, | |
| 302 { "--enable-vm-service", ProcessEnableVmServiceOption }, | 288 { "--enable-vm-service", ProcessEnableVmServiceOption }, |
| 303 { "--trace-debug-protocol", ProcessTraceDebugProtocolOption }, | 289 { "--trace-debug-protocol", ProcessTraceDebugProtocolOption }, |
| 304 { NULL, NULL } | 290 { NULL, NULL } |
| 305 }; | 291 }; |
| 306 | 292 |
| 307 | 293 |
| 308 static bool ProcessMainOptions(const char* option) { | 294 static bool ProcessMainOptions(const char* option) { |
| 309 int i = 0; | 295 int i = 0; |
| 310 const char* name = main_options[0].option_name; | 296 const char* name = main_options[0].option_name; |
| 311 int option_length = strlen(option); | 297 int option_length = strlen(option); |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); | 891 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); |
| 906 result = Dart_LibraryImportLibrary(builtin_lib, root_lib, Dart_Null()); | 892 result = Dart_LibraryImportLibrary(builtin_lib, root_lib, Dart_Null()); |
| 907 | 893 |
| 908 if (has_compile_all) { | 894 if (has_compile_all) { |
| 909 result = Dart_CompileAll(); | 895 result = Dart_CompileAll(); |
| 910 if (Dart_IsError(result)) { | 896 if (Dart_IsError(result)) { |
| 911 return DartErrorExit(result); | 897 return DartErrorExit(result); |
| 912 } | 898 } |
| 913 } | 899 } |
| 914 | 900 |
| 915 if (has_check_function_fingerprints) { | |
| 916 result = Dart_CheckFunctionFingerprints(); | |
| 917 if (Dart_IsError(result)) { | |
| 918 return DartErrorExit(result); | |
| 919 } | |
| 920 } | |
| 921 | |
| 922 if (Dart_IsNull(root_lib)) { | 901 if (Dart_IsNull(root_lib)) { |
| 923 return ErrorExit(kErrorExitCode, | 902 return ErrorExit(kErrorExitCode, |
| 924 "Unable to find root library for '%s'\n", | 903 "Unable to find root library for '%s'\n", |
| 925 script_name); | 904 script_name); |
| 926 } | 905 } |
| 927 if (has_print_script) { | 906 if (has_print_script) { |
| 928 result = GenerateScriptSource(); | 907 result = GenerateScriptSource(); |
| 929 if (Dart_IsError(result)) { | 908 if (Dart_IsError(result)) { |
| 930 return DartErrorExit(result); | 909 return DartErrorExit(result); |
| 931 } | 910 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 | 994 |
| 1016 return Process::GlobalExitCode(); | 995 return Process::GlobalExitCode(); |
| 1017 } | 996 } |
| 1018 | 997 |
| 1019 } // namespace bin | 998 } // namespace bin |
| 1020 } // namespace dart | 999 } // namespace dart |
| 1021 | 1000 |
| 1022 int main(int argc, char** argv) { | 1001 int main(int argc, char** argv) { |
| 1023 return dart::bin::main(argc, argv); | 1002 return dart::bin::main(argc, argv); |
| 1024 } | 1003 } |
| OLD | NEW |