Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: runtime/bin/main.cc

Issue 25674009: Add framework for Dart_Terminate which will cleanup stuff on exit. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/include/dart_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 static int ErrorExit(int exit_code, const char* format, ...) { 623 static int ErrorExit(int exit_code, const char* format, ...) {
624 va_list arguments; 624 va_list arguments;
625 va_start(arguments, format); 625 va_start(arguments, format);
626 Log::VPrintErr(format, arguments); 626 Log::VPrintErr(format, arguments);
627 va_end(arguments); 627 va_end(arguments);
628 fflush(stderr); 628 fflush(stderr);
629 629
630 Dart_ExitScope(); 630 Dart_ExitScope();
631 Dart_ShutdownIsolate(); 631 Dart_ShutdownIsolate();
632 632
633 Dart_Cleanup();
634
633 return exit_code; 635 return exit_code;
634 } 636 }
635 637
636 638
637 static int DartErrorExit(Dart_Handle error) { 639 static int DartErrorExit(Dart_Handle error) {
638 const int exit_code = Dart_IsCompilationError(error) ? 640 const int exit_code = Dart_IsCompilationError(error) ?
639 kCompilationErrorExitCode : kErrorExitCode; 641 kCompilationErrorExitCode : kErrorExitCode;
640 return ErrorExit(exit_code, "%s\n", Dart_GetError(error)); 642 return ErrorExit(exit_code, "%s\n", Dart_GetError(error));
641 } 643 }
642 644
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 Dart_EnterScope(); 794 Dart_EnterScope();
793 795
794 if (generate_script_snapshot) { 796 if (generate_script_snapshot) {
795 // First create a snapshot. 797 // First create a snapshot.
796 Dart_Handle result; 798 Dart_Handle result;
797 uint8_t* buffer = NULL; 799 uint8_t* buffer = NULL;
798 intptr_t size = 0; 800 intptr_t size = 0;
799 result = Dart_CreateScriptSnapshot(&buffer, &size); 801 result = Dart_CreateScriptSnapshot(&buffer, &size);
800 if (Dart_IsError(result)) { 802 if (Dart_IsError(result)) {
801 Log::PrintErr("%s\n", Dart_GetError(result)); 803 Log::PrintErr("%s\n", Dart_GetError(result));
802 Dart_ExitScope();
803 Dart_ShutdownIsolate();
804 return DartErrorExit(result); 804 return DartErrorExit(result);
805 } 805 }
806 806
807 // Write the magic number to indicate file is a script snapshot. 807 // Write the magic number to indicate file is a script snapshot.
808 DartUtils::WriteMagicNumber(snapshot_file); 808 DartUtils::WriteMagicNumber(snapshot_file);
809 809
810 // Now write the snapshot out to specified file. 810 // Now write the snapshot out to specified file.
811 bool bytes_written = snapshot_file->WriteFully(buffer, size); 811 bool bytes_written = snapshot_file->WriteFully(buffer, size);
812 ASSERT(bytes_written); 812 ASSERT(bytes_written);
813 delete snapshot_file; 813 delete snapshot_file;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 } 868 }
869 } 869 }
870 } 870 }
871 871
872 Dart_ExitScope(); 872 Dart_ExitScope();
873 // Shutdown the isolate. 873 // Shutdown the isolate.
874 Dart_ShutdownIsolate(); 874 Dart_ShutdownIsolate();
875 // Terminate process exit-code handler. 875 // Terminate process exit-code handler.
876 Process::TerminateExitCodeHandler(); 876 Process::TerminateExitCodeHandler();
877 877
878 Dart_Cleanup();
879
878 // Free copied argument strings if converted. 880 // Free copied argument strings if converted.
879 if (argv_converted) { 881 if (argv_converted) {
880 for (int i = 0; i < argc; i++) free(argv[i]); 882 for (int i = 0; i < argc; i++) free(argv[i]);
881 } 883 }
882 884
883 return Process::GlobalExitCode(); 885 return Process::GlobalExitCode();
884 } 886 }
885 887
886 } // namespace bin 888 } // namespace bin
887 } // namespace dart 889 } // namespace dart
888 890
889 int main(int argc, char** argv) { 891 int main(int argc, char** argv) {
890 return dart::bin::main(argc, argv); 892 return dart::bin::main(argc, argv);
891 } 893 }
OLDNEW
« no previous file with comments | « no previous file | runtime/include/dart_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698