Slide 37
Slide 37 text
require ‘pp'
pp RubyVM::InstructionSequence.compile(<<-CODE).to_a[13]
class Foo
def bar
i_do_not_exist
end
end
CODE
# => bytecode
[1,
[:trace, 1],
[:putspecialobject, 3],
[:putnil],
[:defineclass,
:Foo,
["YARVInstructionSequence/SimpleDataFormat",
2,
3,
1,
{:arg_size=>0, :local_size=>0, :stack_max=>3},
"",
"",
nil,
1,
:class,
[],
{},
[],
[1,
[:trace, 2],
2,
[:trace, 1],
[:putspecialobject, 1],
[:putobject, :bar],
[:putiseq,
["YARVInstructionSequence/SimpleDataFormat",
2,
3,
1,
{:arg_size=>0, :local_size=>0, :stack_max=>1},
"bar",
"",
nil,
2,
:method,
[],
{},
[],
[2,
[:trace, 8],
3,
[:trace, 1],
[:putself],
[:opt_send_without_block,
{:mid=>:i_do_not_exist, :flag=>28, :orig_argc=>0},
false],
4,
[:trace, 16],
3,
[:leave]]]],
[:opt_send_without_block,
{:mid=>:"core#define_method", :flag=>16, :orig_argc=>2},
false],
5,
[:trace, 4],
2,
[:leave]]],
0],
[:leave]]