OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // Generate a snapshot file after loading all the scripts specified on the | 5 // Generate a snapshot file after loading all the scripts specified on the |
6 // command line. | 6 // command line. |
7 | 7 |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 namespace dart { | 31 namespace dart { |
32 namespace bin { | 32 namespace bin { |
33 | 33 |
34 // Exit code indicating an API error. | 34 // Exit code indicating an API error. |
35 static const int kApiErrorExitCode = 253; | 35 static const int kApiErrorExitCode = 253; |
36 // Exit code indicating a compilation error. | 36 // Exit code indicating a compilation error. |
37 static const int kCompilationErrorExitCode = 254; | 37 static const int kCompilationErrorExitCode = 254; |
38 // Exit code indicating an unhandled error that is not a compilation error. | 38 // Exit code indicating an unhandled error that is not a compilation error. |
39 static const int kErrorExitCode = 255; | 39 static const int kErrorExitCode = 255; |
40 // Exit code indicating a vm restart request. Never returned to the user. | |
41 static const int kRestartRequestExitCode = 1000; | |
42 | 40 |
43 #define CHECK_RESULT(result) \ | 41 #define CHECK_RESULT(result) \ |
44 if (Dart_IsError(result)) { \ | 42 if (Dart_IsError(result)) { \ |
45 intptr_t exit_code = 0; \ | 43 intptr_t exit_code = 0; \ |
46 Log::PrintErr("Error: %s\n", Dart_GetError(result)); \ | 44 Log::PrintErr("Error: %s\n", Dart_GetError(result)); \ |
47 if (Dart_IsCompilationError(result)) { \ | 45 if (Dart_IsCompilationError(result)) { \ |
48 exit_code = kCompilationErrorExitCode; \ | 46 exit_code = kCompilationErrorExitCode; \ |
49 } else if (Dart_IsApiError(result)) { \ | 47 } else if (Dart_IsApiError(result)) { \ |
50 exit_code = kApiErrorExitCode; \ | 48 exit_code = kApiErrorExitCode; \ |
51 } else if (Dart_IsVMRestartRequest(result)) { \ | |
52 exit_code = kRestartRequestExitCode; \ | |
53 } else { \ | 49 } else { \ |
54 exit_code = kErrorExitCode; \ | 50 exit_code = kErrorExitCode; \ |
55 } \ | 51 } \ |
56 Dart_ExitScope(); \ | 52 Dart_ExitScope(); \ |
57 Dart_ShutdownIsolate(); \ | 53 Dart_ShutdownIsolate(); \ |
58 exit(exit_code); \ | 54 exit(exit_code); \ |
59 } | 55 } |
60 | 56 |
61 | 57 |
62 // The core snapshot to use when creating isolates. Normally NULL, but loaded | 58 // The core snapshot to use when creating isolates. Normally NULL, but loaded |
(...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1702 delete mapped_isolate_snapshot_data; | 1698 delete mapped_isolate_snapshot_data; |
1703 return 0; | 1699 return 0; |
1704 } | 1700 } |
1705 | 1701 |
1706 } // namespace bin | 1702 } // namespace bin |
1707 } // namespace dart | 1703 } // namespace dart |
1708 | 1704 |
1709 int main(int argc, char** argv) { | 1705 int main(int argc, char** argv) { |
1710 return dart::bin::main(argc, argv); | 1706 return dart::bin::main(argc, argv); |
1711 } | 1707 } |
OLD | NEW |