Slide 64
Slide 64 text
RubyVM::InstructionSequence
# warning: Do never use this black magic!!
def foo(x = 'xx', y = :yy, z = 1); end
ary = RubyVM::InstructionSequence.of(method(:foo)).to_a
default_args = ary[11][1]
bytecode = ary[13]
p default_args
#=> [:label_0, :label_4, :label_8, :label_11]
p bytecode
#=> [:label_0, 2, [:putstring, "xx"],
[:setlocal_OP__WC__0, 4], :label_4, [:putobject, :yy],
[:setlocal_OP__WC__0, 3], :label_8,
[:putobject_OP_INT2FIX_O_1_C_], [:setlocal_OP__WC__0,
2], :label_11, [:trace, 8], [:putnil], [:trace, 16],
[:leave]]