public
Created

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
[aaron@higgins ~]$ irb
irb(main):001:0> File.write('hello.rb', 'class Foo; def bar; 1 + 1; end end')
=> 34
irb(main):002:0> RubyVM::InstructionSequence.compile_file 'hello.rb'
=> <RubyVM::InstructionSequence:<main>@hello.rb>
irb(main):003:0> puts _.disasm
== disasm: <RubyVM::InstructionSequence:<main>@hello.rb>================
0000 trace 1 ( 1)
0002 putspecialobject 3
0004 putnil
0005 defineclass :Foo, <class:Foo>, 3
0009 leave
== disasm: <RubyVM::InstructionSequence:<class:Foo>@hello.rb>===========
0000 trace 2 ( 1)
0002 trace 1
0004 putspecialobject 1
0006 putspecialobject 2
0008 putobject :bar
0010 putiseq bar
0012 send :"core#define_method", 3, nil, 0, <ic:0>
0018 trace 4
0020 leave
== disasm: <RubyVM::InstructionSequence:bar@hello.rb>===================
0000 trace 8 ( 1)
0002 trace 1
0004 putobject 1
0006 putobject 1
0008 opt_plus <ic:1>
0010 trace 16
0012 leave
=> nil
irb(main):004:0>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.