Class: BOAST::ConstArray

Inherits:
Array
  • Object
show all
Includes:
Inspectable, PrivateStateAccessor
Defined in:
lib/BOAST/Variable.rb

Instance Method Summary collapse

Methods included from Inspectable

#inspect

Methods included from PrivateStateAccessor

private_boolean_state_accessor, private_state_accessor

Constructor Details

#initialize(array, type = nil) ⇒ ConstArray

Returns a new instance of ConstArray.



39
40
41
42
# File 'lib/BOAST/Variable.rb', line 39

def initialize(array,type = nil)
  super(array)
  @type = type::new if type
end

Instance Method Details

#to_sObject



44
45
46
47
# File 'lib/BOAST/Variable.rb', line 44

def to_s
  return to_s_fortran if lang == FORTRAN
  return to_s_c if [C, CL, CUDA].include?( lang )
end

#to_s_cObject



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/BOAST/Variable.rb', line 62

def to_s_c
  s = ""
  return s if first.nil?
  s += "{\n"
  s += first.to_s
  s += @type.suffix if @type 
  self[1..-1].each { |v|
    s += ",\n"+v.to_s
    s += @type.suffix if @type
  }
  s += "}"
end

#to_s_fortranObject



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/BOAST/Variable.rb', line 49

def to_s_fortran
  s = ""
  return s if first.nil?
  s += "(/ &\n"
  s += first.to_s
  s += @type.suffix if @type
  self[1..-1].each { |v|
    s += ", &\n"+v.to_s
    s += @type.suffix if @type
  }
  s += " /)"
end