Commit a511957e authored by fleuria's avatar fleuria

refactor mrb_context_run()

parent d75a907e
......@@ -261,7 +261,7 @@ void mrb_close(mrb_state*);
mrb_value mrb_top_self(mrb_state *);
mrb_value mrb_run(mrb_state*, struct RProc*, mrb_value);
mrb_value mrb_context_run(mrb_state*, struct RProc*, mrb_value);
mrb_value mrb_context_run(mrb_state*, struct RProc*, mrb_value, unsigned int);
void mrb_p(mrb_state*, mrb_value);
mrb_int mrb_obj_id(mrb_value obj);
......
......@@ -367,7 +367,7 @@ main(int argc, char **argv)
result = mrb_context_run(mrb,
/* pass a proc for evaulation */
mrb_proc_new(mrb, mrb->irep[n]),
mrb_top_self(mrb));
mrb_top_self(mrb), 0);
/* did an exception occur? */
if (mrb->exc) {
p(mrb, mrb_obj_value(mrb->exc), 0);
......
......@@ -203,7 +203,7 @@ main(int argc, char **argv)
fprintf(stderr, "failed to load mrb file: %s\n", args.cmdline);
}
else if (!args.check_syntax) {
mrb_context_run(mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_top_self(mrb));
mrb_context_run(mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_top_self(mrb), 0);
n = 0;
if (mrb->exc) {
mrb_print_error(mrb);
......
......@@ -510,7 +510,7 @@ mrb_load_irep(mrb_state *mrb, const uint8_t *bin)
irep_error(mrb, n);
return mrb_nil_value();
}
return mrb_context_run(mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_top_self(mrb));
return mrb_context_run(mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_top_self(mrb), 0);
}
#ifdef ENABLE_STDIO
......@@ -760,6 +760,6 @@ mrb_load_irep_file(mrb_state *mrb, FILE* fp)
irep_error(mrb, n);
return mrb_nil_value();
}
return mrb_context_run(mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_top_self(mrb));
return mrb_context_run(mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_top_self(mrb), 0);
}
#endif /* ENABLE_STDIO */
......@@ -5388,7 +5388,7 @@ load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
if (mrb->c->ci) {
mrb->c->ci->target_class = target;
}
v = mrb_run(mrb, proc, mrb_top_self(mrb));
v = mrb_context_run(mrb, proc, mrb_top_self(mrb), 0);
if (mrb->exc) return mrb_nil_value();
return v;
}
......
......@@ -546,8 +546,8 @@ void mrb_gv_val_set(mrb_state *mrb, mrb_sym sym, mrb_value val);
#define CALL_MAXARGS 127
static mrb_value
run_proc(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stack_keep)
mrb_value
mrb_context_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stack_keep)
{
/* mrb_assert(mrb_proc_cfunc_p(proc)) */
mrb_irep *irep = proc->body.irep;
......@@ -2148,13 +2148,7 @@ run_proc(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stack_
mrb_value
mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
{
return run_proc(mrb, proc, self, mrb->c->ci->argc + 2); /* argc + 2 (receiver and block) */
}
mrb_value
mrb_context_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
{
return run_proc(mrb, proc, self, proc->body.irep->nregs);
return mrb_context_run(mrb, proc, self, mrb->c->ci->argc + 2); /* argc + 2 (receiver and block) */
}
void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment