Class: NameTracker
- Inherits:
-
Object
- Object
- NameTracker
- Defined in:
- lib/normalize_ast.rb
Instance Method Summary collapse
-
#initialize ⇒ NameTracker
constructor
A new instance of NameTracker.
- #rename(type, id) ⇒ Object
Constructor Details
#initialize ⇒ NameTracker
Returns a new instance of NameTracker.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/normalize_ast.rb', line 7 def initialize @var_hash = Hash.new { |h,k| h[k] = "var"+h.size.to_s } @spt_hash = Hash.new { |h,k| h[k] = "*vr"+h.size.to_s } @bar_hash = Hash.new { |h,k| h[k] = "&vr"+h.size.to_s } @sym_hash = Hash.new { |h,k| h[k] = ("sym"+h.size.to_s).to_sym } @str_hash = Hash.new { |h,k| h[k] = "str"+h.size.to_s } @flt_hash = Hash.new { |h,k| h[k] = 0.0+h.size.to_f } @int_hash = Hash.new { |h,k| h[k] = 0+h.size } @mapping = { :str => @str_hash, :sym => @sym_hash, :arg => @var_hash, :float => @flt_hash, :int => @int_hash, :var => @var_hash, :restarg => @spt_hash, :blockarg => @bar_hash } end |
Instance Method Details
#rename(type, id) ⇒ Object
26 27 28 |
# File 'lib/normalize_ast.rb', line 26 def rename(type,id) @mapping[type][id] end |