Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 1st, 2012  |  syntax: None  |  size: 0.98 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. irb(main):006:0> File.write('out.rb', 'def foo; @attributes["zomg"]; end')
  2. => 33
  3. irb(main):007:0> x = RubyVM::InstructionSequence.compile_file 'out.rb'
  4. => <RubyVM::InstructionSequence:<main>@out.rb>
  5. irb(main):008:0> puts x.disasm
  6. == disasm: <RubyVM::InstructionSequence:<main>@out.rb>==================
  7. 0000 trace            1                                               (   1)
  8. 0002 putspecialobject 1
  9. 0004 putspecialobject 2
  10. 0006 putobject        :foo
  11. 0008 putiseq          foo
  12. 0010 send             :"core#define_method", 3, nil, 0, <ic:0>
  13. 0016 leave            
  14. == disasm: <RubyVM::InstructionSequence:foo@out.rb>=====================
  15. local table (size: 2, argc: 0 [opts: 0, rest: -1, post: 0, block: -1] s1)
  16. [ 2] ?          
  17. 0000 trace            8                                               (   1)
  18. 0002 trace            1
  19. 0004 getinstancevariable :@attributes, <ic:0>
  20. 0007 putstring        "zomg"
  21. 0009 opt_aref         <ic:2>
  22. 0011 trace            16
  23. 0013 leave            
  24. => nil
  25. irb(main):009:0>