Class: RedParse::BracketsGetNode
- 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
- #image ⇒ Object
-
#initialize(receiver, lbrack, params, rbrack) ⇒ BracketsGetNode
constructor
A new instance of BracketsGetNode.
- #lvalue_parsetree(o) ⇒ Object
- #name ⇒ Object
- #parsetree(o) ⇒ Object
- #parsetree_no_fcall(o) ⇒ Object
- #unparse(o = default_unparse_options) ⇒ Object
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, #inspect, #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
Constructor Details
#initialize(receiver, lbrack, params, rbrack) ⇒ BracketsGetNode
Returns a new instance of BracketsGetNode.
4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 |
# File 'lib/redparse/node.rb', line 4990 def initialize(receiver,lbrack,params,rbrack) case params when CommaOpNode h,arrowrange=params.extract_unbraced_hash params=Array.new params params[arrowrange]=[h] if arrowrange when ArrowOpNode h=HashLiteralNode.new(nil,params,nil) h.startline=params.startline h.endline=params.endline params=[h] when nil params=nil else params=[params] end params.extend ListInNode if params @offset=receiver.offset super(receiver,params) end |
Instance Attribute Details
#lvalue ⇒ Object
5054 5055 5056 5057 |
# File 'lib/redparse/node.rb', line 5054 def lvalue return @lvalue if defined? @lvalue @lvalue=true end |
Instance Method Details
#image ⇒ Object
5013 |
# File 'lib/redparse/node.rb', line 5013 def image; "(#{receiver.image}.[])" end |
#lvalue_parsetree(o) ⇒ Object
5047 5048 5049 5050 5051 5052 |
# File 'lib/redparse/node.rb', line 5047 def lvalue_parsetree(o) result=parsetree_no_fcall o result[0]=:attrasgn result[2]=:[]= result end |
#name ⇒ Object
5011 |
# File 'lib/redparse/node.rb', line 5011 def name; "[]" end |
#parsetree(o) ⇒ Object
5023 5024 5025 5026 5027 5028 |
# File 'lib/redparse/node.rb', line 5023 def parsetree(o) result=parsetree_no_fcall o o[:quirks] and VarLikeNode===receiver and receiver.name=='self' and result[0..2]=[:fcall,:[]] return result end |
#parsetree_no_fcall(o) ⇒ Object
5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 |
# File 'lib/redparse/node.rb', line 5030 def parsetree_no_fcall o params=params() output,star,amp=param_list_parse(params,o) # receiver=receiver.parsetree(o) result=[:call, receiver.rescue_parsetree(o), :[], output] if params if star and params.size==1 output.concat star else output.unshift :array result[-1]=[:argscat, output, star.last] if star end else result.pop end return result end |
#unparse(o = default_unparse_options) ⇒ Object
5015 5016 5017 5018 5019 5020 5021 |
# File 'lib/redparse/node.rb', line 5015 def unparse o= [ receiver.unparse(o).sub(/\s+\Z/,''), '[', params&¶ms.map{|param| param.unparse o}.join(','), ']' ].join end |