class Opal::Nodes::AndNode

def compile_if

def compile_if
  with_temp do |tmp|
    if truthy_opt = js_truthy_optimize(lhs)
      push "if (#{tmp} = ", truthy_opt, ") {"
    else
      push "if (#{tmp} = ", expr(lhs), ", #{tmp} !== false && #{tmp} !== nil && #{tmp} != null) {"
    end
    indent do
      line expr(rhs)
    end
    line "} else {"
    indent do
      line expr(lhs)
    end
    line "}"
  end
end

def compile_ternary

def compile_ternary
  truthy_opt = nil
  with_temp do |tmp|
    if truthy_opt = js_truthy_optimize(lhs)
      push "((#{tmp} = ", truthy_opt
      push ") ? "
      push expr(rhs)
      push " : ", expr(lhs), ")"
    else
      push "(#{tmp} = "
      push expr(lhs)
      push ", #{tmp} !== false && #{tmp} !== nil && #{tmp} != null ?"
      push expr(rhs)
      push " : #{tmp})"
    end
  end
end