| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 // Value of the --package-root flag. | 54 // Value of the --package-root flag. |
| 55 // (This pointer points into an argv buffer and does not need to be | 55 // (This pointer points into an argv buffer and does not need to be |
| 56 // free'd.) | 56 // free'd.) |
| 57 static const char* package_root = NULL; | 57 static const char* package_root = NULL; |
| 58 | 58 |
| 59 | 59 |
| 60 // Global flag that is used to indicate that we want to compile all the | 60 // Global flag that is used to indicate that we want to compile all the |
| 61 // dart functions and not run anything. | 61 // dart functions and not run anything. |
| 62 static bool has_compile_all = false; | 62 static bool has_compile_all = false; |
| 63 | 63 // Global flag that is used to indicate that we want to check function |
| 64 // fingerprints. |
| 65 static bool has_check_function_fingerprints = false; |
| 64 | 66 |
| 65 // Global flag that is used to indicate that we want to print the source code | 67 // Global flag that is used to indicate that we want to print the source code |
| 66 // for script that is being run. | 68 // for script that is being run. |
| 67 static bool has_print_script = false; | 69 static bool has_print_script = false; |
| 68 | 70 |
| 69 | 71 |
| 70 static bool IsValidFlag(const char* name, | 72 static bool IsValidFlag(const char* name, |
| 71 const char* prefix, | 73 const char* prefix, |
| 72 intptr_t prefix_length) { | 74 intptr_t prefix_length) { |
| 73 intptr_t name_length = strlen(name); | 75 intptr_t name_length = strlen(name); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 static bool ProcessCompileAllOption(const char* arg) { | 125 static bool ProcessCompileAllOption(const char* arg) { |
| 124 ASSERT(arg != NULL); | 126 ASSERT(arg != NULL); |
| 125 if (*arg != '\0') { | 127 if (*arg != '\0') { |
| 126 return false; | 128 return false; |
| 127 } | 129 } |
| 128 has_compile_all = true; | 130 has_compile_all = true; |
| 129 return true; | 131 return true; |
| 130 } | 132 } |
| 131 | 133 |
| 132 | 134 |
| 135 static bool ProcessFingerprintedFunctions(const char* arg) { |
| 136 ASSERT(arg != NULL); |
| 137 if (*arg != '\0') { |
| 138 return false; |
| 139 } |
| 140 has_check_function_fingerprints = true; |
| 141 return true; |
| 142 } |
| 143 |
| 144 |
| 133 static bool ProcessDebugOption(const char* port) { | 145 static bool ProcessDebugOption(const char* port) { |
| 134 // TODO(hausner): Add support for specifying an IP address on which | 146 // TODO(hausner): Add support for specifying an IP address on which |
| 135 // the debugger should listen. | 147 // the debugger should listen. |
| 136 ASSERT(port != NULL); | 148 ASSERT(port != NULL); |
| 137 debug_port = 0; | 149 debug_port = 0; |
| 138 if (*port == '\0') { | 150 if (*port == '\0') { |
| 139 debug_port = DEFAULT_DEBUG_PORT; | 151 debug_port = DEFAULT_DEBUG_PORT; |
| 140 } else { | 152 } else { |
| 141 if ((*port == '=') || (*port == ':')) { | 153 if ((*port == '=') || (*port == ':')) { |
| 142 debug_port = atoi(port + 1); | 154 debug_port = atoi(port + 1); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 { "--package-root=", ProcessPackageRootOption }, | 233 { "--package-root=", ProcessPackageRootOption }, |
| 222 { "-p", ProcessPackageRootOption }, | 234 { "-p", ProcessPackageRootOption }, |
| 223 // VM specific options to the standalone dart program. | 235 // VM specific options to the standalone dart program. |
| 224 { "--break_at=", ProcessBreakpointOption }, | 236 { "--break_at=", ProcessBreakpointOption }, |
| 225 { "--compile_all", ProcessCompileAllOption }, | 237 { "--compile_all", ProcessCompileAllOption }, |
| 226 { "--debug", ProcessDebugOption }, | 238 { "--debug", ProcessDebugOption }, |
| 227 { "--generate-script-snapshot=", ProcessGenScriptSnapshotOption }, | 239 { "--generate-script-snapshot=", ProcessGenScriptSnapshotOption }, |
| 228 { "--stats-root=", ProcessVmStatsRootOption }, | 240 { "--stats-root=", ProcessVmStatsRootOption }, |
| 229 { "--stats", ProcessVmStatsOption }, | 241 { "--stats", ProcessVmStatsOption }, |
| 230 { "--print-script", ProcessPrintScriptOption }, | 242 { "--print-script", ProcessPrintScriptOption }, |
| 243 { "--check-function-fingerprints", ProcessFingerprintedFunctions }, |
| 231 { NULL, NULL } | 244 { NULL, NULL } |
| 232 }; | 245 }; |
| 233 | 246 |
| 234 | 247 |
| 235 static bool ProcessMainOptions(const char* option) { | 248 static bool ProcessMainOptions(const char* option) { |
| 236 int i = 0; | 249 int i = 0; |
| 237 const char* name = main_options[0].option_name; | 250 const char* name = main_options[0].option_name; |
| 238 while (name != NULL) { | 251 while (name != NULL) { |
| 239 int length = strlen(name); | 252 int length = strlen(name); |
| 240 if (strncmp(option, name, length) == 0) { | 253 if (strncmp(option, name, length) == 0) { |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 ASSERT(bytes_written); | 792 ASSERT(bytes_written); |
| 780 delete snapshot_file; | 793 delete snapshot_file; |
| 781 } else { | 794 } else { |
| 782 if (has_compile_all) { | 795 if (has_compile_all) { |
| 783 result = Dart_CompileAll(); | 796 result = Dart_CompileAll(); |
| 784 if (Dart_IsError(result)) { | 797 if (Dart_IsError(result)) { |
| 785 return ErrorExit("%s\n", Dart_GetError(result)); | 798 return ErrorExit("%s\n", Dart_GetError(result)); |
| 786 } | 799 } |
| 787 } | 800 } |
| 788 | 801 |
| 802 if (has_check_function_fingerprints) { |
| 803 result = Dart_CheckFunctionFingerprints(); |
| 804 if (Dart_IsError(result)) { |
| 805 return ErrorExit("%s\n", Dart_GetError(result)); |
| 806 } |
| 807 } |
| 808 |
| 789 // Create a dart options object that can be accessed from dart code. | 809 // Create a dart options object that can be accessed from dart code. |
| 790 Dart_Handle options_result = | 810 Dart_Handle options_result = |
| 791 SetupRuntimeOptions(&dart_options, executable_name, script_name); | 811 SetupRuntimeOptions(&dart_options, executable_name, script_name); |
| 792 if (Dart_IsError(options_result)) { | 812 if (Dart_IsError(options_result)) { |
| 793 return ErrorExit("%s\n", Dart_GetError(options_result)); | 813 return ErrorExit("%s\n", Dart_GetError(options_result)); |
| 794 } | 814 } |
| 795 // Lookup the library of the root script. | 815 // Lookup the library of the root script. |
| 796 Dart_Handle library = Dart_RootLibrary(); | 816 Dart_Handle library = Dart_RootLibrary(); |
| 797 if (Dart_IsNull(library)) { | 817 if (Dart_IsNull(library)) { |
| 798 return ErrorExit("Unable to find root library for '%s'\n", | 818 return ErrorExit("Unable to find root library for '%s'\n", |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 Dart_ShutdownIsolate(); | 855 Dart_ShutdownIsolate(); |
| 836 // Terminate process exit-code handler. | 856 // Terminate process exit-code handler. |
| 837 Process::TerminateExitCodeHandler(); | 857 Process::TerminateExitCodeHandler(); |
| 838 // Free copied argument strings if converted. | 858 // Free copied argument strings if converted. |
| 839 if (argv_converted) { | 859 if (argv_converted) { |
| 840 for (int i = 0; i < argc; i++) free(argv[i]); | 860 for (int i = 0; i < argc; i++) free(argv[i]); |
| 841 } | 861 } |
| 842 | 862 |
| 843 return Process::GlobalExitCode(); | 863 return Process::GlobalExitCode(); |
| 844 } | 864 } |
| OLD | NEW |