Created
December 23, 2011 17:43
-
-
Save tenderlove/1514889 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
[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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment