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.



1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
# File 'lib/BOAST/Algorithm.rb', line 1102

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

#signed ⇒ Object (readonly)

Returns the value of attribute signed.



1101
1102
1103
# File 'lib/BOAST/Algorithm.rb', line 1101

def signed
  @signed
end

#size ⇒ Object (readonly)

Returns the value of attribute size.



1100
1101
1102
# File 'lib/BOAST/Algorithm.rb', line 1100

def size
  @size
end

Class Method Details

.parens(*args, &block) ⇒ Object



1096
1097
1098
# File 'lib/BOAST/Algorithm.rb', line 1096

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

Instance Method Details

#decl ⇒ Object



1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
# File 'lib/BOAST/Algorithm.rb', line 1114

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