Skip to content

Commit

Permalink
check_cfunc: add assertions
Browse files Browse the repository at this point in the history
For debug.  Must not change generated binary unless VM_ASSERT is on.
  • Loading branch information
shyouhei committed Jun 9, 2020
1 parent 42a2fa3 commit 877238f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions vm_insnhelper.c
Expand Up @@ -1653,12 +1653,19 @@ vm_search_method(VALUE cd_owner, struct rb_call_data *cd, VALUE recv)
static inline int
check_cfunc(const rb_callable_method_entry_t *me, VALUE (*func)())
{
if (me && me->def->type == VM_METHOD_TYPE_CFUNC &&
me->def->body.cfunc.func == func) {
return 1;
if (! me) {
return false;
}
else {
return 0;
VM_ASSERT(IMEMO_TYPE_P(me, imemo_ment));
VM_ASSERT(callable_method_entry_p(me));
VM_ASSERT(me->def);
if (me->def->type != VM_METHOD_TYPE_CFUNC) {
return false;
}
else {
return me->def->body.cfunc.func == func;
}
}
}

Expand Down

0 comments on commit 877238f

Please sign in to comment.