102 lines
2.8 KiB
C
Generated
102 lines
2.8 KiB
C
Generated
// Lean compiler output
|
|
// Module: LakeMain
|
|
// Imports: public import Init.System.IO import Lake.DSL import Lake.CLI.Main
|
|
#include <lean/lean.h>
|
|
#if defined(__clang__)
|
|
#pragma clang diagnostic ignored "-Wunused-parameter"
|
|
#pragma clang diagnostic ignored "-Wunused-label"
|
|
#elif defined(__GNUC__) && !defined(__CLANG__)
|
|
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
|
#pragma GCC diagnostic ignored "-Wunused-label"
|
|
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
|
#endif
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
LEAN_EXPORT lean_object* _lean_main(lean_object*);
|
|
LEAN_EXPORT lean_object* l_main___boxed(lean_object*, lean_object*);
|
|
uint32_t l_Lake_cli(lean_object*);
|
|
LEAN_EXPORT lean_object* _lean_main(lean_object* x_1) {
|
|
_start:
|
|
{
|
|
uint32_t x_3; lean_object* x_4; lean_object* x_5;
|
|
x_3 = l_Lake_cli(x_1);
|
|
x_4 = lean_box_uint32(x_3);
|
|
x_5 = lean_alloc_ctor(0, 1, 0);
|
|
lean_ctor_set(x_5, 0, x_4);
|
|
return x_5;
|
|
}
|
|
}
|
|
LEAN_EXPORT lean_object* l_main___boxed(lean_object* x_1, lean_object* x_2) {
|
|
_start:
|
|
{
|
|
lean_object* x_3;
|
|
x_3 = _lean_main(x_1);
|
|
return x_3;
|
|
}
|
|
}
|
|
lean_object* initialize_Init_System_IO(uint8_t builtin);
|
|
lean_object* initialize_Lake_DSL(uint8_t builtin);
|
|
lean_object* initialize_Lake_CLI_Main(uint8_t builtin);
|
|
static bool _G_initialized = false;
|
|
LEAN_EXPORT lean_object* initialize_LakeMain(uint8_t builtin) {
|
|
lean_object * res;
|
|
if (_G_initialized) return lean_io_result_mk_ok(lean_box(0));
|
|
_G_initialized = true;
|
|
res = initialize_Init_System_IO(builtin);
|
|
if (lean_io_result_is_error(res)) return res;
|
|
lean_dec_ref(res);
|
|
res = initialize_Lake_DSL(builtin);
|
|
if (lean_io_result_is_error(res)) return res;
|
|
lean_dec_ref(res);
|
|
res = initialize_Lake_CLI_Main(builtin);
|
|
if (lean_io_result_is_error(res)) return res;
|
|
lean_dec_ref(res);
|
|
return lean_io_result_mk_ok(lean_box(0));
|
|
}
|
|
char ** lean_setup_args(int argc, char ** argv);
|
|
void lean_initialize();
|
|
|
|
#if defined(WIN32) || defined(_WIN32)
|
|
#include <windows.h>
|
|
#endif
|
|
|
|
int main(int argc, char ** argv) {
|
|
#if defined(WIN32) || defined(_WIN32)
|
|
SetErrorMode(SEM_FAILCRITICALERRORS);
|
|
SetConsoleOutputCP(CP_UTF8);
|
|
#endif
|
|
lean_object* in; lean_object* res;
|
|
argv = lean_setup_args(argc, argv);
|
|
lean_initialize();
|
|
lean_set_panic_messages(false);
|
|
res = initialize_LakeMain(1 /* builtin */);
|
|
lean_set_panic_messages(true);
|
|
lean_io_mark_end_initialization();
|
|
if (lean_io_result_is_ok(res)) {
|
|
lean_dec_ref(res);
|
|
lean_init_task_manager();
|
|
in = lean_box(0);
|
|
int i = argc;
|
|
while (i > 1) {
|
|
lean_object* n;
|
|
i--;
|
|
n = lean_alloc_ctor(1,2,0); lean_ctor_set(n, 0, lean_mk_string(argv[i])); lean_ctor_set(n, 1, in);
|
|
in = n;
|
|
}
|
|
res = _lean_main(in);
|
|
}
|
|
lean_finalize_task_manager();
|
|
if (lean_io_result_is_ok(res)) {
|
|
int ret = lean_unbox_uint32(lean_io_result_get_value(res));
|
|
lean_dec_ref(res);
|
|
return ret;
|
|
} else {
|
|
lean_io_result_show_error(res);
|
|
lean_dec_ref(res);
|
|
return 1;
|
|
}
|
|
}
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|