int wmain(int argc, wchar_t *argv[], wchar_t *envp[]) { int i; lock_low32(); for (i=0; i<argc; i++) { // write the command line to UTF8 wchar_t *warg = argv[i]; size_t len = WideCharToMultiByte(CP_UTF8, 0, warg, -1, NULL, 0, NULL, NULL); if (!len) return 1; char *arg = (char*)alloca(len); if (!WideCharToMultiByte(CP_UTF8, 0, warg, -1, arg, len, NULL, NULL)) return 1; argv[i] = (wchar_t*)arg; } #endif #ifdef JULIA_ENABLE_THREADING // We need to make sure this function is called before any reference to // TLS variables. Since the compiler is free to move calls to // `jl_get_ptls_states()` around, we should avoid referencing TLS // variables in this function. (Mark `true_main` as noinline for this // reason). jl_set_ptls_states_getter(jl_get_ptls_states_static); #endif libsupport_init(); parse_opts(&argc, (char***)&argv); if (lisp_prompt) { jl_lisp_prompt(); return 0; } julia_init(imagepathspecified ? JL_IMAGE_CWD : JL_IMAGE_JULIA_HOME); int ret = true_main(argc, (char**)argv); jl_atexit_hook(ret); return ret; }
int main(int argc, char *argv[]) { #else int wmain(int argc, wchar_t *argv[], wchar_t *envp[]) { int i; for (i=0; i<argc; i++) { // write the command line to UTF8 wchar_t *warg = argv[i]; size_t wlen = wcslen(warg)+1; size_t len = WideCharToMultiByte(CP_UTF8, 0, warg, wlen, NULL, 0, NULL, NULL); if (!len) return 1; char *arg = (char*)alloca(len); if (!WideCharToMultiByte(CP_UTF8, 0, warg, wlen, arg, len, NULL, NULL)) return 1; argv[i] = (wchar_t*)arg; } #endif libsupport_init(); parse_opts(&argc, (char***)&argv); if (lisp_prompt) { jl_lisp_prompt(); return 0; } julia_init(lisp_prompt ? NULL : image_file); return julia_trampoline(argc, (char**)argv, true_main); }
int main(int argc, char *argv[]) { #else int wmain(int argc, wchar_t *argv[], wchar_t *envp[]) { int i; for (i=0; i<argc; i++) { // write the command line to UTF8 wchar_t *warg = argv[i]; size_t wlen = wcslen(warg)+1; size_t len = WideCharToMultiByte(CP_UTF8, 0, warg, wlen, NULL, 0, NULL, NULL); if (!len) return 1; char *arg = (char*)alloca(len); if (!WideCharToMultiByte(CP_UTF8, 0, warg, wlen, arg, len, NULL, NULL)) return 1; argv[i] = (wchar_t*)arg; } #endif libsupport_init(); parse_opts(&argc, (char***)&argv); if (lisp_prompt) { jl_lisp_prompt(); return 0; } julia_init(imagepathspecified ? JL_IMAGE_CWD : JL_IMAGE_JULIA_HOME); int ret = true_main(argc, (char**)argv); jl_atexit_hook(); julia_save(); return ret; }
int true_main(int argc, char *argv[]) { if (lisp_prompt) { jl_lisp_prompt(); return 0; } jl_array_t *args = jl_alloc_cell_1d(argc); jl_set_global(jl_current_module, jl_symbol("ARGS"), (jl_value_t*)args); int i; for (i=0; i < argc; i++) { jl_arrayset(args, i, (jl_value_t*)jl_cstr_to_string(argv[i])); } jl_set_const(jl_current_module, jl_symbol("JULIA_HOME"), jl_cstr_to_string(julia_home)); // run program if specified, otherwise enter REPL if (program) { return exec_program(); } init_repl_environment(); jl_function_t *start_client = (jl_function_t*)jl_get_global(jl_base_module, jl_symbol("_start")); if (start_client) { jl_apply(start_client, NULL, 0); return 0; } // client event loop not available; use fallback blocking version int iserr = 0; again: ; JL_TRY { if (iserr) { jl_show(jl_exception_in_transit); ios_printf(ios_stdout, "\n\n"); iserr = 0; } while (1) { char *input = read_expr("julia> "); if (!input || ios_eof(ios_stdin)) { ios_printf(ios_stdout, "\n"); break; } jl_value_t *ast = jl_parse_input_line(input); jl_value_t *value = jl_toplevel_eval(ast); jl_show(value); ios_printf(ios_stdout, "\n\n"); } } JL_CATCH { iserr = 1; goto again; } return 0; }
int true_main(int argc, char *argv[]) { if (lisp_prompt) { jl_lisp_prompt(); return 0; } jl_array_t *args = jl_alloc_cell_1d(argc); jl_set_global(jl_system_module, jl_symbol("ARGS"), (jl_value_t*)args); int i; for (i=0; i < argc; i++) { jl_arrayset(args, i, (jl_value_t*)jl_cstr_to_string(argv[i])); } jl_set_const(jl_system_module, jl_symbol("JULIA_HOME"), jl_cstr_to_string(julia_home)); // run program if specified, otherwise enter REPL if (program) { return exec_program(); } init_repl_environment(); have_color = detect_color(); char *prompt = have_color ? jl_prompt_color : jl_prompt_plain; prompt_length = strlen(jl_prompt_plain); prompt_string = prompt; jl_function_t *start_client = (jl_function_t*) jl_get_global(jl_system_module, jl_symbol("_start")); if (start_client == NULL) { repl_print_prompt(); // client event loop not available; use fallback blocking version int iserr = 0; again: ; JL_TRY { if (iserr) { if (have_color) { ios_printf(ios_stdout, jl_color_normal); } jl_show(jl_exception_in_transit); ios_printf(ios_stdout, "\n\n"); iserr = 0; } while (1) { read_expr(prompt); } } JL_CATCH { iserr = 1; goto again; } }
int main(int argc, char *argv[]) { libsupport_init(); parse_opts(&argc, &argv); if (lisp_prompt) { jl_lisp_prompt(); return 0; } julia_init(lisp_prompt ? NULL : image_file); return julia_trampoline(argc, argv, true_main); }
int main(int argc, char *argv[]) { libsupport_init(); parse_opts(&argc, &argv); if (lisp_prompt) { jl_init_frontend(); jl_lisp_prompt(); return 0; } julia_init(lisp_prompt ? NULL : image_file, build_mode!=NULL); return julia_trampoline(argc, argv, true_main, build_mode); }