Class: Ikra::Types::LocationAwareFixedSizeArrayType

Inherits:
LocationAwareArrayType show all
Defined in:
lib/types/types/array_type.rb

Instance Attribute Summary collapse

Attributes inherited from LocationAwareArrayType

#location

Attributes inherited from ArrayType

#inner_type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from LocationAwareArrayType

#==, #to_c_type

Methods inherited from ArrayType

#==, new_original, #to_c_type, #to_ffi_type, #to_ruby_type, #to_s

Methods included from RubyType

#class_id, #eql?, #hash, #inspect, #is_primitive?, #is_union_type?, #should_generate_self_arg?, #to_array_type, #to_c_type, #to_ruby_type, #to_str, #to_union_type

Constructor Details

#initialize(inner_type, location, dimensions) ⇒ LocationAwareFixedSizeArrayType

Returns a new instance of LocationAwareFixedSizeArrayType.



111
112
113
114
# File 'lib/types/types/array_type.rb', line 111

def initialize(inner_type, location, dimensions)
    super(inner_type, location)
    @dimensions = dimensions
end

Instance Attribute Details

#dimensionsObject (readonly)

Returns the value of attribute dimensions.



109
110
111
# File 'lib/types/types/array_type.rb', line 109

def dimensions
  @dimensions
end

Class Method Details

.new(inner_type, dimensions, location: :device) ⇒ Object



97
98
99
100
101
102
103
104
105
106
# File 'lib/types/types/array_type.rb', line 97

def new(inner_type, dimensions, location: :device)
    if @cache == nil
        @cache = {}
        @cache.default_proc = Proc.new do |hash, key|
            hash[key] = new_original(*key)
        end
    end

    return @cache[[inner_type, location, dimensions]]
end

Instance Method Details

#to_commandObject



116
117
118
119
120
121
122
# File 'lib/types/types/array_type.rb', line 116

def to_command
    # No fusion possible here. The first parameter (target) is a reference to the
    # array command struct representing the [ArrayInHostSectionCommand].
    # TODO: The code depends on the template (variable name `cmd` and `input_0`).
    return Symbolic::FixedSizeArrayInHostSectionCommand.new(
        "((#{@inner_type.to_c_type} *) cmd->input_0)", @inner_type, @dimensions)
end