Class: RedParse::RescueOpNode

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 collapse

Attributes inherited from Node

#endline, #errors, #offset, #parent, #startline

Attributes included from Stackable::Meta

#boolean_identity_params, #identity_params

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RawOpNode

create, #image, #raw_unparse

Methods inherited from ValueNode

#reducer_method

Methods inherited from Node

#+, #+@, #==, [], #[]=, #add_parent_links!, #args_rip, #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, #lvars_defined_in, #merge_replacement_session, #negate, #original_brackets_assign, param_names, #parsetrees, #pretty_print, #prohibit_fixup, #replace_ivars_and_self, #replace_value, #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(expr, rescueword, backup) ⇒ RescueOpNode

Returns a new instance of RescueOpNode.



2232
2233
2234
# File 'lib/redparse/node.rb', line 2232

def initialize(expr,rescueword,backup)
      replace [expr,[RescueNode[[],nil,backup]].extend(ListInNode)]
end

Instance Attribute Details

#after_equalsObject

Returns the value of attribute after_equals.



2254
2255
2256
# File 'lib/redparse/node.rb', line 2254

def after_equals
  @after_equals
end

Class Method Details

.namelistObject



2236
2237
2238
# File 'lib/redparse/node.rb', line 2236

def self.namelist
  %w[left right]
end

Instance Method Details

#elseObject Also known as: else_, empty_else



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

def else; nil end

#ensureObject Also known as: ensure_, empty_ensure



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

def ensure; nil end

#leftObject



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

def left; body end

#lvalueObject



2297
2298
2299
# File 'lib/redparse/node.rb', line 2297

def lvalue
  return nil 
end

#old_rescue_parsetree(o) ⇒ Object



2288
2289
2290
2291
2292
# File 'lib/redparse/node.rb', line 2288

def old_rescue_parsetree o
  result=parsetree o
  result=result.last unless o[:ruby187]
  result
end

#opObject



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

def op; "rescue" end

#op?Boolean

Returns:

  • (Boolean)


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

def op?; true end

#parsetree(o) ⇒ Object Also known as: begin_parsetree, rescue_parsetree



2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
# File 'lib/redparse/node.rb', line 2266

def parsetree(o)
    body=body()
    target=result=[]   #was: [:begin, ]

    #body,rescues,else_,ensure_=*self

    rescues=rescues().map{|resc| resc.parsetree(o)}
    target.push newtarget=[:rescue, ]
    #else_=nil
    needbegin=  (BeginNode===body and body.after_equals)
    huh if needbegin and RescueOpNode===body #need test case for this
    huh if needbegin and ParenedNode===body #need test case for this
    body=body.parsetree(o) 
    body=[:begin, body] if needbegin and body.first!=:begin and !o[:ruby187]
    newtarget.push body if body
    
    newtarget.push linked_list(rescues)
    result=result.last if result.size==1
#          result=[:begin,result] 
    result
end

#reducer_identObject



17585
17586
17587
# File 'lib/redparse/ReduceWithsFor_RedParse_1_9.rb', line 17585

def reducer_ident
  :RescueOpNode
end

#rightObject Also known as: rescue_with



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

def right; rescues[0].action end

#rip(p) ⇒ Object



131
132
133
# File 'lib/redparse/ripper.rb', line 131

def rip p
  p.send( "on_#{op}_mod", rescue_with.rip(p), body.rip(p) )
end

#special_conditions!Object



2257
2258
2259
# File 'lib/redparse/node.rb', line 2257

def special_conditions!
  nil
end

#to_lispObject



2261
2262
2263
2264
# File 'lib/redparse/node.rb', line 2261

def to_lisp
  huh #what about rescues
  body.to_lisp
end

#unparse(o = default_unparse_options) ⇒ Object



2301
2302
2303
2304
2305
# File 'lib/redparse/node.rb', line 2301

def unparse(o=default_unparse_options)
    result= body.unparse(o)
    result+=" rescue "
    result+=rescues.first.action.unparse(o)
end