Class: RedParse::RescueNode
- Defined in:
- 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
- #image ⇒ Object
-
#initialize(rescuehdr, action, semi) ⇒ RescueNode
constructor
A new instance of RescueNode.
- #parsetree(o) ⇒ Object
- #reducer_ident ⇒ Object
- #reducer_method(stack) ⇒ Object
- #rip(p) ⇒ Object
- #unparse(o = default_unparse_options) ⇒ Object
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, #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(rescuehdr, action, semi) ⇒ RescueNode
Returns a new instance of RescueNode.
5227 5228 5229 5230 5231 5232 5233 5234 |
# File 'lib/redparse/node.rb', line 5227 def initialize(rescuehdr,action,semi) @offset=rescuehdr.offset exlist=rescuehdr.exceptions||[] exlist=[exlist] unless exlist.class==Array fail unless exlist.class==Array exlist.extend ListInNode super(exlist,rescuehdr.varname,action) end |
Instance Method Details
#image ⇒ Object
5274 |
# File 'lib/redparse/node.rb', line 5274 def image; "(rescue)" end |
#parsetree(o) ⇒ Object
5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 |
# File 'lib/redparse/node.rb', line 5243 def parsetree(o) result=[:resbody, nil] fail unless exceptions.class==Array ex=#if Node===exceptions; [exceptions.rescue_parsetree(o)] #elsif exceptions exceptions.map{|exc| exc.rescue_parsetree(o)} #end if !ex or ex.empty? #do nothing elsif ex.last.first!=:splat result[1]= [:array, *ex] elsif ex.size==1 result[1]= ex.first else result[1]= [:argscat, ex[0...-1].unshift(:array), ex.last[1]] end VarNode===varname and offset=varname.offset action=if varname SequenceNode.new( AssignNode.new( varname, KeywordToken.new("=",offset), VarNode.new(VarNameToken.new("$!",offset)) ),nil,action() ) else action() end result.push action.parsetree(o) if action result end |
#reducer_ident ⇒ Object
17240 17241 17242 |
# File 'lib/redparse/ReduceWithsFor_RedParse_1_9.rb', line 17240 def reducer_ident :RescueNode end |
#reducer_method(stack) ⇒ Object
17237 17238 17239 |
# File 'lib/redparse/ReduceWithsFor_RedParse_1_9.rb', line 17237 def reducer_method(stack) :reduce_with_tos_RescueNode end |
#rip(p) ⇒ Object
324 325 326 327 328 329 330 |
# File 'lib/redparse/ripper.rb', line 324 def rip p p.on_rescue( exceptions.empty??nil:exceptions.map{|ex| ex.rip(p)}, name&&p.on_var_field(p.on_ident(name.name)), force_stmt_list_rip(action,p) ) end |
#unparse(o = default_unparse_options) ⇒ Object
5237 5238 5239 5240 5241 |
# File 'lib/redparse/node.rb', line 5237 def unparse o= xx=exceptions.map{|exc| exc.unparse o}.join(',') unparse_nl(self,o)+ "rescue #{xx} #{varname&&'=> '+varname.lhs_unparse(o)}#{unparse_nl(action||self,o)}#{action&&action.unparse(o)}" end |