class Opal::Rewriters::ReturnableLogic

def next_tmp

def next_tmp
  @counter ||= 0
  @counter += 1
  "$ret_or_#{@counter}"
end

def on_and(node)

def on_and(node)
  lhs, rhs = *node.children
  lhs_tmp = next_tmp
  node.updated(:if, [s(:lvasgn, lhs_tmp, process(lhs)), process(rhs), s(:js_tmp, lhs_tmp)])
end

def on_or(node)

def on_or(node)
  lhs, rhs = *node.children
  lhs_tmp = next_tmp
  node.updated(:if, [s(:lvasgn, lhs_tmp, process(lhs)), s(:js_tmp, lhs_tmp), process(rhs)])
end

def reset_tmp_counter!

def reset_tmp_counter!
  @counter = nil
end