VALUE test_iseq(VALUE arg) { VALUE v; // rb_require("rubygems"); // rb_protect( (VALUE (*)(VALUE))rb_require, (VALUE) "iseq", &error); // perror("require 'iseq'"); // rb_class_new_instance(argc, argv, klass); p(s("OK")); ruby_show_version(); VALUE iseq=eval("$iseq = RubyVM::InstructionSequence.compile('puts 1+4')"); VALUE rbc=eval("$rbc = $iseq.to_a"); // VALUE rbc=eval("Marshal.load(File.read('out.dump'))"); p(rbc); v=rb_funcall(iseq,id("eval"),0);// YAY!!! // p(rb_cISeq); pf("-----\n"); // iseq=rb_iseq_load(rbc,0, Qnil); iseq=(VALUE)rb_iseq_load(rbc,rb_cISeq, Qnil); // iseq.h:VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt); pf("+++++\n"); pf("%lu\n\n",iseq); if(iseq) p(iseq); pf("///////\n"); // rb_call(VALUE recv, ID mid, int argc, const VALUE *argv, call_type scope) v=rb_funcall(iseq,id("eval"),0); pf("-----"); // eval("puts 'hellou';arr = Marshal.load(File.read('out.dump'));puts arr;puts 'ok1';require 'iseq';puts ISeq;puts 'ok';x=ISeq.load arr;puts x;"); return v; }
static rb_iseq_t * transform(VALUE callable) { VALUE old_iseqw_ary, new_iseqw_ary; VALUE old_iseqw, new_iseqw; const rb_iseq_t *parent; old_iseqw = rb_funcall(rb_cISeq, rb_intern("of"), 1, callable); parent = ((rb_iseq_t *)DATA_PTR(old_iseqw))->body->parent_iseq; old_iseqw_ary = rb_funcall(old_iseqw, rb_intern("to_a"), 0); new_iseqw_ary = rb_funcall(mAsync, rb_intern("transform"), 1, old_iseqw_ary); new_iseqw = rb_iseq_load(new_iseqw_ary, (VALUE)parent, Qnil); return DATA_PTR(new_iseqw); }