Commit 82c5b486 authored by fleuria's avatar fleuria

mirb: reset stack in the first command

parent a511957e
......@@ -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);
......
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