Method: Opal::Rewriters::ReturnableLogic#on_or
- Defined in:
- lib/opal/rewriters/returnable_logic.rb
#on_or(node) ⇒ Object
a || b
/ a or b
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/opal/rewriters/returnable_logic.rb', line 44 def on_or(node) lhs, rhs = *node.children check_control_flow!(lhs) if node.[:if_test] # Let's forward the if_test to the lhs and rhs - since we don't care about the exact return # value of our or, we neither do care about a return value of our lhs or rhs. lhs.[:if_test] = rhs.[:if_test] = true out = process(node.updated(:if, [lhs, s(:true), rhs])) else lhs_tmp = next_tmp out = process(node.updated(:if, [s(:lvasgn, lhs_tmp, lhs), s(:js_tmp, lhs_tmp), rhs])) free_tmp end out end |