Class: BOAST::Int

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(hash = {}) ⇒ Int

Returns a new instance of Int.



1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
# File 'lib/BOAST/Algorithm.rb', line 1121

def initialize(hash={})
  if hash[:size] then
    @size = hash[:size]
  else
    @size = BOAST::get_default_int_size
  end
  if hash[:signed] != nil then
    @signed = hash[:signed]
  else
    @signed = BOAST::get_default_int_signed
  end
end

Instance Attribute Details

#signedObject (readonly)

Returns the value of attribute signed.



1120
1121
1122
# File 'lib/BOAST/Algorithm.rb', line 1120

def signed
  @signed
end

#sizeObject (readonly)

Returns the value of attribute size.



1119
1120
1121
# File 'lib/BOAST/Algorithm.rb', line 1119

def size
  @size
end

Class Method Details

.parens(*args, &block) ⇒ Object



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

def self.parens(*args,&block)
  return Variable::new(args[0], self, *args[1..-1], &block)
end

Instance Method Details

#declObject



1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
# File 'lib/BOAST/Algorithm.rb', line 1133

def decl
  return "integer(kind=#{@size})" if BOAST::get_lang == FORTRAN
  return "int#{8*@size}_t" if BOAST::get_lang == C
  if BOAST::get_lang == CL then
    #char="cl_"
    char=""
    char += "u" if not @signed
    return char += "char" if @size==1
    return char += "short" if @size==2
    return char += "int" if @size==4
    return char += "long" if @size==8
  elsif BOAST::get_lang == CUDA then
    char = ""
    char += "unsigned " if not @signed
    return char += "char" if @size==1
    return char += "short" if @size==2
    return char += "int" if @size==4
    return char += "long long" if @size==8
  end
end