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
#process(exp, _src = nil, _timeout = nil) ⇒ Object
21 22 23 |
# File 'lib/rewriter.rb', line 21 def process exp, _src = nil, _timeout = nil super(exp) end |
#rewrite_defn(exp) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rewriter.rb', line 25 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 |