Skip to content
Permalink
Browse files

extracted declare_under

  • Loading branch information...
nobu committed Oct 9, 2019
1 parent 8dc5fe6 commit 42edb056268303e8d2a1772cda0e46e1ba1a14bb
Showing with 10 additions and 8 deletions.
  1. +10 −8 vm_insnhelper.c
@@ -3548,15 +3548,20 @@ vm_check_if_module(ID id, VALUE mod)
}
}

static VALUE
declare_under(ID id, VALUE cbase, VALUE c)
{
rb_set_class_path_string(c, cbase, rb_id2str(id));
rb_const_set(cbase, id, c);
return c;
}

static VALUE
vm_declare_class(ID id, rb_num_t flags, VALUE cbase, VALUE super)
{
/* new class declaration */
VALUE s = VM_DEFINECLASS_HAS_SUPERCLASS_P(flags) ? super : rb_cObject;
VALUE c = rb_define_class_id(id, s);

rb_set_class_path_string(c, cbase, rb_id2str(id));
rb_const_set(cbase, id, c);
VALUE c = declare_under(id, cbase, rb_define_class_id(id, s));
rb_class_inherited(s, c);
return c;
}
@@ -3565,10 +3570,7 @@ static VALUE
vm_declare_module(ID id, VALUE cbase)
{
/* new module declaration */
VALUE mod = rb_define_module_id(id);
rb_set_class_path_string(mod, cbase, rb_id2str(id));
rb_const_set(cbase, id, mod);
return mod;
return declare_under(id, cbase, rb_define_module_id(id));
}

NORETURN(static void unmatched_redefinition(const char *type, VALUE cbase, ID id, VALUE old));

0 comments on commit 42edb05

Please sign in to comment.
You can’t perform that action at this time.