aboutsummaryrefslogtreecommitdiffstats
path: root/iseq.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-27 02:45:25 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-27 02:45:25 +0000
commit33dc8a5c23cc647b42648596b5c77b3b8de6d39a (patch)
tree39da2f97ec44e93186a3e3384c11b798b7e3eac9 /iseq.c
parent2e075759148689af6b771afb863e88ebbde89c2b (diff)
downloadruby-33dc8a5c23cc647b42648596b5c77b3b8de6d39a.tar.gz
`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:)`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/iseq.c b/iseq.c
index 930a88d28f..abb0f37b98 100644
--- a/iseq.c
+++ b/iseq.c
@@ -2320,17 +2320,26 @@ iseqw_s_of(VALUE klass, VALUE body)
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;
}
/*