Class: BOAST::Sizet

Inherits:
DataType show all
Defined in:
lib/BOAST/DataTypes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DataType

inherited

Methods included from PrivateStateAccessor

private_boolean_state_accessor, private_state_accessor

Constructor Details

#initialize(hash = {}) ⇒ Sizet

Returns a new instance of Sizet.



19
20
21
22
23
24
25
# File 'lib/BOAST/DataTypes.rb', line 19

def initialize(hash={})
  if hash[:signed] != nil then
    @signed = hash[:signed]
  end
  @size = nil
  @vector_length = 1
end

Instance Attribute Details

#signedObject (readonly)

Returns the value of attribute signed.



15
16
17
# File 'lib/BOAST/DataTypes.rb', line 15

def signed
  @signed
end

#sizeObject (readonly)

Returns the value of attribute size.



16
17
18
# File 'lib/BOAST/DataTypes.rb', line 16

def size
  @size
end

#vector_lengthObject (readonly)

Returns the value of attribute vector_length.



17
18
19
# File 'lib/BOAST/DataTypes.rb', line 17

def vector_length
  @vector_length
end

Instance Method Details

#copy(options = {}) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/BOAST/DataTypes.rb', line 31

def copy(options={})
  hash = to_hash
  options.each { |k,v|
    hash[k] = v
  }
  return Sizet::new(hash)
end

#declObject



39
40
41
42
43
44
45
46
# File 'lib/BOAST/DataTypes.rb', line 39

def decl
  return "integer(kind=#{get_default_int_size})" if lang == FORTRAN
  if not @signed then
    return "size_t" if [C, CL, CUDA].include?( lang )
  else
    return "ptrdiff_t" if [C, CL, CUDA].include?( lang )
  end
end

#signed?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/BOAST/DataTypes.rb', line 48

def signed?
  return !!signed
end

#suffixObject



52
53
54
55
56
57
58
59
# File 'lib/BOAST/DataTypes.rb', line 52

def suffix
  s = ""
#      if [C, CL, CUDA].include?( lang ) then
#        s += "U" if not @signed
#        s += "LL" if @size == 8
#      end
  return s
end

#to_hashObject



27
28
29
# File 'lib/BOAST/DataTypes.rb', line 27

def to_hash
  return { :signed => @signed }
end