Skip to content

Instantly share code, notes, and snippets.

@brixen
Created June 29, 2011 06:31
Show Gist options
  • Save brixen/1053269 to your computer and use it in GitHub Desktop.
Save brixen/1053269 to your computer and use it in GitHub Desktop.
ast = "def foo(a) p a end; foo(1)".to_ast
root = Rubinius::AST::Script.new ast
root.file = "(heckle)"
compiler = Rubinius::Compiler.new :bytecode, :compiled_method
compiler.generator.input root
cm = compiler.run
script = cm.create_script
Rubinius.run_script script.compiled_method
ast.array.first.body.array.unshift "a = :what?".to_ast
v = ast.array.first.body.array[1].arguments.array.first.variable
ast.array.first.body.array.first.variable = v
cm = compiler.run
script = cm.create_script
Rubinius.run_script script.compiled_method
$ rbx rbx-heckle.rb
1
:what?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment