Class: BOAST::FuncCall

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(func_name, *args) ⇒ FuncCall

Returns a new instance of FuncCall.



1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
# File 'lib/BOAST/Algorithm.rb', line 1273

def initialize(func_name, *args)
  @func_name = func_name
  if args.last.kind_of?(Hash) then
    @options = args.last
    @args = args[0..-2]
  else
    @args = args
  end
  @return_type = @options[:returns] if @options
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



1270
1271
1272
# File 'lib/BOAST/Algorithm.rb', line 1270

def args
  @args
end

#func_nameObject (readonly)

Returns the value of attribute func_name.



1269
1270
1271
# File 'lib/BOAST/Algorithm.rb', line 1269

def func_name
  @func_name
end

#prefixObject

Returns the value of attribute prefix.



1271
1272
1273
# File 'lib/BOAST/Algorithm.rb', line 1271

def prefix
  @prefix
end

Class Method Details

.parens(*args, &block) ⇒ Object



1265
1266
1267
# File 'lib/BOAST/Algorithm.rb', line 1265

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

Instance Method Details

#*(x) ⇒ Object



1307
1308
1309
# File 'lib/BOAST/Algorithm.rb', line 1307

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

#+(x) ⇒ Object



1303
1304
1305
# File 'lib/BOAST/Algorithm.rb', line 1303

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

#-(x) ⇒ Object



1315
1316
1317
# File 'lib/BOAST/Algorithm.rb', line 1315

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

#-@Object



1319
1320
1321
# File 'lib/BOAST/Algorithm.rb', line 1319

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

#/(x) ⇒ Object



1311
1312
1313
# File 'lib/BOAST/Algorithm.rb', line 1311

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

#==(x) ⇒ Object



1299
1300
1301
# File 'lib/BOAST/Algorithm.rb', line 1299

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

#[](*args) ⇒ Object



1323
1324
1325
# File 'lib/BOAST/Algorithm.rb', line 1323

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


1342
1343
1344
1345
1346
1347
1348
1349
# File 'lib/BOAST/Algorithm.rb', line 1342

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



1295
1296
1297
# File 'lib/BOAST/Algorithm.rb', line 1295

def to_s
  self.to_str
end

#to_strObject



1328
1329
1330
1331
# File 'lib/BOAST/Algorithm.rb', line 1328

def to_str
  return self.to_str_fortran if BOAST::get_lang == FORTRAN
  return self.to_str_c if [C, CL, CUDA].include?( BOAST::get_lang )
end

#to_str_cObject



1337
1338
1339
1340
1341
# File 'lib/BOAST/Algorithm.rb', line 1337

def to_str_c
  s = ""
  s += @prefix if @prefix
  s += "#{func_name}(#{@args.join(", ")})"
end

#to_str_fortranObject



1332
1333
1334
1335
1336
# File 'lib/BOAST/Algorithm.rb', line 1332

def to_str_fortran
  s = ""
  s += @prefix if @prefix
  s += "#{func_name}(#{@args.join(", ")})"
end

#to_varObject



1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
# File 'lib/BOAST/Algorithm.rb', line 1284

def to_var
  if @return_type then
    if @return_type.kind_of?(Variable)
      return @return_type.copy("#{self}")
    else
      return Variable::new("#{self}", @return_type)
    end
  end
  return nil
end