Skip to content

Commit

Permalink
OP_RESCUE refactored; ref #3519
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Mar 19, 2017
1 parent 8d1468e commit d01118d
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions src/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1091,16 +1091,17 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
int c = GETARG_C(i);
mrb_value exc;

if (c == 0) {
exc = mrb_obj_value(mrb->exc);
mrb->exc = 0;
}
else { /* continued; exc taken from R(A) */
exc = regs[a];
}
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:
Expand All @@ -1110,20 +1111,11 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
break;
}
ec = mrb_class_ptr(e);
if (mrb_obj_is_kind_of(mrb, exc, ec)) {
regs[b] = mrb_true_value();
}
else {
regs[b] = mrb_false_value();
}
}
else if (c == 0) {
exc = mrb_obj_value(mrb->exc);
regs[b] = mrb_bool_value(mrb_obj_is_kind_of(mrb, exc, ec));
}
if (a != 0 && c == 0) {
regs[GETARG_A(i)] = exc;
regs[a] = exc;
}
mrb->exc = 0;
NEXT;
}

Expand Down

0 comments on commit d01118d

Please sign in to comment.