class RedParse::ListInNode::AssigneeList
Public Class Methods
new(data)
click to toggle source
# File lib/redparse/node.rb, line 2647 def initialize(data) data.each_with_index{|datum,i| if ParenedNode===datum first=datum.first list=case first when CommaOpNode; Array.new(first) when UnaryStarNode,ParenedNode; [first] end data[i]=NestedAssign.new(list) if list end } replace data @offset=self.first.offset @startline=self.first.startline @endline=self.last.endline end
Public Instance Methods
all_current_lvars()
click to toggle source
# File lib/redparse/node.rb, line 2731 def all_current_lvars result=[] each{|lvar| lvar.respond_to?(:all_current_lvars) and result.concat lvar.all_current_lvars } return result end
lvalue_parsetree(o)
click to toggle source
# File lib/redparse/node.rb, line 2740 def lvalue_parsetree(o); parsetree(o) end
old_parsetree(o)
click to toggle source
# File lib/redparse/node.rb, line 2668 def old_parsetree o lhs=data.dup if UnaryStarNode===lhs.last lstar=lhs.pop.val end lhs.map!{|x| res=x.parsetree(o) res[0]=x.varname2assigntype if VarNode===x res } lhs.unshift(:array) if lhs.size>1 or lstar result=[lhs] if lstar.respond_to? :varname2assigntype result << lstar.varname2assigntype elsif lstar #[]=, attrib=, or A::B= huh else #do nothing end result end
parsetree(o)
click to toggle source
# File lib/redparse/node.rb, line 2690 def parsetree(o) data=self data.empty? and return nil # data=data.first if data.size==1 and ParenedNode===data.first and data.first.size==1 data=Array.new(data) star=data.pop if UnaryStarNode===data.last result=data.map{|x| x.lvalue_parsetree(o) } =begin { if VarNode===x ident=x.ident ty=x.varname2assigntype # ty==:lasgn and ty=:dasgn_curr [ty, ident.to_sym] else x=x.parsetree(o) if x[0]==:call x[0]=:attrasgn x[2]="#{x[2]}=".to_sym end x end } =end if result.size==0 #just star on lhs star or fail result=[:masgn] result.push nil #why??? #if o[:ruby187] result.push star.lvalue_parsetree(o) elsif result.size==1 and !star and !(NestedAssign===data.first) #simple lhs, not multi result=result.first else result=[:masgn, [:array, *result]] result.push nil if (!star or DanglingCommaNode===star) #and o[:ruby187] result.push star.lvalue_parsetree(o) if star and not DanglingCommaNode===star end result end
unparse(o=default_unparse_options)
click to toggle source
# File lib/redparse/node.rb, line 2664 def unparse o=default_unparse_options map{|lval| lval.lhs_unparse o}.join(', ') end