We have already reserved that register in codegen()'s case NODE_DEF, but
what we care about is actually the previous register. So what we need is
get that register by cursp() after pop(), then recover the reservation
by push().
This commit is contained in:
fleuria
2013-10-25 02:48:25 +08:00
parent a230a88e89
commit c647dff1b2
+3 -1
View File
@@ -646,7 +646,9 @@ scope_body(codegen_scope *s, node *tree)
genop(scope, MKOP_AB(OP_RETURN, 0, OP_R_NORMAL));
}
else {
genop_peep(scope, MKOP_AB(OP_RETURN, scope->sp, OP_R_NORMAL), NOVAL);
pop();
genop_peep(scope, MKOP_AB(OP_RETURN, cursp(), OP_R_NORMAL), NOVAL);
push();
}
}
scope_finish(scope);