Class: RedParse::ConstantNode

Inherits:
ListOpNode show all
Defined in:
lib/redparse/node.rb

Constant Summary

Constants included from FlattenedIvars

FlattenedIvars::EXCLUDED_IVARS

Instance Attribute Summary collapse

Attributes inherited from Node

#endline, #errors, #offset, #parent, #startline

Attributes included from Stackable::Meta

#boolean_identity_params, #identity_params

Instance Method Summary collapse

Methods inherited from Node

#+, #+@, #==, [], #[]=, #add_parent_links!, #begin_parsetree, create, #data, #deep_copy, #delete_extraneous_ivars!, #delete_linenums!, #depthwalk, #depthwalk_nodes, #error?, #evalable_inspect, #fixup_multiple_assignments!, #fixup_rescue_assignments!, #initialize_ivars, inline_symbols, #lhs_unparse, #linerange, #lvars_defined_in, #merge_replacement_session, namelist, #negate, #original_brackets_assign, param_names, #parsetrees, #pretty_print, #prohibit_fixup, #replace_ivars_and_self, #replace_value, #rescue_parsetree, #to_parsetree, #to_parsetree_and_warnings, #unary, #walk, #xform_tree!

Methods included from Stackable::Meta

#build_exemplars, #enumerate_exemplars, #identity_param

Methods included from FlattenedIvars

#flattened_ivars, #flattened_ivars_equal?

Methods included from Stackable

#identity_name

Constructor Details

#initialize(*args) ⇒ ConstantNode

Returns a new instance of ConstantNode.



1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
# File 'lib/redparse/node.rb', line 1770

def initialize(*args)
  @offset=args.first.offset
  args.unshift nil if args.size==2
  args.map!{|node| 
    if VarNode===node and (?A..?Z)===node.ident[0]
    then node.ident 
    else node
    end
  }
  super(*args)  
end

Instance Attribute Details

#lvalueObject



1808
1809
1810
1811
# File 'lib/redparse/node.rb', line 1808

def lvalue
  return @lvalue if defined? @lvalue
  @lvalue=true
end

Instance Method Details

#inspect(label = nil, indent = 0) ⇒ Object



1815
1816
1817
1818
1819
1820
# File 'lib/redparse/node.rb', line 1815

def inspect label=nil,indent=0
  result=' '*indent
  result+="#{label}: " if label 
  result+='Constant '
  result+=map{|name| name.inspect}.join(', ')+"\n"
end

#lvalue_parsetree(o) ⇒ Object



1790
1791
1792
# File 'lib/redparse/node.rb', line 1790

def lvalue_parsetree(o)
  [:cdecl,parsetree(o)]
end

#parsetree(o) ⇒ Object



1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
# File 'lib/redparse/node.rb', line 1793

def parsetree(o)
  if !first
    result=[:colon3, self[1].to_sym]
    i=2
  else
    result=first.respond_to?(:parsetree) ? 
             first.parsetree(o) :
             [:const,first.to_sym]
    i=1
  end
  (i...size).inject(result){|r,j| 
    [:colon2, r, self[j].to_sym]
  }
end

#unparse(o = default_unparse_options) ⇒ Object Also known as: image



1781
1782
1783
1784
1785
1786
1787
1788
# File 'lib/redparse/node.rb', line 1781

def unparse(o=default_unparse_options)
  if Node===first
    result=dup
    result[0]= first.unparse(o)#.gsub(/\s+\Z/,'')
    result.join('::')
  else join('::')
  end
end