Class: RedParse::IfOpNode
- Inherits:
-
RawOpNode
show all
- Includes:
- KeywordOpNode
- Defined in:
- lib/redparse/node.rb,
lib/redparse/node.rb,
lib/redparse/ripper.rb,
lib/redparse/ReduceWithsFor_RedParse_1_9.rb,
lib/redparse/ReduceWithsFor_RedParse_1_8.rb
Constant Summary
FlattenedIvars::EXCLUDED_IVARS
Instance Attribute Summary
Attributes inherited from Node
#endline, #errors, #offset, #parent, #startline
#boolean_identity_params, #identity_params
Instance Method Summary
collapse
#unparse
Methods inherited from RawOpNode
create, #image, #raw_unparse
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, #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!
#build_exemplars, #enumerate_exemplars, #identity_param
#flattened_ivars, #flattened_ivars_equal?
Methods included from Stackable
#identity_name
Constructor Details
#initialize(left, op, right = nil) ⇒ IfOpNode
Returns a new instance of IfOpNode.
3033
3034
3035
3036
3037
3038
3039
3040
|
# File 'lib/redparse/node.rb', line 3033
def initialize(left,op,right=nil)
op,right=nil,op unless right
op=op.ident if op.respond_to? :ident
@reverse=false
@loop=false
replace [left,right]
condition.special_conditions! if condition.respond_to? :special_conditions!
end
|
Instance Method Details
#condition ⇒ Object
3031
|
# File 'lib/redparse/node.rb', line 3031
def condition; right end
|
#consequent ⇒ Object
3032
|
# File 'lib/redparse/node.rb', line 3032
def consequent; left end
|
#else ⇒ Object
3044
|
# File 'lib/redparse/node.rb', line 3044
def else; nil end
|
#elsifs ⇒ Object
3045
|
# File 'lib/redparse/node.rb', line 3045
def elsifs; [] end
|
#if ⇒ Object
3042
|
# File 'lib/redparse/node.rb', line 3042
def if; condition end
|
#op ⇒ Object
3046
|
# File 'lib/redparse/node.rb', line 3046
def op; "if" end
|
#parsetree(o) ⇒ Object
3048
3049
3050
3051
3052
3053
3054
3055
3056
|
# File 'lib/redparse/node.rb', line 3048
def parsetree(o)
cond=condition.rescue_parsetree(o)
actions=[consequent.parsetree(o), nil]
if cond.first==:not
actions.reverse!
cond=cond.last
end
[:if, cond, *actions]
end
|
#reducer_ident ⇒ Object
17365
17366
17367
|
# File 'lib/redparse/ReduceWithsFor_RedParse_1_9.rb', line 17365
def reducer_ident
:IfOpNode
end
|
#rip(p) ⇒ Object
179
180
181
|
# File 'lib/redparse/ripper.rb', line 179
def rip p
p.on_if_mod( condition.rip(p), consequent.rip(p) )
end
|
#then ⇒ Object
3043
|
# File 'lib/redparse/node.rb', line 3043
def then; consequent end
|