variable.c: a new function mrb_mod_const_at()

And mrb_mod_constants() use the new function now.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-04-12 16:27:42 +09:00
parent cda551ce25
commit 118e13d85c
2 changed files with 11 additions and 3 deletions
+8 -1
View File
@@ -924,6 +924,13 @@ const_i(mrb_state *mrb, mrb_sym sym, mrb_value v, void *p)
return 0;
}
mrb_value
mrb_mod_const_at(mrb_state *mrb, struct RClass *c, mrb_value ary)
{
iv_foreach(mrb, class_iv_ptr(c), const_i, &ary);
return ary;
}
/* 15.2.2.4.24 */
/*
* call-seq:
@@ -941,7 +948,7 @@ mrb_mod_constants(mrb_state *mrb, mrb_value mod)
mrb_get_args(mrb, "|b", &inherit);
ary = mrb_ary_new(mrb);
while (c) {
iv_foreach(mrb, class_iv_ptr(c), const_i, &ary);
mrb_mod_const_at(mrb, c, ary);
if (!inherit) break;
c = c->super;
if (c == mrb->object_class) break;