| 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 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 // Will set the VM flags, print them out and then we exit as no | 712 // Will set the VM flags, print them out and then we exit as no |
| 713 // script was specified on the command line. | 713 // script was specified on the command line. |
| 714 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); | 714 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); |
| 715 return 0; | 715 return 0; |
| 716 } else { | 716 } else { |
| 717 PrintUsage(); | 717 PrintUsage(); |
| 718 return kErrorExitCode; | 718 return kErrorExitCode; |
| 719 } | 719 } |
| 720 } | 720 } |
| 721 | 721 |
| 722 if (!DartUtils::SetOriginalWorkingDirectory()) { |
| 723 OSError err; |
| 724 fprintf(stderr, "Error determinig current directory: %s\n", err.message()); |
| 725 fflush(stderr); |
| 726 return kErrorExitCode; |
| 727 } |
| 728 |
| 722 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); | 729 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); |
| 723 | 730 |
| 724 // Initialize the Dart VM. | 731 // Initialize the Dart VM. |
| 725 if (!Dart_Initialize(CreateIsolateAndSetup, NULL, NULL, ShutdownIsolate, | 732 if (!Dart_Initialize(CreateIsolateAndSetup, NULL, NULL, ShutdownIsolate, |
| 726 DartUtils::OpenFile, | 733 DartUtils::OpenFile, |
| 727 DartUtils::ReadFile, | 734 DartUtils::ReadFile, |
| 728 DartUtils::WriteFile, | 735 DartUtils::WriteFile, |
| 729 DartUtils::CloseFile)) { | 736 DartUtils::CloseFile)) { |
| 730 fprintf(stderr, "%s", "VM initialization failed\n"); | 737 fprintf(stderr, "%s", "VM initialization failed\n"); |
| 731 fflush(stderr); | 738 fflush(stderr); |
| 732 return kErrorExitCode; | 739 return kErrorExitCode; |
| 733 } | 740 } |
| 734 | 741 |
| 735 DartUtils::SetOriginalWorkingDirectory(); | |
| 736 | |
| 737 // Start the debugger wire protocol handler if necessary. | 742 // Start the debugger wire protocol handler if necessary. |
| 738 if (start_debugger) { | 743 if (start_debugger) { |
| 739 ASSERT(debug_port >= 0); | 744 ASSERT(debug_port >= 0); |
| 740 bool print_msg = verbose_debug_seen || (debug_port == 0); | 745 bool print_msg = verbose_debug_seen || (debug_port == 0); |
| 741 debug_port = DebuggerConnectionHandler::StartHandler(debug_ip, debug_port); | 746 debug_port = DebuggerConnectionHandler::StartHandler(debug_ip, debug_port); |
| 742 if (print_msg) { | 747 if (print_msg) { |
| 743 Log::Print("Debugger listening on port %d\n", debug_port); | 748 Log::Print("Debugger listening on port %d\n", debug_port); |
| 744 } | 749 } |
| 745 } | 750 } |
| 746 | 751 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 | 876 |
| 872 return Process::GlobalExitCode(); | 877 return Process::GlobalExitCode(); |
| 873 } | 878 } |
| 874 | 879 |
| 875 } // namespace bin | 880 } // namespace bin |
| 876 } // namespace dart | 881 } // namespace dart |
| 877 | 882 |
| 878 int main(int argc, char** argv) { | 883 int main(int argc, char** argv) { |
| 879 return dart::bin::main(argc, argv); | 884 return dart::bin::main(argc, argv); |
| 880 } | 885 } |
| OLD | NEW |