Skip to content

Commit

Permalink
fix #1544
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
flaneur2020 committed Oct 24, 2013
1 parent a230a88 commit c647dff
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/codegen.c
Expand Up @@ -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);
Expand Down

0 comments on commit c647dff

Please sign in to comment.