From 63bafca7f5e1eb0e11f57875363ab5e5aa7cc8b6 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Thu, 17 Jun 2021 16:53:21 +0900 Subject: variable.c: refactor `mrb_vm_const_get` function. --- src/variable.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/variable.c') diff --git a/src/variable.c b/src/variable.c index e1200bc3d..bf421955b 100644 --- a/src/variable.c +++ b/src/variable.c @@ -803,9 +803,9 @@ mrb_vm_const_get(mrb_state *mrb, mrb_sym sym) struct RClass *c; struct RClass *c2; mrb_value v; - const struct RProc *proc; + const struct RProc *proc = mrb->c->ci->proc; - c = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc); + c = MRB_PROC_TARGET_CLASS(proc); if (!c) c = mrb->object_class; if (iv_get(mrb, c->iv, sym, &v)) { return v; @@ -821,8 +821,7 @@ mrb_vm_const_get(mrb_state *mrb, mrb_sym sym) c2 = mrb_class_ptr(klass); } if (c2 && (c2->tt == MRB_TT_CLASS || c2->tt == MRB_TT_MODULE)) c = c2; - mrb_assert(!MRB_PROC_CFUNC_P(mrb->c->ci->proc)); - proc = mrb->c->ci->proc; + proc = proc->upper; while (proc) { c2 = MRB_PROC_TARGET_CLASS(proc); if (c2 && iv_get(mrb, c2->iv, sym, &v)) { -- cgit v1.2.3