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.



1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
# File 'lib/BOAST/Algorithm.rb', line 1119

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.



1116
1117
1118
# File 'lib/BOAST/Algorithm.rb', line 1116

def args
  @args
end

#func_nameObject (readonly)

Returns the value of attribute func_name.



1115
1116
1117
# File 'lib/BOAST/Algorithm.rb', line 1115

def func_name
  @func_name
end

#prefixObject

Returns the value of attribute prefix.



1117
1118
1119
# File 'lib/BOAST/Algorithm.rb', line 1117

def prefix
  @prefix
end

Class Method Details

.parens(*args, &block) ⇒ Object



1111
1112
1113
# File 'lib/BOAST/Algorithm.rb', line 1111

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

Instance Method Details

#*(x) ⇒ Object



1153
1154
1155
# File 'lib/BOAST/Algorithm.rb', line 1153

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

#+(x) ⇒ Object



1149
1150
1151
# File 'lib/BOAST/Algorithm.rb', line 1149

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

#-(x) ⇒ Object



1161
1162
1163
# File 'lib/BOAST/Algorithm.rb', line 1161

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

#-@Object



1165
1166
1167
# File 'lib/BOAST/Algorithm.rb', line 1165

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

#/(x) ⇒ Object



1157
1158
1159
# File 'lib/BOAST/Algorithm.rb', line 1157

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

#==(x) ⇒ Object



1145
1146
1147
# File 'lib/BOAST/Algorithm.rb', line 1145

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

#[](*args) ⇒ Object



1169
1170
1171
# File 'lib/BOAST/Algorithm.rb', line 1169

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


1188
1189
1190
1191
1192
1193
1194
1195
# File 'lib/BOAST/Algorithm.rb', line 1188

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



1141
1142
1143
# File 'lib/BOAST/Algorithm.rb', line 1141

def to_s
  self.to_str
end

#to_strObject



1174
1175
1176
1177
# File 'lib/BOAST/Algorithm.rb', line 1174

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



1183
1184
1185
1186
1187
# File 'lib/BOAST/Algorithm.rb', line 1183

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

#to_str_fortranObject



1178
1179
1180
1181
1182
# File 'lib/BOAST/Algorithm.rb', line 1178

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

#to_varObject



1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
# File 'lib/BOAST/Algorithm.rb', line 1130

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