Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created January 25, 2012 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenderlove/1673789 to your computer and use it in GitHub Desktop.
Save tenderlove/1673789 to your computer and use it in GitHub Desktop.
irb(main):006:0> File.write('out.rb', 'def foo; @attributes["zomg"]; end')
=> 33
irb(main):007:0> x = RubyVM::InstructionSequence.compile_file 'out.rb'
=> <RubyVM::InstructionSequence:<main>@out.rb>
irb(main):008:0> puts x.disasm
== disasm: <RubyVM::InstructionSequence:<main>@out.rb>==================
0000 trace 1 ( 1)
0002 putspecialobject 1
0004 putspecialobject 2
0006 putobject :foo
0008 putiseq foo
0010 send :"core#define_method", 3, nil, 0, <ic:0>
0016 leave
== disasm: <RubyVM::InstructionSequence:foo@out.rb>=====================
local table (size: 2, argc: 0 [opts: 0, rest: -1, post: 0, block: -1] s1)
[ 2] ?
0000 trace 8 ( 1)
0002 trace 1
0004 getinstancevariable :@attributes, <ic:0>
0007 putstring "zomg"
0009 opt_aref <ic:2>
0011 trace 16
0013 leave
=> nil
irb(main):009:0>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment