Class: RedParse::AssigneeList
- Defined in:
- lib/redparse/node.rb
Overview
abstract
Direct Known Subclasses
Constant Summary
Constants included from FlattenedIvars
FlattenedIvars::EXCLUDED_IVARS
Instance Attribute Summary
Attributes inherited from Node
#endline, #errors, #offset, #parent, #startline
Attributes included from Stackable::Meta
#boolean_identity_params, #identity_params
Instance Method Summary collapse
- #all_current_lvars ⇒ Object
-
#initialize(data) ⇒ AssigneeList
constructor
A new instance of AssigneeList.
- #lvalue_parsetree(o) ⇒ Object
- #old_parsetree(o) ⇒ Object
- #parsetree(o) ⇒ Object
- #unparse(o = default_unparse_options) ⇒ Object
Methods inherited from ValueNode
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, #image, #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
Constructor Details
#initialize(data) ⇒ AssigneeList
Returns a new instance of AssigneeList.
2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 |
# 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 |
Instance Method Details
#all_current_lvars ⇒ Object
2731 2732 2733 2734 2735 2736 2737 2738 |
# 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) ⇒ Object
2740 |
# File 'lib/redparse/node.rb', line 2740 def lvalue_parsetree(o); parsetree(o) end |
#old_parsetree(o) ⇒ Object
2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 |
# 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) ⇒ Object
2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 |
# 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) ⇒ Object
2664 2665 2666 |
# File 'lib/redparse/node.rb', line 2664 def unparse o= map{|lval| lval.lhs_unparse o}.join(', ') end |