class BOAST::Ternary

@!parse module Functors; functorize Ternary; end

Attributes

operand1[R]
operand2[R]
operand3[R]

Public Class Methods

new(x,y,z) click to toggle source
# File lib/BOAST/Language/Operators.rb, line 1058
def initialize(x,y,z)
  @operand1 = x
  @operand2 = y
  @operand3 = z
end

Public Instance Methods

pr() click to toggle source
# File lib/BOAST/Language/Operators.rb, line 1069
def pr
  s=""
  s << indent
  s << to_s
  s << ";" if [C, CL, CUDA].include?( lang )
  output.puts s
  return self
end
to_s() click to toggle source
# File lib/BOAST/Language/Operators.rb, line 1064
def to_s
  return to_s_fortran if lang == FORTRAN
  return to_s_c if [C, CL, CUDA].include?( lang )
end

Private Instance Methods

op_to_var() click to toggle source
# File lib/BOAST/Language/Operators.rb, line 1090
def op_to_var
  op1 = @operand1.respond_to?(:to_var) ? @operand1.to_var : @operand1
  op1 = @operand1 unless op1
  op2 = @operand2.respond_to?(:to_var) ? @operand2.to_var : @operand2
  op2 = @operand2 unless op2
  op3 = @operand3.respond_to?(:to_var) ? @operand3.to_var : @operand3
  op3 = @operand3 unless op3
  return [op1, op2, op3]
end
to_s_c() click to toggle source
# File lib/BOAST/Language/Operators.rb, line 1085
def to_s_c
  op1, op2, op3 = op_to_var
  "(#{op1} ? #{op2} : #{op3})"
end
to_s_fortran() click to toggle source
# File lib/BOAST/Language/Operators.rb, line 1080
def to_s_fortran
  op1, op2, op3 = op_to_var
  "merge(#{op2}, #{op3}, #{op1})"
end