Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created November 24, 2008 20:01
Show Gist options
  • Save tenderlove/28576 to your computer and use it in GitHub Desktop.
Save tenderlove/28576 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'parse_tree'
require 'ruby2ruby'
require 'sexp_processor'
require 'ruby_parser'
class Codes
def super_awesome
foo = 10
foo + 10 * 20
end
end
class RubyMutator < SexpProcessor
def rewrite_lvar exp
s(:call, exp, :+, s(:lit, 42))
end
end
codes = ParseTree.new.parse_tree(Codes)
puts Ruby2Ruby.new.process(RubyMutator.new.process(codes.first))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment