From: Luis Lavena Date: 2012-07-18T09:13:45+09:00 Subject: [ruby-core:46540] Re: [ruby-trunk - Bug #6724][Open] waaaaaaant! ( On Tue, Jul 17, 2012 at 6:27 PM, Aaron Patterson wrote: > > class RubyVM > class InstructionSequence > address = DL::Handle::DEFAULT['rb_iseq_load'] > func = Fiddle::Function.new(address, [DL::TYPE_VOIDP] * 3, DL::TYPE_VOIDP) > > define_singleton_method(:load) do |data, parent = nil, opt = nil| > func.call(DL.dlwrap(data), parent, opt).to_value > end > end > end > For some reason ::DEFAULT doesn't work on windows, so a bit of tweak: require 'rbconfig' require 'dl' require 'fiddle' require 'minitest/autorun' class RubyVM class InstructionSequence handle = DL::Handle.new(RbConfig::CONFIG["RUBY_SO_NAME"]) address = handle['rb_iseq_load'] func = Fiddle::Function.new(address, [DL::TYPE_VOIDP] * 3, DL::TYPE_VOIDP) define_singleton_method(:load) do |data, parent = nil, opt = nil| func.call(DL.dlwrap(data), parent, opt).to_value end end end class TestISeq < MiniTest::Unit::TestCase def test_load ins = RubyVM::InstructionSequence.new '5 + 10' other = RubyVM::InstructionSequence.load ins.to_a assert_equal ins.eval, other.eval end end That or simply: DL::Handle.new (no argument) which will resolve to libruby DLL. -- Luis Lavena AREA 17 - Perfection in design is achieved not when there is nothing more to add, but rather when there is nothing more to take away. Antoine de Saint-Exup�ry