Create a gist now

Instantly share code, notes, and snippets.

@benolee /yarv_dsl.rb Secret
Created Oct 11, 2012

What would you like to do?
using RubyVM::InstructionSequence.disassemble for a DSL
def wat &block
method, receiver, *args = RubyVM::InstructionSequence.disassemble(block).scan(/send\s+:(\w+)/).reverse.flatten
{ receiver: receiver, method: method, args: args }
wat { (puts Kernel test (hello world)) }
#=> {:receiver=>"Kernel", :method=>"puts", :args=>["test", "hello", "world"]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment