diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-05-01 12:25:04 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-05-01 12:25:04 +0900 |
| commit | a8122a9d563d2916bf4a39c207407ea22da36677 (patch) | |
| tree | 2e0b7533ca2770ea71bb0ee7e36d35ad94163cd3 /mrbgems | |
| parent | 59c8fdd6511ec5bbbb36082ec7b8e62b20f93395 (diff) | |
| download | mruby-a8122a9d563d2916bf4a39c207407ea22da36677.tar.gz mruby-a8122a9d563d2916bf4a39c207407ea22da36677.zip | |
Fix stack position in multiple assignment; fix #4008
This was caused by a patch from #2684.
Diffstat (limited to 'mrbgems')
| -rw-r--r-- | mrbgems/mruby-compiler/core/codegen.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index eb82110b8..b9451fb88 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -1088,8 +1088,12 @@ gen_vmassignment(codegen_scope *s, node *tree, int rhs, int val) t = tree->car; n = 0; while (t) { - genop(s, MKOP_ABC(OP_AREF, cursp(), rhs, n)); - gen_assignment(s, t->car, cursp(), NOVAL); + int sp = cursp(); + + genop(s, MKOP_ABC(OP_AREF, sp, rhs, n)); + push(); + gen_assignment(s, t->car, sp, NOVAL); + pop(); n++; t = t->cdr; } @@ -1103,14 +1107,9 @@ gen_vmassignment(codegen_scope *s, node *tree, int rhs, int val) p = p->cdr; } } - if (val) { - genop(s, MKOP_AB(OP_MOVE, cursp(), rhs)); - } - else { - pop(); - } - push_n(post); - pop_n(post); + genop(s, MKOP_AB(OP_MOVE, cursp(), rhs)); + push_n(post+1); + pop_n(post+1); genop(s, MKOP_ABC(OP_APOST, cursp(), n, post)); n = 1; if (t->car) { /* rest */ @@ -1124,8 +1123,8 @@ gen_vmassignment(codegen_scope *s, node *tree, int rhs, int val) n++; } } - if (!val) { - push(); + if (val) { + genop(s, MKOP_AB(OP_MOVE, cursp(), rhs)); } } } |
