| 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_tools_api.h" | 10 #include "include/dart_tools_api.h" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 return false; | 211 return false; |
| 212 } | 212 } |
| 213 commandline_package_root = arg; | 213 commandline_package_root = arg; |
| 214 return true; | 214 return true; |
| 215 } | 215 } |
| 216 | 216 |
| 217 | 217 |
| 218 static bool ProcessPackagesOption(const char* arg, | 218 static bool ProcessPackagesOption(const char* arg, |
| 219 CommandLineOptions* vm_options) { | 219 CommandLineOptions* vm_options) { |
| 220 ASSERT(arg != NULL); | 220 ASSERT(arg != NULL); |
| 221 if (*arg == '\0' || *arg == '-') { | 221 if ((*arg == '\0') || (*arg == '-')) { |
| 222 return false; | 222 return false; |
| 223 } | 223 } |
| 224 commandline_packages_file = arg; | 224 commandline_packages_file = arg; |
| 225 return true; | 225 return true; |
| 226 } | 226 } |
| 227 | 227 |
| 228 | 228 |
| 229 static void* GetHashmapKeyFromString(char* key) { | 229 static void* GetHashmapKeyFromString(char* key) { |
| 230 return reinterpret_cast<void*>(key); | 230 return reinterpret_cast<void*>(key); |
| 231 } | 231 } |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 } | 1069 } |
| 1070 | 1070 |
| 1071 | 1071 |
| 1072 static void WriteSnapshotFile(const char* snapshot_directory, | 1072 static void WriteSnapshotFile(const char* snapshot_directory, |
| 1073 const char* filename, | 1073 const char* filename, |
| 1074 bool write_magic_number, | 1074 bool write_magic_number, |
| 1075 const uint8_t* buffer, | 1075 const uint8_t* buffer, |
| 1076 const intptr_t size) { | 1076 const intptr_t size) { |
| 1077 char* concat = NULL; | 1077 char* concat = NULL; |
| 1078 const char* qualified_filename; | 1078 const char* qualified_filename; |
| 1079 if ((snapshot_directory != NULL) && strlen(snapshot_directory) > 0) { | 1079 if ((snapshot_directory != NULL) && (strlen(snapshot_directory) > 0)) { |
| 1080 intptr_t len = snprintf(NULL, 0, "%s/%s", snapshot_directory, filename); | 1080 intptr_t len = snprintf(NULL, 0, "%s/%s", snapshot_directory, filename); |
| 1081 concat = new char[len + 1]; | 1081 concat = new char[len + 1]; |
| 1082 snprintf(concat, len + 1, "%s/%s", snapshot_directory, filename); | 1082 snprintf(concat, len + 1, "%s/%s", snapshot_directory, filename); |
| 1083 qualified_filename = concat; | 1083 qualified_filename = concat; |
| 1084 } else { | 1084 } else { |
| 1085 qualified_filename = filename; | 1085 qualified_filename = filename; |
| 1086 } | 1086 } |
| 1087 | 1087 |
| 1088 File* file = File::Open(qualified_filename, File::kWriteTruncate); | 1088 File* file = File::Open(qualified_filename, File::kWriteTruncate); |
| 1089 ASSERT(file != NULL); | 1089 ASSERT(file != NULL); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1103 delete concat; | 1103 delete concat; |
| 1104 } | 1104 } |
| 1105 } | 1105 } |
| 1106 | 1106 |
| 1107 | 1107 |
| 1108 static void ReadSnapshotFile(const char* snapshot_directory, | 1108 static void ReadSnapshotFile(const char* snapshot_directory, |
| 1109 const char* filename, | 1109 const char* filename, |
| 1110 const uint8_t** buffer) { | 1110 const uint8_t** buffer) { |
| 1111 char* concat = NULL; | 1111 char* concat = NULL; |
| 1112 const char* qualified_filename; | 1112 const char* qualified_filename; |
| 1113 if ((snapshot_directory != NULL) && strlen(snapshot_directory) > 0) { | 1113 if ((snapshot_directory != NULL) && (strlen(snapshot_directory) > 0)) { |
| 1114 intptr_t len = snprintf(NULL, 0, "%s/%s", snapshot_directory, filename); | 1114 intptr_t len = snprintf(NULL, 0, "%s/%s", snapshot_directory, filename); |
| 1115 concat = new char[len + 1]; | 1115 concat = new char[len + 1]; |
| 1116 snprintf(concat, len + 1, "%s/%s", snapshot_directory, filename); | 1116 snprintf(concat, len + 1, "%s/%s", snapshot_directory, filename); |
| 1117 qualified_filename = concat; | 1117 qualified_filename = concat; |
| 1118 } else { | 1118 } else { |
| 1119 qualified_filename = filename; | 1119 qualified_filename = filename; |
| 1120 } | 1120 } |
| 1121 | 1121 |
| 1122 void* file = DartUtils::OpenFile(qualified_filename, false); | 1122 void* file = DartUtils::OpenFile(qualified_filename, false); |
| 1123 if (file == NULL) { | 1123 if (file == NULL) { |
| 1124 fprintf(stderr, | 1124 fprintf(stderr, |
| 1125 "Error: Unable to open file %s for reading snapshot\n", | 1125 "Error: Unable to open file %s for reading snapshot\n", |
| 1126 qualified_filename); | 1126 qualified_filename); |
| 1127 fflush(stderr); | 1127 fflush(stderr); |
| 1128 Platform::Exit(kErrorExitCode); | 1128 Platform::Exit(kErrorExitCode); |
| 1129 } | 1129 } |
| 1130 intptr_t len = -1; | 1130 intptr_t len = -1; |
| 1131 DartUtils::ReadFile(buffer, &len, file); | 1131 DartUtils::ReadFile(buffer, &len, file); |
| 1132 if (*buffer == NULL || len == -1) { | 1132 if ((*buffer == NULL) || (len == -1)) { |
| 1133 fprintf(stderr, | 1133 fprintf(stderr, |
| 1134 "Error: Unable to read snapshot file %s\n", qualified_filename); | 1134 "Error: Unable to read snapshot file %s\n", qualified_filename); |
| 1135 fflush(stderr); | 1135 fflush(stderr); |
| 1136 Platform::Exit(kErrorExitCode); | 1136 Platform::Exit(kErrorExitCode); |
| 1137 } | 1137 } |
| 1138 DartUtils::CloseFile(file); | 1138 DartUtils::CloseFile(file); |
| 1139 if (concat != NULL) { | 1139 if (concat != NULL) { |
| 1140 delete concat; | 1140 delete concat; |
| 1141 } | 1141 } |
| 1142 } | 1142 } |
| 1143 | 1143 |
| 1144 | 1144 |
| 1145 static void* LoadLibrarySymbol(const char* snapshot_directory, | 1145 static void* LoadLibrarySymbol(const char* snapshot_directory, |
| 1146 const char* libname, | 1146 const char* libname, |
| 1147 const char* symname) { | 1147 const char* symname) { |
| 1148 char* concat = NULL; | 1148 char* concat = NULL; |
| 1149 const char* qualified_libname; | 1149 const char* qualified_libname; |
| 1150 if ((snapshot_directory != NULL) && strlen(snapshot_directory) > 0) { | 1150 if ((snapshot_directory != NULL) && (strlen(snapshot_directory) > 0)) { |
| 1151 intptr_t len = snprintf(NULL, 0, "%s/%s", snapshot_directory, libname); | 1151 intptr_t len = snprintf(NULL, 0, "%s/%s", snapshot_directory, libname); |
| 1152 concat = new char[len + 1]; | 1152 concat = new char[len + 1]; |
| 1153 snprintf(concat, len + 1, "%s/%s", snapshot_directory, libname); | 1153 snprintf(concat, len + 1, "%s/%s", snapshot_directory, libname); |
| 1154 qualified_libname = concat; | 1154 qualified_libname = concat; |
| 1155 } else { | 1155 } else { |
| 1156 qualified_libname = libname; | 1156 qualified_libname = libname; |
| 1157 } | 1157 } |
| 1158 void* library = Extensions::LoadExtensionLibrary(qualified_libname); | 1158 void* library = Extensions::LoadExtensionLibrary(qualified_libname); |
| 1159 if (library == NULL) { | 1159 if (library == NULL) { |
| 1160 Log::PrintErr("Error: Failed to load library '%s'\n", qualified_libname); | 1160 Log::PrintErr("Error: Failed to load library '%s'\n", qualified_libname); |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1694 Platform::Exit(Process::GlobalExitCode()); | 1694 Platform::Exit(Process::GlobalExitCode()); |
| 1695 } | 1695 } |
| 1696 | 1696 |
| 1697 } // namespace bin | 1697 } // namespace bin |
| 1698 } // namespace dart | 1698 } // namespace dart |
| 1699 | 1699 |
| 1700 int main(int argc, char** argv) { | 1700 int main(int argc, char** argv) { |
| 1701 dart::bin::main(argc, argv); | 1701 dart::bin::main(argc, argv); |
| 1702 UNREACHABLE(); | 1702 UNREACHABLE(); |
| 1703 } | 1703 } |
| OLD | NEW |