Class: Red::ControlNode::RescueBody
- Inherits:
-
Red::ControlNode
- Object
- String
- Red::ControlNode
- Red::ControlNode::RescueBody
- Defined in:
- lib/red/nodes/control_nodes.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(exception_types_array_sexp, block_sexp, rescue_body_sexp = nil, options = {}) ⇒ RescueBody
constructor
[:resbody, | [:array, {expression, expression, …]}, (expression | :block), (:resbody)].
Methods inherited from String
#%, #*, #+, #<<, #<=>, #==, #=~, #[], #[]=, #capitalize, #capitalize!, #casecmp, #center, #chomp, #chomp!, #chop, #chop!, #concat, #count, #crypt, #delete, #delete!, #downcase, #downcase!, #each, #each_byte, #each_line, #empty?, #eql?, #gsub, #gsub!, #hash, #hex, #include?, #index, #insert, #inspect, #intern, #length, #ljust, #lstrip, #lstrip!, #match, #next, #next!, #oct, #replace, #reverse, #reverse!, #rindex, #rjust, #rstrip, #rstrip!, #scan, #size, #slice, #slice!, #split, #squeeze, #strip, #strip!, #strip_scripts, #sub, #sub!, #succ, #succ!, #sum, #swapcase, #swapcase!, #to_f, #to_i, #to_s, #to_str, #to_sym, #tr, #tr!, #tr_s, #tr_s!, #upcase, #upcase!, #upto
Constructor Details
#initialize(exception_types_array_sexp, block_sexp, rescue_body_sexp = nil, options = {}) ⇒ RescueBody
- :resbody, | [:array, {expression, expression, …]}, (expression | :block), (:resbody)
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/red/nodes/control_nodes.rb', line 43 def initialize(exception_types_array_sexp, block_sexp, rescue_body_sexp = nil, = {}) ( = block_sexp) && (block_sexp = nil) if block_sexp.is_a?(Hash) ( = rescue_body_sexp) && (block_sexp.first==:resbody ? (rescue_body_sexp = block_sexp && block_sexp = nil) : (rescue_body_sexp = nil)) if rescue_body_sexp.is_a?(Hash) if block_sexp.is_sexp?(:block) && block_sexp[1].is_sexp?(:lasgn) && block_sexp[1].last == [:gvar, %s($!)] exception_variable = "var %s=_e;" % block_sexp.delete(block_sexp.assoc(:lasgn))[1].red! elsif block_sexp.is_sexp?(:lasgn) && block_sexp.last == [:gvar, %s($!)] exception_variable = "var %s=_e;" % block_sexp[1].red! block_sexp = [:nil] end exception_types_array = (exception_types_array_sexp || [:array, [:const, :Exception]]).red! block = (block_sexp.is_sexp?(:block) ? block_sexp : [:block, block_sexp]).red!(:force_return => [:force_return]) rescue_body = "else{%s;}" % rescue_body_sexp.red!(:force_return => [:force_return]) if rescue_body_sexp self << "%sif($e(_e,%s)){_eRescued=true;%s;}%s" % [exception_variable, exception_types_array, block, rescue_body] end |