From: "Glass_saga (Masaki Matsushita)" Date: 2012-07-01T22:57:48+09:00 Subject: [ruby-dev:45889] [ruby-trunk - Feature #2674] RubyVM::InstructionSequence to accept IOs Issue #2674 has been updated by Glass_saga (Masaki Matsushita). File iseq_io.diff added File ripper_with_T_FILE.diff added IOとして受け付けるかをT_FILE かどうかで判断するパッチを作りました。 また、ripperについてもT_FILEかどうかで判断し、rb_funcall()経由でgetsを呼ぶのではなくrb_io_gets()を使うパッチを作りました。 2つのパッチを添付します。 ---------------------------------------- Feature #2674: RubyVM::InstructionSequence to accept IOs https://bugs.ruby-lang.org/issues/2674#change-27662 Author: shyouhei (Shyouhei Urabe) Status: Feedback Priority: Normal Assignee: ko1 (Koichi Sasada) Category: YARV Target version: 2.0.0 =begin RipperはRipper#initializeでIOを受け付けますが、ISeqはそうはなっていません。 非対称なのでISeqもIOを受け付けるようにするのはどうでしょうか。 Signed-off-by: Urabe, Shyuohei --- iseq.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/iseq.c b/iseq.c index 3c957c7..2d86f5d 100644 --- a/iseq.c +++ b/iseq.c @@ -538,10 +538,14 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE line, VALUE opt) rb_compile_option_t option; const char *fn = StringValueCStr(file); int ln = NUM2INT(line); - NODE *node = parse_string(StringValue(src), fn, ln); + NODE *node; rb_thread_t *th = GET_THREAD(); make_compile_option(&option, opt); + if (rb_obj_respond_to(src, rb_intern("gets"), 0)) + node = rb_compile_file(fn, src, ln); + else + node = rb_compile_string(fn, StringValue(src), ln); if (th->base_block && th->base_block->iseq) { return rb_iseq_new_with_opt(node, th->base_block->iseq->name, file, line, th->base_block->iseq->self, -- 1.6.0.4 =end -- http://bugs.ruby-lang.org/