Class: Rewriter
- Inherits:
-
SexpProcessor
- Object
- SexpProcessor
- Rewriter
- Defined in:
- lib/rewriter.rb
Overview
Rewriter (probably should be renamed) is a first-pass filter that normalizes some of ruby’s ASTs to make them more processable later in the pipeline. It only has processors for what it is interested in, so real the individual methods for a better understanding of what it does.
Instance Method Summary collapse
Instance Method Details
#rewrite_defn(exp) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rewriter.rb', line 20 def rewrite_defn(exp) case exp.last[0] when :ivar then ivar = exp.pop exp.push s(:scope, s(:block, s(:return, ivar))) when :attrset then var = exp.pop exp.push s(:scope, s(:block, s(:return, s(:iasgn, var.last, s(:lvar, :arg))))) end exp end |