class Opal::Nodes::WhenNode

def body_code

def body_code
  body || s(:nil)
end

def case_stmt

def case_stmt
  compiler.case_stmt
end

def compile

def compile
  push "if ("
  when_checks.each_with_index do |check, idx|
    push ' || ' unless idx == 0
    if check.type == :splat
      push "(function($splt) { for (var i = 0; i < $splt.length; i++) {"
      push "if ($splt[i]['$===']($case)) { return true; }"
      push "} return false; })(", expr(check[1]), ")"
    else
      if case_stmt[:cond]
        call = s(:call, check, :===, s(:arglist, s(:js_tmp, '$case')))
        push expr(call)
      else
        push js_truthy(check)
      end
    end
  end
  push ") {", process(body_code, @level), "}"
end

def when_checks

def when_checks
  whens.children
end