Permalink
Browse files

change mrb_run related API names; compatibility macros provided

  • Loading branch information...
matz committed Jan 7, 2016
1 parent 725b3ca commit f7afe1d82a6237879b3727135e244b420f9b61fa
Showing with 13 additions and 17 deletions.
  1. +6 −2 include/mruby.h
  2. +0 −2 include/mruby/compile.h
  3. +1 −1 mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
  4. +1 −1 mrbgems/mruby-compiler/core/parse.y
  5. +5 −11 src/vm.c
View
@@ -933,9 +933,13 @@ MRB_API void* mrb_default_allocf(mrb_state*, void*, size_t, void*);
MRB_API mrb_value mrb_top_self(mrb_state *);
MRB_API mrb_value mrb_run(mrb_state*, struct RProc*, mrb_value);
MRB_API mrb_value mrb_toplevel_run(mrb_state*, struct RProc*);
MRB_API mrb_value mrb_context_run(mrb_state*, struct RProc*, mrb_value, unsigned int);
MRB_API mrb_value mrb_top_run(mrb_state*, struct RProc*, mrb_value, unsigned int);
MRB_API mrb_value mrb_vm_run(mrb_state*, struct RProc*, mrb_value, unsigned int);
MRB_API mrb_value mrb_vm_exec(mrb_state*, struct RProc*, mrb_code*);
/* compatibility macros */
#define mrb_toplevel_run_keep(m,p,k) mrb_top_run((m),(p),mrb_top_self(m),(k))
#define mrb_toplevel_run(m,p) mrb_toplevel_run_keep((m),(p),0)
#define mrb_context_run(m,p,s,k) mrb_vm_run((m),(p),(s),(k))
MRB_API void mrb_p(mrb_state*, mrb_value);
MRB_API mrb_int mrb_obj_id(mrb_value obj);
View
@@ -40,8 +40,6 @@ MRB_API void mrbc_context_free(mrb_state *mrb, mrbc_context *cxt);
MRB_API const char *mrbc_filename(mrb_state *mrb, mrbc_context *c, const char *s);
MRB_API void mrbc_partial_hook(mrb_state *mrb, mrbc_context *c, int (*partial_hook)(struct mrb_parser_state*), void*data);
MRB_API mrb_value mrb_toplevel_run_keep(mrb_state*, struct RProc*, unsigned int);
/* AST node structure */
typedef struct mrb_ast_node {
struct mrb_ast_node *car, *cdr;
@@ -546,7 +546,7 @@ main(int argc, char **argv)
}
/* pass a proc for evaulation */
/* evaluate the bytecode */
result = mrb_context_run(mrb,
result = mrb_vm_run(mrb,
proc,
mrb_top_self(mrb),
stack_keep);
@@ -5634,7 +5634,7 @@ load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
if (mrb->c->ci) {
mrb->c->ci->target_class = target;
}
v = mrb_toplevel_run_keep(mrb, proc, keep);
v = mrb_top_run(mrb, proc, mrb_top_self(mrb), keep);
if (mrb->exc) return mrb_nil_value();
return v;
}
View
@@ -746,7 +746,7 @@ argnum_error(mrb_state *mrb, mrb_int num)
void mrb_method_missing(mrb_state *mrb, mrb_sym name, mrb_value self, mrb_value args);
MRB_API mrb_value
mrb_context_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stack_keep)
mrb_vm_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stack_keep)
{
mrb_irep *irep = proc->body.irep;
@@ -2434,30 +2434,24 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
MRB_API 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) */
return mrb_vm_run(mrb, proc, self, mrb->c->ci->argc + 2); /* argc + 2 (receiver and block) */
}
MRB_API mrb_value
mrb_toplevel_run_keep(mrb_state *mrb, struct RProc *proc, unsigned int stack_keep)
mrb_top_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stack_keep)
{
mrb_callinfo *ci;
mrb_value v;
if (!mrb->c->cibase || mrb->c->ci == mrb->c->cibase) {
return mrb_context_run(mrb, proc, mrb_top_self(mrb), stack_keep);
return mrb_vm_run(mrb, proc, self, stack_keep);
}
ci = cipush(mrb);
ci->nregs = 1; /* protect the receiver */
ci->acc = CI_ACC_SKIP;
ci->target_class = mrb->object_class;
v = mrb_context_run(mrb, proc, mrb_top_self(mrb), stack_keep);
v = mrb_vm_run(mrb, proc, self, stack_keep);
cipop(mrb);
return v;
}
MRB_API mrb_value
mrb_toplevel_run(mrb_state *mrb, struct RProc *proc)
{
return mrb_toplevel_run_keep(mrb, proc, 0);
}

0 comments on commit f7afe1d

Please sign in to comment.