summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--mrbgems/mruby-bin-mirb/tools/mirb/mirb.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c b/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
index b27654e0b..5156366f5 100644
--- a/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
+++ b/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
@@ -255,6 +255,9 @@ main(int argc, char **argv)
int n;
int code_block_open = FALSE;
int ai;
+ struct RProc *proc;
+ int first_command = 1;
+ unsigned int nregs;
/* new interpreter instance */
mrb = mrb_open();
@@ -363,11 +366,14 @@ main(int argc, char **argv)
/* generate bytecode */
n = mrb_generate_code(mrb, parser);
+ /* pass a proc for evaulation */
+ proc = mrb_proc_new(mrb, mrb->irep[n]);
+ nregs = first_command ? 0: proc->body.irep->nregs;
/* evaluate the bytecode */
result = mrb_context_run(mrb,
- /* pass a proc for evaulation */
- mrb_proc_new(mrb, mrb->irep[n]),
- mrb_top_self(mrb), 0);
+ proc,
+ mrb_top_self(mrb),
+ nregs);
/* did an exception occur? */
if (mrb->exc) {
p(mrb, mrb_obj_value(mrb->exc), 0);
@@ -387,6 +393,7 @@ main(int argc, char **argv)
}
mrb_parser_free(parser);
cxt->lineno++;
+ first_command = 0;
}
mrbc_context_free(mrb, cxt);
mrb_close(mrb);