diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-03-11 22:25:12 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-03-12 00:58:00 +0900 |
| commit | 92f5becabe9db34e51fa917f3095b1f90869a1a5 (patch) | |
| tree | b634d28ffb2c079ac86aac94fd04c21c8e9420f9 /src | |
| parent | 26169f9e25788caf2781a92087f489e5e5fdc0c9 (diff) | |
| download | mruby-92f5becabe9db34e51fa917f3095b1f90869a1a5.tar.gz mruby-92f5becabe9db34e51fa917f3095b1f90869a1a5.zip | |
Update VM to support new OP_RESCUE behavior; ref #3487
Diffstat (limited to 'src')
| -rw-r--r-- | src/vm.c | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -1082,15 +1082,22 @@ RETRY_TRY_BLOCK: } CASE(OP_RESCUE) { - /* A R(A) := exc; clear(exc) */ - /* B R(B) := matched (bool) */ + /* A B R(A) := exc; clear(exc); R(B) := matched (bool) */ + int a = GETARG_A(i); int b = GETARG_B(i); - mrb_value exc = mrb_obj_value(mrb->exc); + int c = GETARG_C(i); + mrb_value exc; if (b != 0) { mrb_value e = regs[b]; struct RClass *ec; + if (c == 0) { + exc = mrb_obj_value(mrb->exc); + } + else { /* continued; exc taken from R(A) */ + exc = regs[a]; + } switch (mrb_type(e)) { case MRB_TT_CLASS: case MRB_TT_MODULE: @@ -1107,7 +1114,12 @@ RETRY_TRY_BLOCK: regs[b] = mrb_false_value(); } } - regs[GETARG_A(i)] = exc; + else if (c == 0) { + exc = mrb_obj_value(mrb->exc); + } + if (a != 0 && c == 0) { + regs[GETARG_A(i)] = exc; + } mrb->exc = 0; NEXT; } |
