Skip to content

Commit

Permalink
Merge branch 'master' into android.rake-ndk-clang
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Jones committed Nov 10, 2016
2 parents cc5f40b + 3f002b6 commit 70aa6dc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
16 changes: 13 additions & 3 deletions mrbgems/mruby-compiler/core/codegen.c
Expand Up @@ -1645,7 +1645,7 @@ codegen(codegen_scope *s, node *tree, int val)
node *t = tree->cdr, *p;
int rhs = cursp();

if ((intptr_t)t->car == NODE_ARRAY && nosplat(t->cdr)) {
if ((intptr_t)t->car == NODE_ARRAY && t->cdr && nosplat(t->cdr)) {
/* fixed rhs */
t = t->cdr;
while (t) {
Expand All @@ -1655,11 +1655,21 @@ codegen(codegen_scope *s, node *tree, int val)
}
tree = tree->car;
if (tree->car) { /* pre */
int first = TRUE;
t = tree->car;
n = 0;
while (t) {
gen_assignment(s, t->car, rhs+n, NOVAL);
n++;
if (n < len) {
gen_assignment(s, t->car, rhs+n, NOVAL);
n++;
}
else {
if (first) {
genop(s, MKOP_A(OP_LOADNIL, rhs+n));
first = FALSE;
}
gen_assignment(s, t->car, rhs+n, NOVAL);
}
t = t->cdr;
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/variable.c
Expand Up @@ -760,26 +760,30 @@ mrb_mod_cv_get(mrb_state *mrb, struct RClass * c, mrb_sym sym)
{
struct RClass * cls = c;
mrb_value v;
int given = FALSE;

while (c) {
if (c->iv && iv_get(mrb, c->iv, sym, &v)) {
return v;
given = TRUE;
}
c = c->super;
}
if (given) return v;
if (cls && cls->tt == MRB_TT_SCLASS) {
mrb_value klass;

klass = mrb_obj_iv_get(mrb, (struct RObject *)cls,
mrb_intern_lit(mrb, "__attached__"));
c = mrb_class_ptr(klass);
if (c->tt == MRB_TT_CLASS || c->tt == MRB_TT_MODULE) {
given = FALSE;
while (c) {
if (c->iv && iv_get(mrb, c->iv, sym, &v)) {
return v;
given = TRUE;
}
c = c->super;
}
if (given) return v;
}
}
mrb_name_error(mrb, sym, "uninitialized class variable %S in %S",
Expand Down
3 changes: 3 additions & 0 deletions src/vm.c
Expand Up @@ -1513,6 +1513,7 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
/* A B return R(A) (B=normal,in-block return/break) */
if (mrb->exc) {
mrb_callinfo *ci;
mrb_value *stk;
int eidx;

L_RAISE:
Expand All @@ -1524,6 +1525,7 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
if (ci->ridx == 0) goto L_STOP;
goto L_RESCUE;
}
stk = mrb->c->stack;
while (ci[0].ridx == ci[-1].ridx) {
cipop(mrb);
ci = mrb->c->ci;
Expand All @@ -1533,6 +1535,7 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
MRB_THROW(prev_jmp);
}
if (ci == mrb->c->cibase) {
mrb->c->stack = stk;
while (eidx > 0) {
ecall(mrb, --eidx);
}
Expand Down
5 changes: 4 additions & 1 deletion test/t/exception.rb
Expand Up @@ -338,10 +338,13 @@ def b
begin
1 * "b"
ensure
@e = self.z
@e = self.zz
end
end

def zz
true
end
def z
true
end
Expand Down

0 comments on commit 70aa6dc

Please sign in to comment.