Commit 49cac5f9 authored by Yukihiro Matsumoto's avatar Yukihiro Matsumoto

case should care about return value; close #372

parent a9247f72
...@@ -479,10 +479,10 @@ lambda_body(codegen_scope *s, node *tree, int blk) ...@@ -479,10 +479,10 @@ lambda_body(codegen_scope *s, node *tree, int blk)
pos = new_label(s); pos = new_label(s);
for (i=0; i<oa; i++) { for (i=0; i<oa; i++) {
new_label(s); new_label(s);
genop(s, MKOP_Ax(OP_JMP, 0)); genop(s, MKOP_sBx(OP_JMP, 0));
} }
if (oa > 0) { if (oa > 0) {
genop(s, MKOP_Ax(OP_JMP, 0)); genop(s, MKOP_sBx(OP_JMP, 0));
} }
opt = tree->car->cdr->car; opt = tree->car->cdr->car;
i = 0; i = 0;
...@@ -1086,21 +1086,23 @@ codegen(codegen_scope *s, node *tree, int val) ...@@ -1086,21 +1086,23 @@ codegen(codegen_scope *s, node *tree, int val)
} }
if (tree->car->car) { if (tree->car->car) {
pos1 = new_label(s); pos1 = new_label(s);
genop(s, MKOP_AsBx(OP_JMP, cursp(), 0)); genop(s, MKOP_sBx(OP_JMP, 0));
dispatch_linked(s, pos2); dispatch_linked(s, pos2);
} }
pop(); pop(); pop();
codegen(s, tree->car->cdr, val); codegen(s, tree->car->cdr, val);
pop();
tmp = new_label(s); tmp = new_label(s);
genop(s, MKOP_AsBx(OP_JMP, cursp(), pos3)); genop(s, MKOP_sBx(OP_JMP, pos3));
pos3 = tmp; pos3 = tmp;
if (pos1) dispatch(s, pos1); if (pos1) dispatch(s, pos1);
tree = tree->cdr; tree = tree->cdr;
push(); push(); push();
} }
pop(); pop();
if (pos3) dispatch_linked(s, pos3); genop(s, MKOP_A(OP_LOADNIL, cursp()));
if (val) push(); if (val) push();
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