From 5b21e94bebed90180d8ff63dad03b8b948361089 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Thu, 21 Jul 2022 09:23:58 -0700 Subject: Expand tabs [ci skip] [Misc #18891] --- vm_method.c | 838 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 419 insertions(+), 419 deletions(-) (limited to 'vm_method.c') diff --git a/vm_method.c b/vm_method.c index 7cd9fee754..e88a30c5f3 100644 --- a/vm_method.c +++ b/vm_method.c @@ -373,13 +373,13 @@ rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_me { if (argc < -2 || 15 < argc) rb_raise(rb_eArgError, "arity out of range: %d for -2..15", argc); if (func != rb_f_notimplement) { - rb_method_cfunc_t opt; - opt.func = func; - opt.argc = argc; + rb_method_cfunc_t opt; + opt.func = func; + opt.argc = argc; rb_add_method(klass, mid, VM_METHOD_TYPE_CFUNC, &opt, visi); } else { - rb_define_notimplement_method_id(klass, mid, visi); + rb_define_notimplement_method_id(klass, mid, visi); } } @@ -397,20 +397,20 @@ static void rb_method_definition_release(rb_method_definition_t *def, int complemented) { if (def != NULL) { - const int alias_count = def->alias_count; - const int complemented_count = def->complemented_count; - VM_ASSERT(alias_count >= 0); - VM_ASSERT(complemented_count >= 0); + const int alias_count = def->alias_count; + const int complemented_count = def->complemented_count; + VM_ASSERT(alias_count >= 0); + VM_ASSERT(complemented_count >= 0); - if (alias_count + complemented_count == 0) { + if (alias_count + complemented_count == 0) { if (METHOD_DEBUG) fprintf(stderr, "-%p-%s:%d,%d (remove)\n", (void *)def, rb_id2name(def->original_id), alias_count, complemented_count); if (def->type == VM_METHOD_TYPE_BMETHOD && def->body.bmethod.hooks) { xfree(def->body.bmethod.hooks); } - xfree(def); - } - else { + xfree(def); + } + else { if (complemented) { VM_ASSERT(def->complemented_count > 0); def->complemented_count--; @@ -419,9 +419,9 @@ rb_method_definition_release(rb_method_definition_t *def, int complemented) def->alias_count--; } - if (METHOD_DEBUG) fprintf(stderr, "-%p-%s:%d->%d,%d->%d (dec)\n", (void *)def, rb_id2name(def->original_id), - alias_count, def->alias_count, complemented_count, def->complemented_count); - } + if (METHOD_DEBUG) fprintf(stderr, "-%p-%s:%d->%d,%d->%d (dec)\n", (void *)def, rb_id2name(def->original_id), + alias_count, def->alias_count, complemented_count, def->complemented_count); + } } } @@ -506,81 +506,81 @@ rb_method_definition_set(const rb_method_entry_t *me, rb_method_definition_t *de *(rb_method_definition_t **)&me->def = def; if (opts != NULL) { - switch (def->type) { - case VM_METHOD_TYPE_ISEQ: - { - rb_method_iseq_t *iseq_body = (rb_method_iseq_t *)opts; + switch (def->type) { + case VM_METHOD_TYPE_ISEQ: + { + rb_method_iseq_t *iseq_body = (rb_method_iseq_t *)opts; const rb_iseq_t *iseq = iseq_body->iseqptr; - rb_cref_t *method_cref, *cref = iseq_body->cref; + rb_cref_t *method_cref, *cref = iseq_body->cref; - /* setup iseq first (before invoking GC) */ - RB_OBJ_WRITE(me, &def->body.iseq.iseqptr, iseq); + /* setup iseq first (before invoking GC) */ + RB_OBJ_WRITE(me, &def->body.iseq.iseqptr, iseq); if (ISEQ_BODY(iseq)->mandatory_only_iseq) def->iseq_overload = 1; - if (0) vm_cref_dump("rb_method_definition_create", cref); - - if (cref) { - method_cref = cref; - } - else { - method_cref = vm_cref_new_toplevel(GET_EC()); /* TODO: can we reuse? */ - } - - RB_OBJ_WRITE(me, &def->body.iseq.cref, method_cref); - return; - } - case VM_METHOD_TYPE_CFUNC: - { - rb_method_cfunc_t *cfunc = (rb_method_cfunc_t *)opts; - setup_method_cfunc_struct(UNALIGNED_MEMBER_PTR(def, body.cfunc), cfunc->func, cfunc->argc); - return; - } - case VM_METHOD_TYPE_ATTRSET: - case VM_METHOD_TYPE_IVAR: - { - const rb_execution_context_t *ec = GET_EC(); - rb_control_frame_t *cfp; - int line; - - def->body.attr.id = (ID)(VALUE)opts; - - cfp = rb_vm_get_ruby_level_next_cfp(ec, ec->cfp); - - if (cfp && (line = rb_vm_get_sourceline(cfp))) { - VALUE location = rb_ary_new3(2, rb_iseq_path(cfp->iseq), INT2FIX(line)); - RB_OBJ_WRITE(me, &def->body.attr.location, rb_ary_freeze(location)); - } - else { - VM_ASSERT(def->body.attr.location == 0); - } - return; - } - case VM_METHOD_TYPE_BMETHOD: + if (0) vm_cref_dump("rb_method_definition_create", cref); + + if (cref) { + method_cref = cref; + } + else { + method_cref = vm_cref_new_toplevel(GET_EC()); /* TODO: can we reuse? */ + } + + RB_OBJ_WRITE(me, &def->body.iseq.cref, method_cref); + return; + } + case VM_METHOD_TYPE_CFUNC: + { + rb_method_cfunc_t *cfunc = (rb_method_cfunc_t *)opts; + setup_method_cfunc_struct(UNALIGNED_MEMBER_PTR(def, body.cfunc), cfunc->func, cfunc->argc); + return; + } + case VM_METHOD_TYPE_ATTRSET: + case VM_METHOD_TYPE_IVAR: + { + const rb_execution_context_t *ec = GET_EC(); + rb_control_frame_t *cfp; + int line; + + def->body.attr.id = (ID)(VALUE)opts; + + cfp = rb_vm_get_ruby_level_next_cfp(ec, ec->cfp); + + if (cfp && (line = rb_vm_get_sourceline(cfp))) { + VALUE location = rb_ary_new3(2, rb_iseq_path(cfp->iseq), INT2FIX(line)); + RB_OBJ_WRITE(me, &def->body.attr.location, rb_ary_freeze(location)); + } + else { + VM_ASSERT(def->body.attr.location == 0); + } + return; + } + case VM_METHOD_TYPE_BMETHOD: RB_OBJ_WRITE(me, &def->body.bmethod.proc, (VALUE)opts); RB_OBJ_WRITE(me, &def->body.bmethod.defined_ractor, rb_ractor_self(GET_RACTOR())); - return; - case VM_METHOD_TYPE_NOTIMPLEMENTED: - setup_method_cfunc_struct(UNALIGNED_MEMBER_PTR(def, body.cfunc), rb_f_notimplement_internal, -1); - return; - case VM_METHOD_TYPE_OPTIMIZED: + return; + case VM_METHOD_TYPE_NOTIMPLEMENTED: + setup_method_cfunc_struct(UNALIGNED_MEMBER_PTR(def, body.cfunc), rb_f_notimplement_internal, -1); + return; + case VM_METHOD_TYPE_OPTIMIZED: def->body.optimized = *(rb_method_optimized_t *)opts; - return; - case VM_METHOD_TYPE_REFINED: - { - const rb_method_refined_t *refined = (rb_method_refined_t *)opts; - RB_OBJ_WRITE(me, &def->body.refined.orig_me, refined->orig_me); - RB_OBJ_WRITE(me, &def->body.refined.owner, refined->owner); - return; - } - case VM_METHOD_TYPE_ALIAS: - RB_OBJ_WRITE(me, &def->body.alias.original_me, (rb_method_entry_t *)opts); - return; - case VM_METHOD_TYPE_ZSUPER: - case VM_METHOD_TYPE_UNDEF: - case VM_METHOD_TYPE_MISSING: - return; - } + return; + case VM_METHOD_TYPE_REFINED: + { + const rb_method_refined_t *refined = (rb_method_refined_t *)opts; + RB_OBJ_WRITE(me, &def->body.refined.orig_me, refined->orig_me); + RB_OBJ_WRITE(me, &def->body.refined.owner, refined->owner); + return; + } + case VM_METHOD_TYPE_ALIAS: + RB_OBJ_WRITE(me, &def->body.alias.original_me, (rb_method_entry_t *)opts); + return; + case VM_METHOD_TYPE_ZSUPER: + case VM_METHOD_TYPE_UNDEF: + case VM_METHOD_TYPE_MISSING: + return; + } } } @@ -591,33 +591,33 @@ method_definition_reset(const rb_method_entry_t *me) switch (def->type) { case VM_METHOD_TYPE_ISEQ: - RB_OBJ_WRITTEN(me, Qundef, def->body.iseq.iseqptr); - RB_OBJ_WRITTEN(me, Qundef, def->body.iseq.cref); + RB_OBJ_WRITTEN(me, Qundef, def->body.iseq.iseqptr); + RB_OBJ_WRITTEN(me, Qundef, def->body.iseq.cref); break; case VM_METHOD_TYPE_ATTRSET: case VM_METHOD_TYPE_IVAR: - RB_OBJ_WRITTEN(me, Qundef, def->body.attr.location); - break; + RB_OBJ_WRITTEN(me, Qundef, def->body.attr.location); + break; case VM_METHOD_TYPE_BMETHOD: RB_OBJ_WRITTEN(me, Qundef, def->body.bmethod.proc); RB_OBJ_WRITTEN(me, Qundef, def->body.bmethod.defined_ractor); /* give up to check all in a list */ if (def->body.bmethod.hooks) rb_gc_writebarrier_remember((VALUE)me); - break; + break; case VM_METHOD_TYPE_REFINED: - RB_OBJ_WRITTEN(me, Qundef, def->body.refined.orig_me); - RB_OBJ_WRITTEN(me, Qundef, def->body.refined.owner); - break; + RB_OBJ_WRITTEN(me, Qundef, def->body.refined.orig_me); + RB_OBJ_WRITTEN(me, Qundef, def->body.refined.owner); + break; case VM_METHOD_TYPE_ALIAS: - RB_OBJ_WRITTEN(me, Qundef, def->body.alias.original_me); - break; + RB_OBJ_WRITTEN(me, Qundef, def->body.alias.original_me); + break; case VM_METHOD_TYPE_CFUNC: case VM_METHOD_TYPE_ZSUPER: case VM_METHOD_TYPE_MISSING: case VM_METHOD_TYPE_OPTIMIZED: case VM_METHOD_TYPE_UNDEF: case VM_METHOD_TYPE_NOTIMPLEMENTED: - break; + break; } } @@ -661,11 +661,11 @@ filter_defined_class(VALUE klass) { switch (BUILTIN_TYPE(klass)) { case T_CLASS: - return klass; + return klass; case T_MODULE: - return 0; + return 0; case T_ICLASS: - break; + break; default: break; } @@ -700,29 +700,29 @@ rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID cal rb_method_definition_t *def = src_me->def; rb_method_entry_t *me; struct { - const struct rb_method_entry_struct *orig_me; - VALUE owner; + const struct rb_method_entry_struct *orig_me; + VALUE owner; } refined = {0}; if (!src_me->defined_class && - def->type == VM_METHOD_TYPE_REFINED && - def->body.refined.orig_me) { - const rb_method_entry_t *orig_me = - rb_method_entry_clone(def->body.refined.orig_me); - RB_OBJ_WRITE((VALUE)orig_me, &orig_me->defined_class, defined_class); - refined.orig_me = orig_me; - refined.owner = orig_me->owner; - def = NULL; + def->type == VM_METHOD_TYPE_REFINED && + def->body.refined.orig_me) { + const rb_method_entry_t *orig_me = + rb_method_entry_clone(def->body.refined.orig_me); + RB_OBJ_WRITE((VALUE)orig_me, &orig_me->defined_class, defined_class); + refined.orig_me = orig_me; + refined.owner = orig_me->owner; + def = NULL; } else { - def = method_definition_addref_complement(def); + def = method_definition_addref_complement(def); } me = rb_method_entry_alloc(called_id, src_me->owner, defined_class, def); METHOD_ENTRY_FLAGS_COPY(me, src_me); METHOD_ENTRY_COMPLEMENTED_SET(me); if (!def) { - def = rb_method_definition_create(VM_METHOD_TYPE_REFINED, called_id); - rb_method_definition_set(me, def, &refined); + def = rb_method_definition_create(VM_METHOD_TYPE_REFINED, called_id); + rb_method_definition_set(me, def, &refined); } VM_ASSERT(RB_TYPE_P(me->owner, T_MODULE)); @@ -745,28 +745,28 @@ static void make_method_entry_refined(VALUE owner, rb_method_entry_t *me) { if (me->def->type == VM_METHOD_TYPE_REFINED) { - return; + return; } else { - struct { - struct rb_method_entry_struct *orig_me; - VALUE owner; - } refined; - rb_method_definition_t *def; + struct { + struct rb_method_entry_struct *orig_me; + VALUE owner; + } refined; + rb_method_definition_t *def; - rb_vm_check_redefinition_opt_method(me, me->owner); + rb_vm_check_redefinition_opt_method(me, me->owner); - refined.orig_me = - rb_method_entry_alloc(me->called_id, me->owner, - me->defined_class ? - me->defined_class : owner, - method_definition_addref(me->def)); - METHOD_ENTRY_FLAGS_COPY(refined.orig_me, me); - refined.owner = owner; + refined.orig_me = + rb_method_entry_alloc(me->called_id, me->owner, + me->defined_class ? + me->defined_class : owner, + method_definition_addref(me->def)); + METHOD_ENTRY_FLAGS_COPY(refined.orig_me, me); + refined.owner = owner; - def = rb_method_definition_create(VM_METHOD_TYPE_REFINED, me->called_id); - rb_method_definition_set(me, def, (void *)&refined); - METHOD_ENTRY_VISI_SET(me, METHOD_VISI_PUBLIC); + def = rb_method_definition_create(VM_METHOD_TYPE_REFINED, me->called_id); + rb_method_definition_set(me, def, (void *)&refined); + METHOD_ENTRY_VISI_SET(me, METHOD_VISI_PUBLIC); } } @@ -777,10 +777,10 @@ lookup_method_table(VALUE klass, ID id) struct rb_id_table *m_tbl = RCLASS_M_TBL(klass); if (rb_id_table_lookup(m_tbl, id, &body)) { - return (rb_method_entry_t *) body; + return (rb_method_entry_t *) body; } else { - return 0; + return 0; } } @@ -790,11 +790,11 @@ rb_add_refined_method_entry(VALUE refined_class, ID mid) rb_method_entry_t *me = lookup_method_table(refined_class, mid); if (me) { - make_method_entry_refined(refined_class, me); - rb_clear_method_cache(refined_class, mid); + make_method_entry_refined(refined_class, me); + rb_clear_method_cache(refined_class, mid); } else { - rb_add_method(refined_class, mid, VM_METHOD_TYPE_REFINED, 0, METHOD_VISI_PUBLIC); + rb_add_method(refined_class, mid, VM_METHOD_TYPE_REFINED, 0, METHOD_VISI_PUBLIC); } } @@ -805,11 +805,11 @@ check_override_opt_method_i(VALUE klass, VALUE arg) const rb_method_entry_t *me, *newme; if (vm_redefinition_check_flag(klass)) { - me = lookup_method_table(RCLASS_ORIGIN(klass), mid); - if (me) { - newme = rb_method_entry(klass, mid); - if (newme != me) rb_vm_check_redefinition_opt_method(me, me->owner); - } + me = lookup_method_table(RCLASS_ORIGIN(klass), mid); + if (me) { + newme = rb_method_entry(klass, mid); + if (newme != me) rb_vm_check_redefinition_opt_method(me, me->owner); + } } rb_class_foreach_subclass(klass, check_override_opt_method_i, (VALUE)mid); } @@ -830,7 +830,7 @@ check_override_opt_method(VALUE klass, VALUE mid) */ static rb_method_entry_t * rb_method_entry_make(VALUE klass, ID mid, VALUE defined_class, rb_method_visibility_t visi, - rb_method_type_t type, rb_method_definition_t *def, ID original_id, void *opts) + rb_method_type_t type, rb_method_definition_t *def, ID original_id, void *opts) { rb_method_entry_t *me; struct rb_id_table *mtbl; @@ -839,21 +839,21 @@ rb_method_entry_make(VALUE klass, ID mid, VALUE defined_class, rb_method_visibil VALUE orig_klass; if (NIL_P(klass)) { - klass = rb_cObject; + klass = rb_cObject; } orig_klass = klass; if (!FL_TEST(klass, FL_SINGLETON) && - type != VM_METHOD_TYPE_NOTIMPLEMENTED && - type != VM_METHOD_TYPE_ZSUPER) { - switch (mid) { - case idInitialize: - case idInitialize_copy: - case idInitialize_clone: - case idInitialize_dup: - case idRespond_to_missing: - visi = METHOD_VISI_PRIVATE; - } + type != VM_METHOD_TYPE_NOTIMPLEMENTED && + type != VM_METHOD_TYPE_ZSUPER) { + switch (mid) { + case idInitialize: + case idInitialize_copy: + case idInitialize_clone: + case idInitialize_dup: + case idRespond_to_missing: + visi = METHOD_VISI_PRIVATE; + } } if (type != VM_METHOD_TYPE_REFINED) { @@ -861,15 +861,15 @@ rb_method_entry_make(VALUE klass, ID mid, VALUE defined_class, rb_method_visibil } if (RB_TYPE_P(klass, T_MODULE) && FL_TEST(klass, RMODULE_IS_REFINEMENT)) { - VALUE refined_class = rb_refinement_module_get_refined_class(klass); - rb_add_refined_method_entry(refined_class, mid); + VALUE refined_class = rb_refinement_module_get_refined_class(klass); + rb_add_refined_method_entry(refined_class, mid); } if (type == VM_METHOD_TYPE_REFINED) { - rb_method_entry_t *old_me = lookup_method_table(RCLASS_ORIGIN(klass), mid); - if (old_me) rb_vm_check_redefinition_opt_method(old_me, klass); + rb_method_entry_t *old_me = lookup_method_table(RCLASS_ORIGIN(klass), mid); + if (old_me) rb_vm_check_redefinition_opt_method(old_me, klass); } else { - klass = RCLASS_ORIGIN(klass); + klass = RCLASS_ORIGIN(klass); if (klass != orig_klass) { rb_clear_method_cache(orig_klass, mid); } @@ -878,42 +878,42 @@ rb_method_entry_make(VALUE klass, ID mid, VALUE defined_class, rb_method_visibil /* check re-definition */ if (rb_id_table_lookup(mtbl, mid, &data)) { - rb_method_entry_t *old_me = (rb_method_entry_t *)data; - rb_method_definition_t *old_def = old_me->def; - - if (rb_method_definition_eq(old_def, def)) return old_me; - rb_vm_check_redefinition_opt_method(old_me, klass); - - if (old_def->type == VM_METHOD_TYPE_REFINED) make_refined = 1; - - if (RTEST(ruby_verbose) && - type != VM_METHOD_TYPE_UNDEF && - (old_def->alias_count == 0) && - (!old_def->no_redef_warning) && - !make_refined && - old_def->type != VM_METHOD_TYPE_UNDEF && - old_def->type != VM_METHOD_TYPE_ZSUPER && - old_def->type != VM_METHOD_TYPE_ALIAS) { - const rb_iseq_t *iseq = 0; - - rb_warning("method redefined; discarding old %"PRIsVALUE, rb_id2str(mid)); - switch (old_def->type) { - case VM_METHOD_TYPE_ISEQ: - iseq = def_iseq_ptr(old_def); - break; - case VM_METHOD_TYPE_BMETHOD: + rb_method_entry_t *old_me = (rb_method_entry_t *)data; + rb_method_definition_t *old_def = old_me->def; + + if (rb_method_definition_eq(old_def, def)) return old_me; + rb_vm_check_redefinition_opt_method(old_me, klass); + + if (old_def->type == VM_METHOD_TYPE_REFINED) make_refined = 1; + + if (RTEST(ruby_verbose) && + type != VM_METHOD_TYPE_UNDEF && + (old_def->alias_count == 0) && + (!old_def->no_redef_warning) && + !make_refined && + old_def->type != VM_METHOD_TYPE_UNDEF && + old_def->type != VM_METHOD_TYPE_ZSUPER && + old_def->type != VM_METHOD_TYPE_ALIAS) { + const rb_iseq_t *iseq = 0; + + rb_warning("method redefined; discarding old %"PRIsVALUE, rb_id2str(mid)); + switch (old_def->type) { + case VM_METHOD_TYPE_ISEQ: + iseq = def_iseq_ptr(old_def); + break; + case VM_METHOD_TYPE_BMETHOD: iseq = rb_proc_get_iseq(old_def->body.bmethod.proc, 0); - break; - default: - break; - } - if (iseq) { - rb_compile_warning(RSTRING_PTR(rb_iseq_path(iseq)), + break; + default: + break; + } + if (iseq) { + rb_compile_warning(RSTRING_PTR(rb_iseq_path(iseq)), FIX2INT(ISEQ_BODY(iseq)->location.first_lineno), - "previous definition of %"PRIsVALUE" was here", - rb_id2str(old_def->original_id)); - } - } + "previous definition of %"PRIsVALUE" was here", + rb_id2str(old_def->original_id)); + } + } } /* create method entry */ @@ -935,13 +935,13 @@ rb_method_entry_make(VALUE klass, ID mid, VALUE defined_class, rb_method_visibil } /* check mid */ if (mid == object_id || mid == id__send__) { - if (type == VM_METHOD_TYPE_ISEQ && search_method(klass, mid, 0)) { - rb_warn("redefining `%s' may cause serious problems", rb_id2name(mid)); - } + if (type == VM_METHOD_TYPE_ISEQ && search_method(klass, mid, 0)) { + rb_warn("redefining `%s' may cause serious problems", rb_id2name(mid)); + } } if (make_refined) { - make_method_entry_refined(klass, me); + make_method_entry_refined(klass, me); } rb_method_table_insert(klass, mtbl, mid, me); @@ -950,7 +950,7 @@ rb_method_entry_make(VALUE klass, ID mid, VALUE defined_class, rb_method_visibil /* check optimized method override by a prepended module */ if (RB_TYPE_P(orig_klass, T_MODULE)) { - check_override_opt_method(klass, (VALUE)mid); + check_override_opt_method(klass, (VALUE)mid); } return me; @@ -1074,21 +1074,21 @@ check_overloaded_cme(const rb_callable_method_entry_t *cme, const struct rb_call } #define CALL_METHOD_HOOK(klass, hook, mid) do { \ - const VALUE arg = ID2SYM(mid); \ - VALUE recv_class = (klass); \ - ID hook_id = (hook); \ - if (FL_TEST((klass), FL_SINGLETON)) { \ - recv_class = rb_ivar_get((klass), attached); \ - hook_id = singleton_##hook; \ - } \ - rb_funcallv(recv_class, hook_id, 1, &arg); \ + const VALUE arg = ID2SYM(mid); \ + VALUE recv_class = (klass); \ + ID hook_id = (hook); \ + if (FL_TEST((klass), FL_SINGLETON)) { \ + recv_class = rb_ivar_get((klass), attached); \ + hook_id = singleton_##hook; \ + } \ + rb_funcallv(recv_class, hook_id, 1, &arg); \ } while (0) static void method_added(VALUE klass, ID mid) { if (ruby_running) { - CALL_METHOD_HOOK(klass, added, mid); + CALL_METHOD_HOOK(klass, added, mid); } } @@ -1098,7 +1098,7 @@ rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_ rb_method_entry_make(klass, mid, klass, visi, type, NULL, mid, opts); if (type != VM_METHOD_TYPE_UNDEF && type != VM_METHOD_TYPE_REFINED) { - method_added(klass, mid); + method_added(klass, mid); } } @@ -1118,10 +1118,10 @@ rb_add_method_iseq(VALUE klass, ID mid, const rb_iseq_t *iseq, rb_cref_t *cref, static rb_method_entry_t * method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *me, - rb_method_visibility_t visi, VALUE defined_class) + rb_method_visibility_t visi, VALUE defined_class) { rb_method_entry_t *newme = rb_method_entry_make(klass, mid, defined_class, visi, - me->def->type, me->def, 0, NULL); + me->def->type, me->def, 0, NULL); if (newme == me) { me->def->no_redef_warning = TRUE; } @@ -1159,9 +1159,9 @@ rb_get_alloc_func(VALUE klass) Check_Type(klass, T_CLASS); for (; klass; klass = RCLASS_SUPER(klass)) { - rb_alloc_func_t allocator = RCLASS_ALLOCATOR(klass); - if (allocator == UNDEF_ALLOC_FUNC) break; - if (allocator) return allocator; + rb_alloc_func_t allocator = RCLASS_ALLOCATOR(klass); + if (allocator == UNDEF_ALLOC_FUNC) break; + if (allocator) return allocator; } return 0; } @@ -1180,7 +1180,7 @@ search_method0(VALUE klass, ID id, VALUE *defined_class_ptr, bool skip_refined) RB_DEBUG_COUNTER_INC(mc_search); for (; klass; klass = RCLASS_SUPER(klass)) { - RB_DEBUG_COUNTER_INC(mc_search_super); + RB_DEBUG_COUNTER_INC(mc_search_super); if ((me = lookup_method_table(klass, id)) != 0) { if (!skip_refined || me->def->type != VM_METHOD_TYPE_REFINED || me->def->body.refined.orig_me) { @@ -1393,18 +1393,18 @@ method_entry_resolve_refinement(VALUE klass, ID id, int with_refinement, VALUE * const rb_method_entry_t *me = search_method_protect(klass, id, defined_class_ptr); if (me) { - if (me->def->type == VM_METHOD_TYPE_REFINED) { - if (with_refinement) { - const rb_cref_t *cref = rb_vm_cref(); - VALUE refinements = cref ? CREF_REFINEMENTS(cref) : Qnil; - me = resolve_refined_method(refinements, me, defined_class_ptr); - } - else { - me = resolve_refined_method(Qnil, me, defined_class_ptr); - } + if (me->def->type == VM_METHOD_TYPE_REFINED) { + if (with_refinement) { + const rb_cref_t *cref = rb_vm_cref(); + VALUE refinements = cref ? CREF_REFINEMENTS(cref) : Qnil; + me = resolve_refined_method(refinements, me, defined_class_ptr); + } + else { + me = resolve_refined_method(Qnil, me, defined_class_ptr); + } - if (UNDEFINED_METHOD_ENTRY_P(me)) me = NULL; - } + if (UNDEFINED_METHOD_ENTRY_P(me)) me = NULL; + } } return me; @@ -1467,18 +1467,18 @@ static const rb_method_entry_t * resolve_refined_method(VALUE refinements, const rb_method_entry_t *me, VALUE *defined_class_ptr) { while (me && me->def->type == VM_METHOD_TYPE_REFINED) { - VALUE refinement; + VALUE refinement; const rb_method_entry_t *tmp_me; VALUE super; - refinement = find_refinement(refinements, me->owner); + refinement = find_refinement(refinements, me->owner); if (!NIL_P(refinement)) { - tmp_me = search_method_protect(refinement, me->called_id, defined_class_ptr); + tmp_me = search_method_protect(refinement, me->called_id, defined_class_ptr); - if (tmp_me && tmp_me->def->type != VM_METHOD_TYPE_REFINED) { - return tmp_me; - } - } + if (tmp_me && tmp_me->def->type != VM_METHOD_TYPE_REFINED) { + return tmp_me; + } + } tmp_me = me->def->body.refined.orig_me; if (tmp_me) { @@ -1510,10 +1510,10 @@ rb_resolve_refined_method_callable(VALUE refinements, const rb_callable_method_e const rb_method_entry_t *resolved_me = resolve_refined_method(refinements, (const rb_method_entry_t *)me, &defined_class); if (resolved_me && resolved_me->defined_class == 0) { - return rb_method_entry_complement_defined_class(resolved_me, me->called_id, defined_class); + return rb_method_entry_complement_defined_class(resolved_me, me->called_id, defined_class); } else { - return (const rb_callable_method_entry_t *)resolved_me; + return (const rb_callable_method_entry_t *)resolved_me; } } @@ -1527,15 +1527,15 @@ remove_method(VALUE klass, ID mid) klass = RCLASS_ORIGIN(klass); rb_class_modify_check(klass); if (mid == object_id || mid == id__send__ || mid == idInitialize) { - rb_warn("removing `%s' may cause serious problems", rb_id2name(mid)); + rb_warn("removing `%s' may cause serious problems", rb_id2name(mid)); } if (!rb_id_table_lookup(RCLASS_M_TBL(klass), mid, &data) || - !(me = (rb_method_entry_t *)data) || - (!me->def || me->def->type == VM_METHOD_TYPE_UNDEF) || + !(me = (rb_method_entry_t *)data) || + (!me->def || me->def->type == VM_METHOD_TYPE_UNDEF) || UNDEFINED_REFINED_METHOD_P(me->def)) { - rb_name_err_raise("method `%1$s' not defined in %2$s", - klass, ID2SYM(mid)); + rb_name_err_raise("method `%1$s' not defined in %2$s", + klass, ID2SYM(mid)); } if (klass != self) { @@ -1547,7 +1547,7 @@ remove_method(VALUE klass, ID mid) rb_vm_check_redefinition_opt_method(me, klass); if (me->def->type == VM_METHOD_TYPE_REFINED) { - rb_add_refined_method_entry(klass, mid); + rb_add_refined_method_entry(klass, mid); } CALL_METHOD_HOOK(self, removed, mid); @@ -1581,13 +1581,13 @@ rb_mod_remove_method(int argc, VALUE *argv, VALUE mod) int i; for (i = 0; i < argc; i++) { - VALUE v = argv[i]; - ID id = rb_check_id(&v); - if (!id) { - rb_name_err_raise("method `%1$s' not defined in %2$s", - mod, v); - } - remove_method(mod, id); + VALUE v = argv[i]; + ID id = rb_check_id(&v); + if (!id) { + rb_name_err_raise("method `%1$s' not defined in %2$s", + mod, v); + } + remove_method(mod, id); } return mod; } @@ -1602,18 +1602,18 @@ rb_export_method(VALUE klass, ID name, rb_method_visibility_t visi) me = search_method0(origin_class, name, &defined_class, true); if (!me && RB_TYPE_P(klass, T_MODULE)) { - me = search_method(rb_cObject, name, &defined_class); + me = search_method(rb_cObject, name, &defined_class); } if (UNDEFINED_METHOD_ENTRY_P(me) || - UNDEFINED_REFINED_METHOD_P(me->def)) { - rb_print_undef(klass, name, METHOD_VISI_UNDEF); + UNDEFINED_REFINED_METHOD_P(me->def)) { + rb_print_undef(klass, name, METHOD_VISI_UNDEF); } if (METHOD_ENTRY_VISI(me) != visi) { - rb_vm_check_redefinition_opt_method(me, klass); + rb_vm_check_redefinition_opt_method(me, klass); - if (klass == defined_class || origin_class == defined_class) { + if (klass == defined_class || origin_class == defined_class) { if (me->def->type == VM_METHOD_TYPE_REFINED) { // Refinement method entries should always be public because the refinement // search is always performed. @@ -1625,10 +1625,10 @@ rb_export_method(VALUE klass, ID name, rb_method_visibility_t visi) METHOD_ENTRY_VISI_SET(me, visi); } rb_clear_method_cache(klass, name); - } - else { - rb_add_method(klass, name, VM_METHOD_TYPE_ZSUPER, 0, visi); - } + } + else { + rb_add_method(klass, name, VM_METHOD_TYPE_ZSUPER, 0, visi); + } } } @@ -1659,13 +1659,13 @@ method_boundp(VALUE klass, ID id, int ex) default: break; } - } + } - if (cme->def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) { - if (ex & BOUND_RESPONDS) return 2; - return 0; - } - return 1; + if (cme->def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) { + if (ex & BOUND_RESPONDS) return 2; + return 0; + } + return 1; } return 0; } @@ -1719,31 +1719,31 @@ rb_attr(VALUE klass, ID id, int read, int write, int ex) const rb_cref_t *cref = rb_vm_cref_in_context(klass, klass); if (!ex || !cref) { - visi = METHOD_VISI_PUBLIC; + visi = METHOD_VISI_PUBLIC; } else { switch (vm_scope_visibility_get(ec)) { - case METHOD_VISI_PRIVATE: + case METHOD_VISI_PRIVATE: if (vm_scope_module_func_check(ec)) { - rb_warning("attribute accessor as module_function"); - } - visi = METHOD_VISI_PRIVATE; - break; - case METHOD_VISI_PROTECTED: - visi = METHOD_VISI_PROTECTED; - break; - default: - visi = METHOD_VISI_PUBLIC; - break; - } + rb_warning("attribute accessor as module_function"); + } + visi = METHOD_VISI_PRIVATE; + break; + case METHOD_VISI_PROTECTED: + visi = METHOD_VISI_PROTECTED; + break; + default: + visi = METHOD_VISI_PUBLIC; + break; + } } attriv = rb_intern_str(rb_sprintf("@%"PRIsVALUE, rb_id2str(id))); if (read) { - rb_add_method(klass, id, VM_METHOD_TYPE_IVAR, (void *)attriv, visi); + rb_add_method(klass, id, VM_METHOD_TYPE_IVAR, (void *)attriv, visi); } if (write) { - rb_add_method(klass, rb_id_attrset(id), VM_METHOD_TYPE_ATTRSET, (void *)attriv, visi); + rb_add_method(klass, rb_id_attrset(id), VM_METHOD_TYPE_ATTRSET, (void *)attriv, visi); } } @@ -1753,21 +1753,21 @@ rb_undef(VALUE klass, ID id) const rb_method_entry_t *me; if (NIL_P(klass)) { - rb_raise(rb_eTypeError, "no class to undef method"); + rb_raise(rb_eTypeError, "no class to undef method"); } rb_class_modify_check(klass); if (id == object_id || id == id__send__ || id == idInitialize) { - rb_warn("undefining `%s' may cause serious problems", rb_id2name(id)); + rb_warn("undefining `%s' may cause serious problems", rb_id2name(id)); } me = search_method(klass, id, 0); if (me && me->def->type == VM_METHOD_TYPE_REFINED) { - me = rb_resolve_refined_method(Qnil, me); + me = rb_resolve_refined_method(Qnil, me); } if (UNDEFINED_METHOD_ENTRY_P(me) || - UNDEFINED_REFINED_METHOD_P(me->def)) { - rb_method_name_error(klass, rb_id2str(id)); + UNDEFINED_REFINED_METHOD_P(me->def)) { + rb_method_name_error(klass, rb_id2str(id)); } rb_add_method(klass, id, VM_METHOD_TYPE_UNDEF, 0, METHOD_VISI_PUBLIC); @@ -1825,12 +1825,12 @@ rb_mod_undef_method(int argc, VALUE *argv, VALUE mod) { int i; for (i = 0; i < argc; i++) { - VALUE v = argv[i]; - ID id = rb_check_id(&v); - if (!id) { - rb_method_name_error(mod, v); - } - rb_undef(mod, id); + VALUE v = argv[i]; + ID id = rb_check_id(&v); + if (!id) { + rb_method_name_error(mod, v); + } + rb_undef(mod, id); } return mod; } @@ -1848,20 +1848,20 @@ check_definition_visibility(VALUE mod, int argc, VALUE *argv) if (!id) return METHOD_VISI_UNDEF; if (argc == 1) { - inc_super = 1; + inc_super = 1; } else { - inc_super = RTEST(include_super); - if (!inc_super) { - lookup_mod = RCLASS_ORIGIN(mod); - } + inc_super = RTEST(include_super); + if (!inc_super) { + lookup_mod = RCLASS_ORIGIN(mod); + } } me = rb_method_entry_without_refinements(lookup_mod, id, NULL); if (me) { - if (me->def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) return METHOD_VISI_UNDEF; - if (!inc_super && me->owner != mod) return METHOD_VISI_UNDEF; - return METHOD_ENTRY_VISI(me); + if (me->def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) return METHOD_VISI_UNDEF; + if (!inc_super && me->owner != mod) return METHOD_VISI_UNDEF; + return METHOD_ENTRY_VISI(me); } return METHOD_VISI_UNDEF; } @@ -2034,19 +2034,19 @@ original_method_definition(const rb_method_definition_t *def) { again: if (def) { - switch (def->type) { - case VM_METHOD_TYPE_REFINED: - if (def->body.refined.orig_me) { - def = def->body.refined.orig_me->def; - goto again; - } - break; - case VM_METHOD_TYPE_ALIAS: - def = def->body.alias.original_me->def; - goto again; - default: - break; - } + switch (def->type) { + case VM_METHOD_TYPE_REFINED: + if (def->body.refined.orig_me) { + def = def->body.refined.orig_me->def; + goto again; + } + break; + case VM_METHOD_TYPE_ALIAS: + def = def->body.alias.original_me->def; + goto again; + default: + break; + } } return def; } @@ -2065,26 +2065,26 @@ rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_defini case VM_METHOD_TYPE_ISEQ: return d1->body.iseq.iseqptr == d2->body.iseq.iseqptr; case VM_METHOD_TYPE_CFUNC: - return - d1->body.cfunc.func == d2->body.cfunc.func && - d1->body.cfunc.argc == d2->body.cfunc.argc; + return + d1->body.cfunc.func == d2->body.cfunc.func && + d1->body.cfunc.argc == d2->body.cfunc.argc; case VM_METHOD_TYPE_ATTRSET: case VM_METHOD_TYPE_IVAR: - return d1->body.attr.id == d2->body.attr.id; + return d1->body.attr.id == d2->body.attr.id; case VM_METHOD_TYPE_BMETHOD: return RTEST(rb_equal(d1->body.bmethod.proc, d2->body.bmethod.proc)); case VM_METHOD_TYPE_MISSING: - return d1->original_id == d2->original_id; + return d1->original_id == d2->original_id; case VM_METHOD_TYPE_ZSUPER: case VM_METHOD_TYPE_NOTIMPLEMENTED: case VM_METHOD_TYPE_UNDEF: - return 1; + return 1; case VM_METHOD_TYPE_OPTIMIZED: - return (d1->body.optimized.type == d2->body.optimized.type) && + return (d1->body.optimized.type == d2->body.optimized.type) && (d1->body.optimized.index == d2->body.optimized.index); case VM_METHOD_TYPE_REFINED: case VM_METHOD_TYPE_ALIAS: - break; + break; } rb_bug("rb_method_definition_eq: unsupported type: %d\n", d1->type); } @@ -2099,27 +2099,27 @@ rb_hash_method_definition(st_index_t hash, const rb_method_definition_t *def) switch (def->type) { case VM_METHOD_TYPE_ISEQ: - return rb_hash_uint(hash, (st_index_t)def->body.iseq.iseqptr); + return rb_hash_uint(hash, (st_index_t)def->body.iseq.iseqptr); case VM_METHOD_TYPE_CFUNC: - hash = rb_hash_uint(hash, (st_index_t)def->body.cfunc.func); - return rb_hash_uint(hash, def->body.cfunc.argc); + hash = rb_hash_uint(hash, (st_index_t)def->body.cfunc.func); + return rb_hash_uint(hash, def->body.cfunc.argc); case VM_METHOD_TYPE_ATTRSET: case VM_METHOD_TYPE_IVAR: - return rb_hash_uint(hash, def->body.attr.id); + return rb_hash_uint(hash, def->body.attr.id); case VM_METHOD_TYPE_BMETHOD: return rb_hash_proc(hash, def->body.bmethod.proc); case VM_METHOD_TYPE_MISSING: - return rb_hash_uint(hash, def->original_id); + return rb_hash_uint(hash, def->original_id); case VM_METHOD_TYPE_ZSUPER: case VM_METHOD_TYPE_NOTIMPLEMENTED: case VM_METHOD_TYPE_UNDEF: - return hash; + return hash; case VM_METHOD_TYPE_OPTIMIZED: hash = rb_hash_uint(hash, def->body.optimized.index); - return rb_hash_uint(hash, def->body.optimized.type); + return rb_hash_uint(hash, def->body.optimized.type); case VM_METHOD_TYPE_REFINED: case VM_METHOD_TYPE_ALIAS: - break; /* unreachable */ + break; /* unreachable */ } rb_bug("rb_hash_method_definition: unsupported method type (%d)\n", def->type); } @@ -2139,7 +2139,7 @@ rb_alias(VALUE klass, ID alias_name, ID original_name) rb_method_visibility_t visi = METHOD_VISI_UNDEF; if (NIL_P(klass)) { - rb_raise(rb_eTypeError, "no class to make alias"); + rb_raise(rb_eTypeError, "no class to make alias"); } rb_class_modify_check(klass); @@ -2148,24 +2148,24 @@ rb_alias(VALUE klass, ID alias_name, ID original_name) orig_me = search_method(klass, original_name, &defined_class); if (orig_me && orig_me->def->type == VM_METHOD_TYPE_REFINED) { - orig_me = rb_resolve_refined_method(Qnil, orig_me); + orig_me = rb_resolve_refined_method(Qnil, orig_me); } if (UNDEFINED_METHOD_ENTRY_P(orig_me) || - UNDEFINED_REFINED_METHOD_P(orig_me->def)) { - if ((!RB_TYPE_P(klass, T_MODULE)) || - (orig_me = search_method(rb_cObject, original_name, &defined_class), - UNDEFINED_METHOD_ENTRY_P(orig_me))) { - rb_print_undef(klass, original_name, METHOD_VISI_UNDEF); - } + UNDEFINED_REFINED_METHOD_P(orig_me->def)) { + if ((!RB_TYPE_P(klass, T_MODULE)) || + (orig_me = search_method(rb_cObject, original_name, &defined_class), + UNDEFINED_METHOD_ENTRY_P(orig_me))) { + rb_print_undef(klass, original_name, METHOD_VISI_UNDEF); + } } switch (orig_me->def->type) { case VM_METHOD_TYPE_ZSUPER: - klass = RCLASS_SUPER(klass); - original_name = orig_me->def->original_id; - visi = METHOD_ENTRY_VISI(orig_me); - goto again; + klass = RCLASS_SUPER(klass); + original_name = orig_me->def->original_id; + visi = METHOD_ENTRY_VISI(orig_me); + goto again; case VM_METHOD_TYPE_ALIAS: visi = METHOD_ENTRY_VISI(orig_me); orig_me = orig_me->def->body.alias.original_me; @@ -2177,16 +2177,16 @@ rb_alias(VALUE klass, ID alias_name, ID original_name) if (visi == METHOD_VISI_UNDEF) visi = METHOD_ENTRY_VISI(orig_me); if (orig_me->defined_class == 0) { - rb_method_entry_make(target_klass, alias_name, target_klass, visi, - VM_METHOD_TYPE_ALIAS, NULL, orig_me->called_id, - (void *)rb_method_entry_clone(orig_me)); - method_added(target_klass, alias_name); + rb_method_entry_make(target_klass, alias_name, target_klass, visi, + VM_METHOD_TYPE_ALIAS, NULL, orig_me->called_id, + (void *)rb_method_entry_clone(orig_me)); + method_added(target_klass, alias_name); } else { - rb_method_entry_t *alias_me; + rb_method_entry_t *alias_me; - alias_me = method_entry_set(target_klass, alias_name, orig_me, visi, orig_me->owner); - RB_OBJ_WRITE(alias_me, &alias_me->owner, target_klass); + alias_me = method_entry_set(target_klass, alias_name, orig_me, visi, orig_me->owner); + RB_OBJ_WRITE(alias_me, &alias_me->owner, target_klass); RB_OBJ_WRITE(alias_me, &alias_me->defined_class, orig_me->defined_class); } } @@ -2218,7 +2218,7 @@ rb_mod_alias_method(VALUE mod, VALUE newname, VALUE oldname) { ID oldid = rb_check_id(&oldname); if (!oldid) { - rb_print_undef_str(mod, oldname); + rb_print_undef_str(mod, oldname); } VALUE id = rb_to_id(newname); rb_alias(mod, id, oldid); @@ -2230,7 +2230,7 @@ check_and_export_method(VALUE self, VALUE name, rb_method_visibility_t visi) { ID id = rb_check_id(&name); if (!id) { - rb_print_undef_str(self, name); + rb_print_undef_str(self, name); } rb_export_method(self, id, visi); } @@ -2242,9 +2242,9 @@ set_method_visibility(VALUE self, int argc, const VALUE *argv, rb_method_visibil rb_check_frozen(self); if (argc == 0) { - rb_warning("%"PRIsVALUE" with no argument is just ignored", - QUOTE_ID(rb_frame_callee())); - return; + rb_warning("%"PRIsVALUE" with no argument is just ignored", + QUOTE_ID(rb_frame_callee())); + return; } @@ -2253,9 +2253,9 @@ set_method_visibility(VALUE self, int argc, const VALUE *argv, rb_method_visibil if (argc == 1 && (v = rb_check_array_type(argv[0])) != Qnil) { long j; - for (j = 0; j < RARRAY_LEN(v); j++) { - check_and_export_method(self, RARRAY_AREF(v, j), visi); - } + for (j = 0; j < RARRAY_LEN(v); j++) { + check_and_export_method(self, RARRAY_AREF(v, j), visi); + } } else { for (i = 0; i < argc; i++) { @@ -2632,36 +2632,36 @@ rb_mod_modfunc(int argc, VALUE *argv, VALUE module) const rb_method_entry_t *me; if (!RB_TYPE_P(module, T_MODULE)) { - rb_raise(rb_eTypeError, "module_function must be called for modules"); + rb_raise(rb_eTypeError, "module_function must be called for modules"); } if (argc == 0) { - rb_scope_module_func_set(); + rb_scope_module_func_set(); return Qnil; } set_method_visibility(module, argc, argv, METHOD_VISI_PRIVATE); for (i = 0; i < argc; i++) { - VALUE m = module; - - id = rb_to_id(argv[i]); - for (;;) { - me = search_method(m, id, 0); - if (me == 0) { - me = search_method(rb_cObject, id, 0); - } - if (UNDEFINED_METHOD_ENTRY_P(me)) { - rb_print_undef(module, id, METHOD_VISI_UNDEF); - } - if (me->def->type != VM_METHOD_TYPE_ZSUPER) { - break; /* normal case: need not to follow 'super' link */ - } - m = RCLASS_SUPER(m); - if (!m) - break; - } - rb_method_entry_set(rb_singleton_class(module), id, me, METHOD_VISI_PUBLIC); + VALUE m = module; + + id = rb_to_id(argv[i]); + for (;;) { + me = search_method(m, id, 0); + if (me == 0) { + me = search_method(rb_cObject, id, 0); + } + if (UNDEFINED_METHOD_ENTRY_P(me)) { + rb_print_undef(module, id, METHOD_VISI_UNDEF); + } + if (me->def->type != VM_METHOD_TYPE_ZSUPER) { + break; /* normal case: need not to follow 'super' link */ + } + m = RCLASS_SUPER(m); + if (!m) + break; + } + rb_method_entry_set(rb_singleton_class(module), id, me, METHOD_VISI_PUBLIC); } if (argc == 1) { return argv[0]; @@ -2697,7 +2697,7 @@ call_method_entry(rb_execution_context_t *ec, VALUE defined_class, VALUE obj, ID static VALUE basic_obj_respond_to_missing(rb_execution_context_t *ec, VALUE klass, VALUE obj, - VALUE mid, VALUE priv) + VALUE mid, VALUE priv) { VALUE defined_class, args[2]; const ID rtmid = idRespond_to_missing; @@ -2717,13 +2717,13 @@ basic_obj_respond_to(rb_execution_context_t *ec, VALUE obj, ID id, int pub) switch (method_boundp(klass, id, pub|BOUND_RESPONDS)) { case 2: - return FALSE; + return FALSE; case 0: - ret = basic_obj_respond_to_missing(ec, klass, obj, ID2SYM(id), - RBOOL(!pub)); - return RTEST(ret) && ret != Qundef; + ret = basic_obj_respond_to_missing(ec, klass, obj, ID2SYM(id), + RBOOL(!pub)); + return RTEST(ret) && ret != Qundef; default: - return TRUE; + return TRUE; } } @@ -2736,46 +2736,46 @@ vm_respond_to(rb_execution_context_t *ec, VALUE klass, VALUE obj, ID id, int pri if (!cme) return -1; if (METHOD_ENTRY_BASIC(cme)) { - return -1; + return -1; } else { - int argc = 1; - VALUE args[2]; - VALUE result; + int argc = 1; + VALUE args[2]; + VALUE result; - args[0] = ID2SYM(id); - args[1] = Qtrue; - if (priv) { + args[0] = ID2SYM(id); + args[1] = Qtrue; + if (priv) { argc = rb_method_entry_arity((const rb_method_entry_t *)cme); - if (argc > 2) { - rb_raise(rb_eArgError, - "respond_to? must accept 1 or 2 arguments (requires %d)", - argc); - } - if (argc != 1) { - argc = 2; - } - else if (!NIL_P(ruby_verbose)) { - VALUE location = rb_method_entry_location((const rb_method_entry_t *)cme); + if (argc > 2) { + rb_raise(rb_eArgError, + "respond_to? must accept 1 or 2 arguments (requires %d)", + argc); + } + if (argc != 1) { + argc = 2; + } + else if (!NIL_P(ruby_verbose)) { + VALUE location = rb_method_entry_location((const rb_method_entry_t *)cme); rb_category_warn(RB_WARN_CATEGORY_DEPRECATED, "%"PRIsVALUE"%c""respond_to?(:%"PRIsVALUE") uses" - " the deprecated method signature, which takes one parameter", - (FL_TEST(klass, FL_SINGLETON) ? obj : klass), - (FL_TEST(klass, FL_SINGLETON) ? '.' : '#'), - QUOTE_ID(id)); - if (!NIL_P(location)) { - VALUE path = RARRAY_AREF(location, 0); - VALUE line = RARRAY_AREF(location, 1); - if (!NIL_P(path)) { - rb_category_compile_warn(RB_WARN_CATEGORY_DEPRECATED, - RSTRING_PTR(path), NUM2INT(line), - "respond_to? is defined here"); - } - } - } - } + " the deprecated method signature, which takes one parameter", + (FL_TEST(klass, FL_SINGLETON) ? obj : klass), + (FL_TEST(klass, FL_SINGLETON) ? '.' : '#'), + QUOTE_ID(id)); + if (!NIL_P(location)) { + VALUE path = RARRAY_AREF(location, 0); + VALUE line = RARRAY_AREF(location, 1); + if (!NIL_P(path)) { + rb_category_compile_warn(RB_WARN_CATEGORY_DEPRECATED, + RSTRING_PTR(path), NUM2INT(line), + "respond_to? is defined here"); + } + } + } + } result = call_method_entry(ec, defined_class, obj, resid, cme, argc, args, RB_NO_KEYWORDS); - return RTEST(result); + return RTEST(result); } } @@ -2831,10 +2831,10 @@ obj_respond_to(int argc, VALUE *argv, VALUE obj) rb_scan_args(argc, argv, "11", &mid, &priv); if (!(id = rb_check_id(&mid))) { - VALUE ret = basic_obj_respond_to_missing(ec, CLASS_OF(obj), obj, - rb_to_symbol(mid), priv); - if (ret == Qundef) ret = Qfalse; - return ret; + VALUE ret = basic_obj_respond_to_missing(ec, CLASS_OF(obj), obj, + rb_to_symbol(mid), priv); + if (ret == Qundef) ret = Qfalse; + return ret; } return RBOOL(basic_obj_respond_to(ec, obj, id, !RTEST(priv))); } @@ -2889,20 +2889,20 @@ Init_eval_method(void) rb_define_method(rb_cModule, "private_class_method", rb_mod_private_method, -1); rb_define_private_method(rb_singleton_class(rb_vm_top_self()), - "public", top_public, -1); + "public", top_public, -1); rb_define_private_method(rb_singleton_class(rb_vm_top_self()), - "private", top_private, -1); + "private", top_private, -1); rb_define_private_method(rb_singleton_class(rb_vm_top_self()), - "ruby2_keywords", top_ruby2_keywords, -1); + "ruby2_keywords", top_ruby2_keywords, -1); { #define REPLICATE_METHOD(klass, id) do { \ - const rb_method_entry_t *me = rb_method_entry((klass), (id)); \ - rb_method_entry_set((klass), (id), me, METHOD_ENTRY_VISI(me)); \ - } while (0) + const rb_method_entry_t *me = rb_method_entry((klass), (id)); \ + rb_method_entry_set((klass), (id), me, METHOD_ENTRY_VISI(me)); \ + } while (0) - REPLICATE_METHOD(rb_eException, idMethodMissing); - REPLICATE_METHOD(rb_eException, idRespond_to); - REPLICATE_METHOD(rb_eException, idRespond_to_missing); + REPLICATE_METHOD(rb_eException, idMethodMissing); + REPLICATE_METHOD(rb_eException, idRespond_to); + REPLICATE_METHOD(rb_eException, idRespond_to_missing); } } -- cgit v1.2.1