Chromium Code Reviews| Index: runtime/bin/exit.h |
| diff --git a/runtime/bin/exit.h b/runtime/bin/exit.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..86dd63b97b0f8999493354f62b692425b15abb2e |
| --- /dev/null |
| +++ b/runtime/bin/exit.h |
| @@ -0,0 +1,55 @@ |
| +// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
|
zra
2017/02/09 16:15:38
2017
rmacnak
2017/02/10 02:11:56
Done.
rmacnak
2017/02/10 02:11:56
Done.
|
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +#ifndef RUNTIME_BIN_EXIT_H_ |
| +#define RUNTIME_BIN_EXIT_H_ |
| + |
| +#include "bin/log.h" |
| +#include "bin/platform.h" |
| +#include "bin/process.h" |
| +#include "bin/eventhandler.h" |
| +#include "include/dart_api.h" |
| +#include "platform/assert.h" |
| +#include "platform/globals.h" |
| + |
| +namespace dart { |
| +namespace bin { |
| + |
| +// Exit code indicating an internal Dart Frontend error. |
| +static const int kDartFrontendErrorExitCode = 252; |
| +// Exit code indicating an API error. |
| +static const int kApiErrorExitCode = 253; |
| +// Exit code indicating a compilation error. |
| +static const int kCompilationErrorExitCode = 254; |
| +// Exit code indicating an unhandled error that is not a compilation error. |
| +static const int kErrorExitCode = 255; |
| +// Exit code indicating a vm restart request. Never returned to the user. |
| +static const int kRestartRequestExitCode = 1000; |
| + |
| +static void ErrorExit(int exit_code, const char* format, ...) { |
|
zra
2017/02/09 16:15:38
Maybe rename this file error_exit.h and make a .cc
rmacnak
2017/02/10 02:11:56
Done.
|
| + va_list arguments; |
| + va_start(arguments, format); |
| + Log::VPrintErr(format, arguments); |
| + va_end(arguments); |
| + |
| + Dart_ExitScope(); |
| + Dart_ShutdownIsolate(); |
| + |
| + // Terminate process exit-code handler. |
| + Process::TerminateExitCodeHandler(); |
| + |
| + char* error = Dart_Cleanup(); |
| + if (error != NULL) { |
| + Log::PrintErr("VM cleanup failed: %s\n", error); |
| + free(error); |
| + } |
| + |
| + EventHandler::Stop(); |
| + Platform::Exit(exit_code); |
| +} |
| + |
| +} // namespace bin |
| +} // namespace dart |
| + |
| +#endif // RUNTIME_BIN_EXIT_H_ |