int main(int argc, const char *argv[]) { int stacktop; const char *sourcefile; const char *execname; Interp *interp; int status; int pir_argc; const char **pir_argv; Parrot_Run_core_t core = PARROT_SLOW_CORE; Parrot_trace_flags trace = PARROT_NO_TRACE; /* internationalization setup */ /* setlocale(LC_ALL, ""); */ PARROT_BINDTEXTDOMAIN(PACKAGE, LOCALEDIR); PARROT_TEXTDOMAIN(PACKAGE); Parrot_set_config_hash(); interp = allocate_interpreter(NULL, PARROT_NO_FLAGS); /* We parse the arguments, but first store away the name of the Parrot executable, since parsing destroys that and we want to make it available. */ execname = argv[0]; /* Parse minimal subset of flags */ parseflags_minimal(interp, argc, argv); /* Now initialize interpreter */ initialize_interpreter(interp, (void*)&stacktop); /* Parse flags */ sourcefile = parseflags(interp, argc, argv, &pir_argc, &pir_argv, &core, &trace); Parrot_set_trace(interp, trace); Parrot_set_run_core(interp, (Parrot_Run_core_t) core); Parrot_set_executable_name(interp, Parrot_str_new(interp, execname, 0)); status = imcc_run(interp, sourcefile, argc, argv); if (status) imcc_run_pbc(interp, interp->output_file, pir_argc, pir_argv); /* Clean-up after ourselves */ Parrot_destroy(interp); Parrot_exit(interp, 0); }
int main(int argc, char **argv) { long *opp; int dummy_var; struct Parrot_Interp * interpreter; struct PackFile * pf; opcode_t *code_start; INTVAL i; PMC *userargv; extern char *program_code; extern long opcode_map; extern int bytecode_offset; #if defined(JIT_CGP) extern void * exec_prederef_code; #endif extern int Parrot_exec_run; extern struct PackFile_Constant *exec_const_table; extern struct PackFile_Constant const_table; extern struct Parrot_Interp interpre; /* s. exec.c */ Parrot_exec_run = 1; /* s. packfile.c (PackFile_ConstTable_unpack()) */ exec_const_table = &const_table; interpreter = Parrot_new(NULL); if (!interpreter) { return 1; } Parrot_init(interpreter); run_native = run_compiled; /* TODO make also a shared variant of PackFile_new */ pf = PackFile_new(0); if (!PackFile_unpack(interpreter, pf, (opcode_t *)(&program_code), sizeof(&program_code))) { printf( "Can't unpack.\n" ); return 1; } Parrot_loadbc(interpreter, pf); setup_argv(interpreter, argc, argv); /* opcode_map has the offset of each opcode in the compiled code * this modifies it to be address of the opcode. */ opp = &opcode_map; for (i = 0; i < (int)interpre.code->cur_cs->base.size; i++) { opp[i] += (long)run_compiled; } #if defined(JIT_CGP) exec_init_prederef(interpreter, &exec_prederef_code); #endif Parrot_set_run_core(interpreter, PARROT_EXEC_CORE); interpreter->code->byte_code = (opcode_t *)&((&program_code)[bytecode_offset]); Parrot_exec_run = 0; runops(interpreter, 0); /* run_compiled(interpreter, (opcode_t *)&((&program_code)[bytecode_offset])); */ exit(0); }