Class: RedParse::ModuleNode

Inherits:
NamespaceNode show all
Defined in:
lib/redparse/node.rb,
lib/redparse/ripper.rb,
lib/redparse/ReduceWithsFor_RedParse_1_9.rb,
lib/redparse/ReduceWithsFor_RedParse_1_8.rb

Constant Summary

Constants included from FlattenedIvars

FlattenedIvars::EXCLUDED_IVARS

Instance Attribute Summary

Attributes inherited from Node

#endline, #errors, #offset, #startline

Attributes included from Stackable::Meta

#boolean_identity_params, #identity_params

Instance Method Summary collapse

Methods included from HasRescue

#parsetree_and_rescues, #unparse_and_rescues

Methods inherited from ValueNode

#lvalue, #reducer_method

Methods inherited from Node

#+, #+@, #==, [], #[]=, #add_parent_links!, #args_rip, #begin_parsetree, #classic_inspect, create, #data, #deep_copy, #delete_extraneous_ivars!, #delete_linenums!, #depthwalk, #depthwalk_nodes, #error?, #evalable_inspect, #fixup_multiple_assignments!, #fixup_rescue_assignments!, #force_stmt_list_rip, #initialize_ivars, inline_symbols, #inspect, #lhs_unparse, #linerange, #lvalue, #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, #rfind, #rfind_all, #rgrep, #rip_and_rescues, #rip_explode!, #short_inspect, #stmts_rip, #to_parsetree, #to_parsetree_and_warnings, #to_ruby, #to_s, #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(moduleword, name, semiword, body, rescues, else_, ensure_, endword) ⇒ ModuleNode

Returns a new instance of ModuleNode.



5063
5064
5065
5066
5067
5068
5069
# File 'lib/redparse/node.rb', line 5063

def initialize moduleword,name,semiword,body,rescues,else_,ensure_,endword
  @offset=moduleword.offset
  else_=else_.val if else_
  ensure_=ensure_.val if ensure_
  rescues.extend ListInNode if rescues
  super(name,body,rescues,else_,ensure_)        
end

Instance Method Details

#imageObject



5075
# File 'lib/redparse/node.rb', line 5075

def image; "(module #{name})" end

#parentObject



5081
# File 'lib/redparse/node.rb', line 5081

def parent; nil end

#parsetree(o) ⇒ Object



5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
# File 'lib/redparse/node.rb', line 5091

def parsetree(o)
  name=name()
  if VarNode===name
    name=name.ident.to_sym
  elsif name.nil? #do nothing
#        elsif o[:quirks]
#          name=name.constant.ident.to_sym
  else 
    name=name.parsetree(o)
  end
  result=[:module, name, scope=[:scope, ]]
  scope << parsetree_and_rescues(o) if body
  return result
end

#reducer_identObject



17325
17326
17327
# File 'lib/redparse/ReduceWithsFor_RedParse_1_9.rb', line 17325

def reducer_ident
  :ModuleNode
end

#rip(p) ⇒ Object



277
278
279
# File 'lib/redparse/ripper.rb', line 277

def rip p 
  p.on_module( name.rip(p), rip_and_rescues(p) )
end

#to_lispObject



5082
5083
5084
5085
5086
5087
5088
5089
# File 'lib/redparse/node.rb', line 5082

def to_lisp
  result="(#{name.ident} #{body.to_lisp} "
  #parent=@data[2]
  #result+="is #{parent.to_lisp} " if parent
 
  result+="\n"+body.to_lisp+")"
  return result
end

#unparse(o = default_unparse_options) ⇒ Object



5077
5078
5079
# File 'lib/redparse/node.rb', line 5077

def unparse o=default_unparse_options
  "module #{name.unparse o}#{unparse_nl(body||self,o)}#{unparse_and_rescues(o)}#{unparse_nl(endline,o)}end"
end