Skip to content

Commit

Permalink
codegen.c: adjust stack position for OP_SUPER instruction.
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Feb 19, 2022
1 parent f906ac3 commit 44f591a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions mrbgems/mruby-compiler/core/codegen.c
Expand Up @@ -2954,19 +2954,20 @@ codegen(codegen_scope *s, node *tree, int val)
if (tree->cdr->cdr) {
codegen(s, tree->cdr->cdr, VAL);
}
else if (!s2) {/* super at top-level */
push(); /* no need to push block */
}
else if (s2) gen_blkmove(s, s2->ainfo, lv);
else {
gen_blkmove(s, s2->ainfo, lv);
genop_1(s, OP_LOADNIL, cursp());
push();
}
st++;
}
else {
if (!s2) push();
else gen_blkmove(s, s2->ainfo, lv);
st++;
if (s2) gen_blkmove(s, s2->ainfo, lv);
else {
genop_1(s, OP_LOADNIL, cursp());
push();
}
}
st++;
pop_n(st+1);
genop_2(s, OP_SUPER, cursp(), n);
if (val) push();
Expand Down Expand Up @@ -3218,6 +3219,7 @@ codegen(codegen_scope *s, node *tree, int val)
codegen_error(s, "no anonymous block argument");
}
gen_move(s, cursp(), idx, val);
if (val) push();
}
else {
codegen(s, tree, val);
Expand Down

0 comments on commit 44f591a

Please sign in to comment.