Class: Opal::Nodes::ResBodyNode
- Defined in:
- opal/lib/opal/nodes/rescue.rb
Constant Summary
Constants included from Helpers
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#add_ivar, #add_local, #add_temp, children, #children, #compile_to_fragments, #error, #expr, #expr?, #expr_or_nil, #fragment, handle, handlers, #helper, #in_while?, #initialize, #process, #push, #recv, #recv?, #s, #scope, #stmt, #stmt?, #unshift, #while_loop, #with_temp, #wrap
Methods included from Helpers
#current_indent, #empty_line, #indent, #js_falsy, #js_truthy, #js_truthy_optimize, #line, #lvar_to_js, #mid_to_jsid, #property, #reserved?, #variable
Constructor Details
This class inherits a constructor from Opal::Nodes::Base
Instance Method Details
#compile ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'opal/lib/opal/nodes/rescue.rb', line 92 def compile push "if (" rescue_classes.each_with_index do |cls, idx| push ', ' unless idx == 0 call = s(:call, cls, :===, s(:arglist, s(:js_tmp, '$err'))) push expr(call) end # if no classes are given, then catch all errors push "true" if rescue_classes.empty? push ") {" if variable = rescue_variable variable[2] = s(:js_tmp, '$err') push expr(variable), ';' end line process(rescue_body, @level) line "}" end |
#rescue_body ⇒ Object
129 130 131 |
# File 'opal/lib/opal/nodes/rescue.rb', line 129 def rescue_body body || s(:nil) end |
#rescue_classes ⇒ Object
123 124 125 126 127 |
# File 'opal/lib/opal/nodes/rescue.rb', line 123 def rescue_classes classes = args.children classes.pop if classes.last and classes.last.type != :const classes end |