int main(int argc, const char *argv[]) { Parrot_PMC interp, bytecodepmc, sysargs, pirargs; Parrot_Init_Args *initargs; struct init_args_t parsed_flags; GET_INIT_STRUCT(initargs); /* Parse minimal subset of flags */ parseflags_minimal(initargs, argc, argv); if (!Parrot_api_make_interpreter(NULL, 0, initargs, &interp)) { fprintf(stderr, "PARROT VM: Could not allocate new interpreter\n"); if (interp != NULL) show_last_error_and_exit(interp); else fprintf(stderr, "PARROT VM: No interpreter. Cannot get error details\n"); exit(EXIT_FAILURE); } if (!(Parrot_set_config_hash(interp) && Parrot_api_set_executable_name(interp, argv[0]))) { fprintf(stderr, "PARROT VM: Could not initialize new interpreter\n"); show_last_error_and_exit(interp); } /* Parse flags */ parseflags(interp, argc, argv, &parsed_flags); if (!Parrot_api_set_runcore(interp, parsed_flags.run_core_name, parsed_flags.trace)) show_last_error_and_exit(interp); Parrot_api_toggle_gc(interp, 0); setup_imcc(interp); if (!parsed_flags.turn_gc_off) Parrot_api_toggle_gc(interp, 1); if (!(Parrot_api_pmc_wrap_string_array(interp, parsed_flags.sysargc, parsed_flags.sysargv, &sysargs) && Parrot_api_pmc_wrap_string_array(interp, parsed_flags.progargc, parsed_flags.progargv, &pirargs) && Parrot_api_load_bytecode_bytes(interp, get_program_code(), get_program_code_size(), &bytecodepmc) && Parrot_api_run_bytecode(interp, bytecodepmc, sysargs, pirargs))) show_last_error_and_exit(interp); /* Clean-up after ourselves */ Parrot_api_destroy_interpreter(interp); exit(EXIT_SUCCESS); }
int main(int argc, const char *argv[]) { Parrot_PMC interp, bytecodepmc, args; Parrot_Init_Args *initargs; struct init_args_t parsed_flags; Parrot_PMC compiler = NULL; GET_INIT_STRUCT(initargs); initargs->numthreads = 0; /* Parse minimal subset of flags */ parseflags_minimal(initargs, argc, argv); if (!Parrot_api_make_interpreter(NULL, 0, initargs, &interp)) { fprintf(stderr, "PARROT VM: Could not allocate new interpreter\n"); if (interp != NULL) show_last_error_and_exit(interp); else fprintf(stderr, "PARROT VM: No interpreter. Cannot get error details\n"); exit(EXIT_FAILURE); } if (!(Parrot_set_config_hash(interp) && Parrot_api_set_executable_name(interp, argv[0]))) { fprintf(stderr, "PARROT VM: Could not initialize new interpreter\n"); show_last_error_and_exit(interp); } /* Parse flags */ parseflags(interp, argc, argv, &parsed_flags); if (!Parrot_api_set_runcore(interp, parsed_flags.run_core_name, parsed_flags.trace)) show_last_error_and_exit(interp); Parrot_api_toggle_gc(interp, 0); { Parrot_PMC pir_compiler = NULL; Parrot_PMC pasm_compiler = NULL;; if (!(imcc_get_pir_compreg_api(interp, 1, &pir_compiler) && imcc_get_pasm_compreg_api(interp, 1, &pasm_compiler))) show_last_error_and_exit(interp); compiler = parsed_flags.have_pasm_file ? pasm_compiler : pir_compiler; } if (!parsed_flags.turn_gc_off) Parrot_api_toggle_gc(interp, 1); if (parsed_flags.imcc_dflags || parsed_flags.imcc_opts) { if (!imcc_set_flags_api(interp, compiler, parsed_flags.imcc_dflags, parsed_flags.imcc_opts)) exit(EXIT_FAILURE); } if (!(Parrot_api_pmc_wrap_string_array(interp, parsed_flags.argc, parsed_flags.argv, &args) && Parrot_api_load_bytecode_bytes(interp, get_program_code(), get_program_code_size(), &bytecodepmc) && Parrot_api_run_bytecode(interp, bytecodepmc, args))) show_last_error_and_exit(interp); /* Clean-up after ourselves */ Parrot_api_destroy_interpreter(interp); exit(EXIT_SUCCESS); }