diff options
author | Peter Zhu <peter@peterzhu.ca> | 2024-02-20 15:58:10 -0500 |
---|---|---|
committer | Peter Zhu <peter@peterzhu.ca> | 2024-02-21 11:33:05 -0500 |
commit | 330830dd1a44b6e497250a14d93efae6fa363f82 (patch) | |
tree | 864fc9a6ba29c91fcbeb0c9c439e99b7d7fb0a04 /vm_method.c | |
parent | 2e6f8554f8c4ec12f620f31d4a110066ee76bfbe (diff) | |
download | ruby-330830dd1a44b6e497250a14d93efae6fa363f82.tar.gz |
Add IMEMO_NEW
Rather than exposing that an imemo has a flag and four fields, this
changes the implementation to only expose one field (the klass) and
fills the rest with 0. The type will have to fill in the values themselves.
Diffstat (limited to 'vm_method.c')
-rw-r--r-- | vm_method.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/vm_method.c b/vm_method.c index bd43d7ea4d..0f69bc00fc 100644 --- a/vm_method.c +++ b/vm_method.c @@ -409,13 +409,11 @@ rb_vm_ci_lookup(ID mid, unsigned int flag, unsigned int argc, const struct rb_ca if (kwarg) { ((struct rb_callinfo_kwarg *)kwarg)->references++; } - const struct rb_callinfo *new_ci = (const struct rb_callinfo *) - rb_imemo_new( - imemo_callinfo, - (VALUE)mid, - (VALUE)flag, - (VALUE)argc, - (VALUE)kwarg); + + struct rb_callinfo *new_ci = IMEMO_NEW(struct rb_callinfo, imemo_callinfo, (VALUE)kwarg); + new_ci->mid = mid; + new_ci->flag = flag; + new_ci->argc = argc; RB_VM_LOCK_ENTER(); { @@ -764,7 +762,11 @@ static rb_method_entry_t * rb_method_entry_alloc(ID called_id, VALUE owner, VALUE defined_class, rb_method_definition_t *def, bool complement) { if (def) method_definition_addref(def, complement); - rb_method_entry_t *me = (rb_method_entry_t *)rb_imemo_new(imemo_ment, (VALUE)def, (VALUE)called_id, owner, defined_class); + rb_method_entry_t *me = IMEMO_NEW(rb_method_entry_t, imemo_ment, defined_class); + *((rb_method_definition_t **)&me->def) = def; + me->called_id = called_id; + me->owner = owner; + return me; } |