ruby-changes:53797
From: ko1 <ko1@a...>
Date: Tue, 27 Nov 2018 11:45:29 +0900 (JST)
Subject: [ruby-changes:53797] ko1:r66015 (trunk): `RubyVM::ISeq.of` accept ISeq.
ko1 2018-11-27 11:45:25 +0900 (Tue, 27 Nov 2018) New Revision: 66015 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66015 Log: `RubyVM::ISeq.of` accept ISeq. * iseq.c (iseqw_s_of): return given object if the given object is a `RubyVM::InstructionSequence`. We can specify ISeq for `TracePoint#enable(target:)`. Modified files: trunk/iseq.c Index: iseq.c =================================================================== --- iseq.c (revision 66014) +++ iseq.c (revision 66015) @@ -2320,17 +2320,26 @@ iseqw_s_of(VALUE klass, VALUE body) https://github.com/ruby/ruby/blob/trunk/iseq.c#L2320 rb_secure(1); if (rb_obj_is_proc(body)) { - iseq = vm_proc_iseq(body); + iseq = vm_proc_iseq(body); - if (!rb_obj_is_iseq((VALUE)iseq)) { - iseq = NULL; - } + if (rb_obj_is_iseq((VALUE)iseq)) { + return iseqw_new(iseq); + } + else { + return Qnil; + } + } + else if (rb_obj_is_method(body)) { + return iseqw_new(rb_method_iseq(body)); + } + else if (RB_TYPE_P(body, T_DATA) && + RTYPEDDATA_P(body) && + RTYPEDDATA_TYPE(body) == &iseqw_data_type) { + return body; } else { - iseq = rb_method_iseq(body); + return Qnil; } - - return iseq ? iseqw_new(iseq) : Qnil; } /* -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/