-
-
Save dsisnero/d5e3b8db02de5d280ea82ecba2a5e79e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ffi' | |
module RB | |
extend FFI::Library | |
ffi_lib [:ruby] | |
attach_function :iseq_load, :rb_iseq_load, [:pointer, :int, :pointer], :pointer | |
attach_function :iseq_eval, :rb_iseq_eval, [:pointer], :pointer | |
attach_function :eval_string, :rb_eval_string, [:string], :pointer | |
end | |
a = RB.eval_string('RubyVM::InstructionSequence.new("puts :hi").to_a') | |
b = 4 | |
c = RB.eval_string('RubyVM::InstructionSequence.compile_option') | |
p RB.iseq_eval(RB.iseq_load(a, b, c)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment