Use `static const struct mrb_irep each_irep` to ininitalize `each`.

parent 029c7c11
...@@ -1302,30 +1302,38 @@ static const mrb_code each_iseq[] = { ...@@ -1302,30 +1302,38 @@ static const mrb_code each_iseq[] = {
OP_RETURN, 0x0 /* OP_RETURN R3 */ OP_RETURN, 0x0 /* OP_RETURN R3 */
}; };
static const mrb_sym each_syms[] = {
MRB_SYM(each),
MRB_SYM(to_enum),
MRB_QSYM(aref),
MRB_SYM(call),
MRB_SYM(length),
};
static const mrb_irep each_irep = {
.nlocals = 3,
.nregs = 7,
.flags = MRB_ISEQ_NO_FREE | MRB_IREP_NO_FREE,
.iseq = each_iseq,
.pool = NULL,
.syms = each_syms,
.reps = NULL,
.lv = NULL,
.debug_info = NULL,
.ilen = sizeof(each_iseq),
.plen = 0,
.slen = sizeof(each_syms),
.rlen = 1,
.refcnt = 0,
};
static void static void
init_ary_each(mrb_state *mrb, struct RClass *ary) init_ary_each(mrb_state *mrb, struct RClass *ary)
{ {
struct RProc *p; struct RProc *p;
mrb_method_t m; mrb_method_t m;
mrb_irep *each_irep = (mrb_irep*)mrb_malloc(mrb, sizeof(mrb_irep));
static const mrb_irep mrb_irep_zero = { 0 }; p = mrb_proc_new(mrb, &each_irep);
mrb_sym *syms;
*each_irep = mrb_irep_zero;
syms = (mrb_sym*)mrb_malloc(mrb, sizeof(mrb_sym)*5);
syms[0] = MRB_SYM(each);
syms[1] = MRB_SYM(to_enum);
syms[2] = MRB_QSYM(aref);
syms[3] = MRB_SYM(call);
syms[4] = MRB_SYM(length);
each_irep->syms = syms;
each_irep->slen = 5;
each_irep->flags = MRB_ISEQ_NO_FREE;
each_irep->iseq = each_iseq;
each_irep->ilen = sizeof(each_iseq);
each_irep->nregs = 7;
each_irep->nlocals = 3;
p = mrb_proc_new(mrb, each_irep);
p->flags |= MRB_PROC_SCOPE | MRB_PROC_STRICT; p->flags |= MRB_PROC_SCOPE | MRB_PROC_STRICT;
MRB_METHOD_FROM_PROC(m, p); MRB_METHOD_FROM_PROC(m, p);
mrb_define_method_raw(mrb, ary, MRB_SYM(each), m); mrb_define_method_raw(mrb, ary, MRB_SYM(each), m);
......
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