Class: BOAST::Ternary

Inherits:
Object show all
Defined in:
lib/BOAST/Algorithm.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y, z) ⇒ Ternary

Returns a new instance of Ternary.



1201
1202
1203
1204
1205
# File 'lib/BOAST/Algorithm.rb', line 1201

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

Instance Attribute Details

#operand1Object (readonly)

Returns the value of attribute operand1.



1197
1198
1199
# File 'lib/BOAST/Algorithm.rb', line 1197

def operand1
  @operand1
end

#operand2Object (readonly)

Returns the value of attribute operand2.



1198
1199
1200
# File 'lib/BOAST/Algorithm.rb', line 1198

def operand2
  @operand2
end

#operand3Object (readonly)

Returns the value of attribute operand3.



1199
1200
1201
# File 'lib/BOAST/Algorithm.rb', line 1199

def operand3
  @operand3
end

Class Method Details

.parens(*args, &block) ⇒ Object



1193
1194
1195
# File 'lib/BOAST/Algorithm.rb', line 1193

def self.parens(*args,&block)
  return self::new(*args,&block)
end

Instance Method Details

#*(x) ⇒ Object



1223
1224
1225
# File 'lib/BOAST/Algorithm.rb', line 1223

def *(x)
  return Expression::new("*",self,x)
end

#+(x) ⇒ Object



1211
1212
1213
# File 'lib/BOAST/Algorithm.rb', line 1211

def +(x)
  return Expression::new("+",self,x)
end

#-(x) ⇒ Object



1227
1228
1229
# File 'lib/BOAST/Algorithm.rb', line 1227

def -(x)
  return Expression::new("-",self,x)
end

#-@Object



1231
1232
1233
# File 'lib/BOAST/Algorithm.rb', line 1231

def -@
  return Expression::new("-",nil,self)
end

#<(x) ⇒ Object



1215
1216
1217
# File 'lib/BOAST/Algorithm.rb', line 1215

def <(x)
  return Expression::new("<",self,x)
end

#==(x) ⇒ Object



1207
1208
1209
# File 'lib/BOAST/Algorithm.rb', line 1207

def ==(x)
  return Expression::new("==",self,x)
end

#>=(x) ⇒ Object



1219
1220
1221
# File 'lib/BOAST/Algorithm.rb', line 1219

def >=(x)
  return Expression::new(">=",self,x)
end

#[](*args) ⇒ Object



1235
1236
1237
# File 'lib/BOAST/Algorithm.rb', line 1235

def [](*args)
  return Index::new(self,args)
end


1251
1252
1253
1254
1255
1256
1257
1258
# File 'lib/BOAST/Algorithm.rb', line 1251

def print(final=true)
  s=""
  s += " "*BOAST::get_indent_level if final
  s += self.to_str
  s += ";" if final and [C, CL, CUDA].include?( BOAST::get_lang )
  BOAST::get_output.puts s if final
  return s
end

#to_sObject



1239
1240
1241
# File 'lib/BOAST/Algorithm.rb', line 1239

def to_s
  self.to_str
end

#to_strObject



1243
1244
1245
1246
# File 'lib/BOAST/Algorithm.rb', line 1243

def to_str
  raise "Ternary operator unsupported in FORTRAN!" if BOAST::get_lang == FORTRAN
  return self.to_str_c if [C, CL, CUDA].include?( BOAST::get_lang )
end

#to_str_cObject



1247
1248
1249
1250
# File 'lib/BOAST/Algorithm.rb', line 1247

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