| 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 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 // Parse out options to be passed to dart main. | 597 // Parse out options to be passed to dart main. |
| 598 while (i < argc) { | 598 while (i < argc) { |
| 599 dart_options->AddArgument(argv[i]); | 599 dart_options->AddArgument(argv[i]); |
| 600 i++; | 600 i++; |
| 601 } | 601 } |
| 602 | 602 |
| 603 // Verify consistency of arguments. | 603 // Verify consistency of arguments. |
| 604 if ((commandline_package_root != NULL) && | 604 if ((commandline_package_root != NULL) && |
| 605 (commandline_packages_file != NULL)) { | 605 (commandline_packages_file != NULL)) { |
| 606 Log::PrintErr("Specifying both a packages directory and a packages " | 606 Log::PrintErr("Specifying both a packages directory and a packages " |
| 607 "file is invalid."); | 607 "file is invalid.\n"); |
| 608 return -1; |
| 609 } |
| 610 if (has_noopt) { |
| 611 if (has_gen_precompiled_snapshot) { |
| 612 Log::PrintErr("Specifying --noopt and --gen_precompiled_snapshot" |
| 613 " is invalid.\n"); |
| 614 return -1; |
| 615 } |
| 616 if (has_run_precompiled_snapshot) { |
| 617 Log::PrintErr("Specifying --noopt and --run_precompiled_snapshot" |
| 618 " is invalid.\n"); |
| 619 return -1; |
| 620 } |
| 621 } |
| 622 if (has_gen_precompiled_snapshot && has_run_precompiled_snapshot) { |
| 623 Log::PrintErr("Specifying --gen_precompiled_snapshot and" |
| 624 " --run_precompiled_snapshot is invalid.\n"); |
| 608 return -1; | 625 return -1; |
| 609 } | 626 } |
| 610 | 627 |
| 611 return 0; | 628 return 0; |
| 612 } | 629 } |
| 613 | 630 |
| 614 | 631 |
| 615 static Dart_Handle CreateRuntimeOptions(CommandLineOptions* options) { | 632 static Dart_Handle CreateRuntimeOptions(CommandLineOptions* options) { |
| 616 int options_count = options->count(); | 633 int options_count = options->count(); |
| 617 Dart_Handle dart_arguments = Dart_NewList(options_count); | 634 Dart_Handle dart_arguments = Dart_NewList(options_count); |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 // be included in the precompiled snapshot. | 1217 // be included in the precompiled snapshot. |
| 1201 if (!VmService::LoadForGenPrecompiled()) { | 1218 if (!VmService::LoadForGenPrecompiled()) { |
| 1202 fprintf(stderr, | 1219 fprintf(stderr, |
| 1203 "VM service loading failed: %s\n", | 1220 "VM service loading failed: %s\n", |
| 1204 VmService::GetErrorMessage()); | 1221 VmService::GetErrorMessage()); |
| 1205 fflush(stderr); | 1222 fflush(stderr); |
| 1206 exit(kErrorExitCode); | 1223 exit(kErrorExitCode); |
| 1207 } | 1224 } |
| 1208 } | 1225 } |
| 1209 | 1226 |
| 1227 if (has_compile_all) { |
| 1228 result = Dart_CompileAll(); |
| 1229 CHECK_RESULT(result); |
| 1230 } |
| 1231 |
| 1210 if (has_noopt || has_gen_precompiled_snapshot) { | 1232 if (has_noopt || has_gen_precompiled_snapshot) { |
| 1211 Dart_QualifiedFunctionName standalone_entry_points[] = { | 1233 Dart_QualifiedFunctionName standalone_entry_points[] = { |
| 1212 { "dart:_builtin", "::", "_getMainClosure" }, | 1234 { "dart:_builtin", "::", "_getMainClosure" }, |
| 1213 { "dart:_builtin", "::", "_getPrintClosure" }, | 1235 { "dart:_builtin", "::", "_getPrintClosure" }, |
| 1214 { "dart:_builtin", "::", "_getUriBaseClosure" }, | 1236 { "dart:_builtin", "::", "_getUriBaseClosure" }, |
| 1215 { "dart:_builtin", "::", "_resolveUri" }, | 1237 { "dart:_builtin", "::", "_resolveUri" }, |
| 1216 { "dart:_builtin", "::", "_setWorkingDirectory" }, | 1238 { "dart:_builtin", "::", "_setWorkingDirectory" }, |
| 1217 { "dart:_builtin", "::", "_setPackageRoot" }, | 1239 { "dart:_builtin", "::", "_setPackageRoot" }, |
| 1218 { "dart:_builtin", "::", "_addPackageMapEntry" }, | 1240 { "dart:_builtin", "::", "_addPackageMapEntry" }, |
| 1219 { "dart:_builtin", "::", "_loadPackagesMap" }, | 1241 { "dart:_builtin", "::", "_loadPackagesMap" }, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1260 WritePrecompiledSnapshotFile(kPrecompiledVmIsolateName, | 1282 WritePrecompiledSnapshotFile(kPrecompiledVmIsolateName, |
| 1261 vm_isolate_buffer, | 1283 vm_isolate_buffer, |
| 1262 vm_isolate_size); | 1284 vm_isolate_size); |
| 1263 WritePrecompiledSnapshotFile(kPrecompiledIsolateName, | 1285 WritePrecompiledSnapshotFile(kPrecompiledIsolateName, |
| 1264 isolate_buffer, | 1286 isolate_buffer, |
| 1265 isolate_size); | 1287 isolate_size); |
| 1266 WritePrecompiledSnapshotFile(kPrecompiledInstructionsName, | 1288 WritePrecompiledSnapshotFile(kPrecompiledInstructionsName, |
| 1267 instructions_buffer, | 1289 instructions_buffer, |
| 1268 instructions_size); | 1290 instructions_size); |
| 1269 } else { | 1291 } else { |
| 1270 if (has_compile_all) { | |
| 1271 result = Dart_CompileAll(); | |
| 1272 CHECK_RESULT(result); | |
| 1273 } | |
| 1274 | |
| 1275 if (Dart_IsNull(root_lib)) { | 1292 if (Dart_IsNull(root_lib)) { |
| 1276 ErrorExit(kErrorExitCode, | 1293 ErrorExit(kErrorExitCode, |
| 1277 "Unable to find root library for '%s'\n", | 1294 "Unable to find root library for '%s'\n", |
| 1278 script_name); | 1295 script_name); |
| 1279 } | 1296 } |
| 1280 | 1297 |
| 1281 // The helper function _getMainClosure creates a closure for the main | 1298 // The helper function _getMainClosure creates a closure for the main |
| 1282 // entry point which is either explicitly or implictly exported from the | 1299 // entry point which is either explicitly or implictly exported from the |
| 1283 // root library. | 1300 // root library. |
| 1284 Dart_Handle main_closure = Dart_Invoke(builtin_lib, | 1301 Dart_Handle main_closure = Dart_Invoke(builtin_lib, |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1536 Platform::Exit(Process::GlobalExitCode()); | 1553 Platform::Exit(Process::GlobalExitCode()); |
| 1537 } | 1554 } |
| 1538 | 1555 |
| 1539 } // namespace bin | 1556 } // namespace bin |
| 1540 } // namespace dart | 1557 } // namespace dart |
| 1541 | 1558 |
| 1542 int main(int argc, char** argv) { | 1559 int main(int argc, char** argv) { |
| 1543 dart::bin::main(argc, argv); | 1560 dart::bin::main(argc, argv); |
| 1544 UNREACHABLE(); | 1561 UNREACHABLE(); |
| 1545 } | 1562 } |
| OLD | NEW |