static void eval_load_irep(mrb_state *mrb, mrb_irep *irep) { int ai; struct RProc *proc; replace_stop_with_return(mrb, irep); proc = mrb_proc_new(mrb, irep); proc->target_class = mrb->object_class; ai = mrb_gc_arena_save(mrb); mrb_yield_internal(mrb, mrb_obj_value(proc), 0, NULL, mrb_top_self(mrb), mrb->object_class); mrb_gc_arena_restore(mrb, ai); }
static void load_mrb_file(mrb_state *mrb, mrb_value filepath) { char *fpath = RSTRING_PTR(filepath); int ai; FILE *fp; mrb_irep *irep; fp = fopen(fpath, "rb"); if (fp == NULL) { mrb_load_fail( mrb, mrb_str_new_cstr(mrb, fpath), "cannot load such file" ); return; } ai = mrb_gc_arena_save(mrb); irep = mrb_read_irep_file(mrb, fp); fclose(fp); mrb_gc_arena_restore(mrb, ai); if (irep) { struct RProc *proc; /* size_t i; for (i = sirep; i < mrb->irep_len; i++) { mrb->irep[i]->filename = mrb_string_value_ptr(mrb, filepath); } */ #ifdef USE_MRUBY_OLD_BYTE_CODE replace_stop_with_return(mrb, irep); #endif proc = mrb_proc_new(mrb, irep); MRB_PROC_SET_TARGET_CLASS(proc, mrb->object_class); ai = mrb_gc_arena_save(mrb); mrb_yield_with_class(mrb, mrb_obj_value(proc), 0, NULL, mrb_top_self(mrb), mrb->object_class); mrb_gc_arena_restore(mrb, ai); } else if (mrb->exc) { // fail to load longjmp(*(jmp_buf*)mrb->jmp, 1); } }
static void mrb_load_irep_data(mrb_state* mrb, const uint8_t* data) { int ai = mrb_gc_arena_save(mrb); mrb_irep *irep = mrb_read_irep(mrb,data); mrb_gc_arena_restore(mrb,ai); if (irep) { int ai; struct RProc *proc; replace_stop_with_return(mrb, irep); proc = mrb_proc_new(mrb, irep); proc->target_class = mrb->object_class; ai = mrb_gc_arena_save(mrb); mrb_yield_with_class(mrb, mrb_obj_value(proc), 0, NULL, mrb_top_self(mrb), mrb->object_class); mrb_gc_arena_restore(mrb, ai); } else if (mrb->exc) { // fail to load longjmp(*(jmp_buf*)mrb->jmp, 1); } }