class Opal::Nodes::IfNode
def compile
def compile truthy, falsy = self.truthy, self.falsy if skip_check_present? falsy = nil end push "if (", js_truthy(test), ") {" # skip if-body if no truthy sexp indent { line stmt(truthy) } if truthy if falsy if falsy.type == :if line "} else ", stmt(falsy) else indent do line "} else {" line stmt(falsy) end line "}" end else push "}" end wrap "(function() {", "; return nil; })()" if needs_wrapper? end
def falsy
def falsy needs_wrapper? ? compiler.returns(false_body || s(:nil)) : false_body end
def needs_wrapper?
def needs_wrapper? expr? or recv? end
def skip_check_present?
engine is opal then that code gets generated as the
opal, then falsy block gets generated as normal. Unless
pre-processing only effects falsy blocks. If engine is
def skip_check_present? test == RUBY_ENGINE_CHECK or test == RUBY_PLATFORM_CHECK end
def truthy
def truthy needs_wrapper? ? compiler.returns(true_body || s(:nil)) : true_body end