Class: RedParse::UnlessOpNode

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

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

Methods included from KeywordOpNode

#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!

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(val1, op, val2 = nil) ⇒ UnlessOpNode

Returns a new instance of UnlessOpNode.



3002
3003
3004
3005
3006
3007
3008
3009
# File 'lib/redparse/node.rb', line 3002

def initialize(val1,op,val2=nil)
  op,val2=nil,op unless val2
  op=op.ident if op.respond_to? :ident
  @reverse=true
  @loop=false
  replace [val1,val2]
  condition.special_conditions! if condition.respond_to? :special_conditions!
end

Instance Method Details

#conditionObject



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

def condition; right end

#consequentObject



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

def consequent; left end

#elseObject



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

def else; consequent end

#elsifsObject



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

def elsifs; [] end

#ifObject



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

def if; condition end

#opObject



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

def op; "unless" end

#parsetree(o) ⇒ Object



3017
3018
3019
3020
3021
3022
3023
3024
3025
# File 'lib/redparse/node.rb', line 3017

def parsetree(o)
  cond=condition.rescue_parsetree(o)
  actions=[nil, consequent.parsetree(o)]
  if cond.first==:not
    actions.reverse!
    cond=cond.last
  end
  [:if, cond, *actions]
end

#reducer_identObject



17435
17436
17437
# File 'lib/redparse/ReduceWithsFor_RedParse_1_9.rb', line 17435

def reducer_ident
  :UnlessOpNode
end

#rip(p) ⇒ Object



185
186
187
# File 'lib/redparse/ripper.rb', line 185

def rip p
  p.on_unless_mod( condition.rip(p), consequent.rip(p) )
end

#thenObject



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

def then; nil end