mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
small refactoring (dedup mrb_vm_cv_set)
This commit is contained in:
+2
-19
@@ -756,7 +756,7 @@ mrb_cv_get(mrb_state *mrb, mrb_value mod, mrb_sym sym)
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
if (!c) c = mrb->c->ci->target_class;
|
||||
while (c) {
|
||||
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_mod_cv_set(mrb, c, sym, v);
|
||||
}
|
||||
|
||||
mrb_bool
|
||||
|
||||
Reference in New Issue
Block a user