| 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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 | 622 |
| 623 | 623 |
| 624 static const int kErrorExitCode = 255; // Indicates we encountered an error. | 624 static const int kErrorExitCode = 255; // Indicates we encountered an error. |
| 625 | 625 |
| 626 | 626 |
| 627 static int ErrorExit(const char* format, ...) { | 627 static int ErrorExit(const char* format, ...) { |
| 628 va_list arguments; | 628 va_list arguments; |
| 629 va_start(arguments, format); | 629 va_start(arguments, format); |
| 630 Log::VPrintErr(format, arguments); | 630 Log::VPrintErr(format, arguments); |
| 631 va_end(arguments); | 631 va_end(arguments); |
| 632 fflush(stderr); |
| 632 | 633 |
| 633 Dart_ExitScope(); | 634 Dart_ExitScope(); |
| 634 Dart_ShutdownIsolate(); | 635 Dart_ShutdownIsolate(); |
| 635 | 636 |
| 636 return kErrorExitCode; | 637 return kErrorExitCode; |
| 637 } | 638 } |
| 638 | 639 |
| 639 | 640 |
| 640 static void ShutdownIsolate(void* callback_data) { | 641 static void ShutdownIsolate(void* callback_data) { |
| 641 IsolateData* isolate_data = reinterpret_cast<IsolateData*>(callback_data); | 642 IsolateData* isolate_data = reinterpret_cast<IsolateData*>(callback_data); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 return kErrorExitCode; | 686 return kErrorExitCode; |
| 686 } | 687 } |
| 687 } | 688 } |
| 688 | 689 |
| 689 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); | 690 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); |
| 690 | 691 |
| 691 // Initialize the Dart VM. | 692 // Initialize the Dart VM. |
| 692 if (!Dart_Initialize(CreateIsolateAndSetup, | 693 if (!Dart_Initialize(CreateIsolateAndSetup, |
| 693 NULL, | 694 NULL, |
| 694 ShutdownIsolate)) { | 695 ShutdownIsolate)) { |
| 695 return ErrorExit("VM initialization failed\n"); | 696 fprintf(stderr, "%s", "VM initialization failed\n"); |
| 697 fflush(stderr); |
| 698 return kErrorExitCode; |
| 696 } | 699 } |
| 697 | 700 |
| 698 DartUtils::SetOriginalWorkingDirectory(); | 701 DartUtils::SetOriginalWorkingDirectory(); |
| 699 | 702 |
| 700 // Start the debugger wire protocol handler if necessary. | 703 // Start the debugger wire protocol handler if necessary. |
| 701 if (start_debugger) { | 704 if (start_debugger) { |
| 702 ASSERT(debug_port != 0); | 705 ASSERT(debug_port != 0); |
| 703 DebuggerConnectionHandler::StartHandler(debug_ip, debug_port); | 706 DebuggerConnectionHandler::StartHandler(debug_ip, debug_port); |
| 704 } | 707 } |
| 705 | 708 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 Dart_ShutdownIsolate(); | 774 Dart_ShutdownIsolate(); |
| 772 // Terminate process exit-code handler. | 775 // Terminate process exit-code handler. |
| 773 Process::TerminateExitCodeHandler(); | 776 Process::TerminateExitCodeHandler(); |
| 774 // Free copied argument strings if converted. | 777 // Free copied argument strings if converted. |
| 775 if (argv_converted) { | 778 if (argv_converted) { |
| 776 for (int i = 0; i < argc; i++) free(argv[i]); | 779 for (int i = 0; i < argc; i++) free(argv[i]); |
| 777 } | 780 } |
| 778 | 781 |
| 779 return 0; | 782 return 0; |
| 780 } | 783 } |
| OLD | NEW |