Commit f80401de authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

resolved conflicts and updated to latest return value change of mrb_generate_code()

parents e386760c 82c5b486
......@@ -261,6 +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, unsigned int);
void mrb_p(mrb_state*, mrb_value);
mrb_int mrb_obj_id(mrb_value obj);
......
......@@ -255,6 +255,8 @@ main(int argc, char **argv)
int n;
int code_block_open = FALSE;
int ai;
int first_command = 1;
unsigned int nregs;
/* new interpreter instance */
mrb = mrb_open();
......@@ -363,10 +365,13 @@ main(int argc, char **argv)
/* generate bytecode */
struct RProc *proc = mrb_generate_code(mrb, parser);
/* pass a proc for evaulation */
nregs = first_command ? 0: proc->body.irep->nregs;
/* evaluate the bytecode */
result = mrb_run(mrb,
/* pass a proc for evaulation */
proc, mrb_top_self(mrb));
result = mrb_context_run(mrb,
proc,
mrb_top_self(mrb),
nregs);
/* did an exception occur? */
if (mrb->exc) {
p(mrb, mrb_obj_value(mrb->exc), 0);
......@@ -386,6 +391,7 @@ main(int argc, char **argv)
}
mrb_parser_free(parser);
cxt->lineno++;
first_command = 0;
}
mrbc_context_free(mrb, cxt);
mrb_close(mrb);
......
......@@ -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_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_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_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 */
......@@ -5387,7 +5387,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;
}
......
......@@ -547,7 +547,7 @@ void mrb_gv_val_set(mrb_state *mrb, mrb_sym sym, mrb_value val);
#define CALL_MAXARGS 127
mrb_value
mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
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;
......@@ -595,7 +595,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
if (!mrb->c->stack) {
stack_init(mrb);
}
stack_extend(mrb, irep->nregs, mrb->c->ci->argc + 2); /* argc + 2 (receiver and block) */
stack_extend(mrb, irep->nregs, stack_keep);
mrb->c->ci->err = pc;
mrb->c->ci->proc = proc;
mrb->c->ci->nregs = irep->nregs + 1;
......@@ -2145,6 +2145,12 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
END_DISPATCH;
}
mrb_value
mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
{
return mrb_context_run(mrb, proc, self, mrb->c->ci->argc + 2); /* argc + 2 (receiver and block) */
}
void
mrb_longjmp(mrb_state *mrb)
{
......
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