Class: Y2R::AST::YCP::YETriple

Inherits:
Node
  • Object
show all
Defined in:
lib/y2r/ast/ycp.rb

Instance Method Summary collapse

Methods inherited from Node

#always_returns?, #compile_statements, #compile_statements_inside_block, #compile_statements_with_whitespace, #creates_local_scope?, #needs_copy?, #optimize_last_statement, #optimize_next, #optimize_return, #remove_duplicate_imports, transfers_comments

Instance Method Details

#compile(context) ⇒ Object



2512
2513
2514
2515
2516
2517
2518
# File 'lib/y2r/ast/ycp.rb', line 2512

def compile(context)
  Ruby::TernaryOperator.new(
    :condition => cond.compile(context),
    :then      => self.true.compile(context),
    :else      => self.false.compile(context)
  )
end

#compile_as_copy_if_needed(context) ⇒ Object



2504
2505
2506
2507
2508
2509
2510
# File 'lib/y2r/ast/ycp.rb', line 2504

def compile_as_copy_if_needed(context)
  Ruby::TernaryOperator.new(
    :condition => cond.compile(context),
    :then      => self.true.compile_as_copy_if_needed(context),
    :else      => self.false.compile_as_copy_if_needed(context)
  )
end

#never_nil?Boolean

Returns:

  • (Boolean)


2522
2523
2524
# File 'lib/y2r/ast/ycp.rb', line 2522

def never_nil?
  return self.true.never_nil? && self.false.never_nil?
end