small refactoring (dedup mrb_vm_cv_set)

parent fe19ac2b
...@@ -756,7 +756,7 @@ mrb_cv_get(mrb_state *mrb, mrb_value mod, mrb_sym sym) ...@@ -756,7 +756,7 @@ mrb_cv_get(mrb_state *mrb, mrb_value mod, mrb_sym sym)
} }
void void
mrb_mod_cv_set(mrb_state *mrb, struct RClass * c, mrb_sym sym, mrb_value v) mrb_mod_cv_set(mrb_state *mrb, struct RClass *c, mrb_sym sym, mrb_value v)
{ {
struct RClass * cls = c; struct RClass * cls = c;
...@@ -823,24 +823,7 @@ mrb_vm_cv_set(mrb_state *mrb, mrb_sym sym, mrb_value v) ...@@ -823,24 +823,7 @@ mrb_vm_cv_set(mrb_state *mrb, mrb_sym sym, mrb_value v)
struct RClass *c = mrb->c->ci->proc->target_class; struct RClass *c = mrb->c->ci->proc->target_class;
if (!c) c = mrb->c->ci->target_class; if (!c) c = mrb->c->ci->target_class;
while (c) { mrb_mod_cv_set(mrb, c, sym, v);
if (c->iv) {
iv_tbl *t = c->iv;
if (iv_get(mrb, t, sym, NULL)) {
mrb_write_barrier(mrb, (struct RBasic*)c);
iv_put(mrb, t, sym, v);
return;
}
}
c = c->super;
}
c = mrb->c->ci->target_class;
if (!c->iv) {
c->iv = iv_new(mrb);
}
mrb_write_barrier(mrb, (struct RBasic*)c);
iv_put(mrb, c->iv, sym, v);
} }
mrb_bool mrb_bool
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment