Class: BOAST::Ternary

Inherits:
Object
  • Object
show all
Extended by:
Functor
Includes:
Arithmetic, Inspectable, PrivateStateAccessor
Defined in:
lib/BOAST/Operators.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Functor

extended

Methods included from PrivateStateAccessor

private_boolean_state_accessor, private_state_accessor

Methods included from Inspectable

#inspect

Methods included from Arithmetic

#!, #!=, #*, #+, #-, #-@, #/, #<, #<=, #==, #===, #>, #>=, #address, #and, #components, #dereference, #or

Constructor Details

#initialize(x, y, z) ⇒ Ternary

Returns a new instance of Ternary.



461
462
463
464
465
# File 'lib/BOAST/Operators.rb', line 461

def initialize(x,y,z)
  @operand1 = x
  @operand2 = y
  @operand3 = z
end

Instance Attribute Details

#operand1Object (readonly)

Returns the value of attribute operand1.



457
458
459
# File 'lib/BOAST/Operators.rb', line 457

def operand1
  @operand1
end

#operand2Object (readonly)

Returns the value of attribute operand2.



458
459
460
# File 'lib/BOAST/Operators.rb', line 458

def operand2
  @operand2
end

#operand3Object (readonly)

Returns the value of attribute operand3.



459
460
461
# File 'lib/BOAST/Operators.rb', line 459

def operand3
  @operand3
end

Instance Method Details

#prObject



477
478
479
480
481
482
483
484
# File 'lib/BOAST/Operators.rb', line 477

def pr
  s=""
  s += indent
  s += to_s
  s += ";" if [C, CL, CUDA].include?( lang )
  output.puts s
  return self
end

#to_sObject



467
468
469
470
# File 'lib/BOAST/Operators.rb', line 467

def to_s
  raise "Ternary operator unsupported in FORTRAN!" if lang == FORTRAN
  return to_s_c if [C, CL, CUDA].include?( lang )
end

#to_s_cObject



472
473
474
475
# File 'lib/BOAST/Operators.rb', line 472

def to_s_c
  s = ""
  s += "(#{@operand1} ? #{@operand2} : #{@operand3})"
end