wrong stack position for headless case; close #675

parent be122b73
...@@ -1205,6 +1205,7 @@ codegen(codegen_scope *s, node *tree, int val) ...@@ -1205,6 +1205,7 @@ codegen(codegen_scope *s, node *tree, int val)
pop(); pop();
genop(s, MKOP_ABC(OP_SEND, cursp(), new_msym(s, mrb_intern(s->mrb, "===")), 1)); genop(s, MKOP_ABC(OP_SEND, cursp(), new_msym(s, mrb_intern(s->mrb, "===")), 1));
} }
pop();
tmp = new_label(s); tmp = new_label(s);
genop(s, MKOP_AsBx(OP_JMPIF, cursp(), pos2)); genop(s, MKOP_AsBx(OP_JMPIF, cursp(), pos2));
pos2 = tmp; pos2 = tmp;
...@@ -1215,7 +1216,6 @@ codegen(codegen_scope *s, node *tree, int val) ...@@ -1215,7 +1216,6 @@ codegen(codegen_scope *s, node *tree, int val)
genop(s, MKOP_sBx(OP_JMP, 0)); genop(s, MKOP_sBx(OP_JMP, 0));
dispatch_linked(s, pos2); dispatch_linked(s, pos2);
} }
pop(); /* pop HEAD */
codegen(s, tree->car->cdr, val); codegen(s, tree->car->cdr, val);
if (val) pop(); if (val) pop();
tmp = new_label(s); tmp = new_label(s);
...@@ -1223,11 +1223,11 @@ codegen(codegen_scope *s, node *tree, int val) ...@@ -1223,11 +1223,11 @@ codegen(codegen_scope *s, node *tree, int val)
pos3 = tmp; pos3 = tmp;
if (pos1) dispatch(s, pos1); if (pos1) dispatch(s, pos1);
tree = tree->cdr; tree = tree->cdr;
push(); /* push HEAD */
} }
pop(); /* pop HEAD */ if (val) {
genop(s, MKOP_A(OP_LOADNIL, cursp())); genop(s, MKOP_A(OP_LOADNIL, cursp()));
if (val) push(); push();
}
if (pos3) dispatch_linked(s, pos3); if (pos3) dispatch_linked(s, pos3);
} }
break; break;
......
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