Class: LLVM::StructType

Inherits:
Type
  • Object
show all
Defined in:
lib/llvm/core/type.rb

Instance Method Summary collapse

Methods inherited from Type

#aggregate?, #align, array, #dump, #element_type, from_ptr, function, #kind, label, #null, #null_pointer, #pointer, pointer, rec, #size, struct, #to_s, vector, void, x86_amx, x86_mmx

Methods included from PointerIdentity

#==, #eql?, #hash, #to_ptr

Instance Method Details

#element_typesObject

Returns the element types of the struct.



185
186
187
188
189
190
191
192
193
# File 'lib/llvm/core/type.rb', line 185

def element_types
  count = C.count_struct_element_types(self)
  elt_types = nil
  FFI::MemoryPointer.new(FFI.type_size(:pointer) * count) do |types_ptr|
    C.get_struct_element_types(self, types_ptr)
    elt_types = types_ptr.read_array_of_pointer(count).map { |type_ptr| Type.from_ptr(type_ptr, nil) }
  end
  elt_types
end

#element_types=(elt_types) ⇒ Object

Sets the struct body.



196
197
198
199
200
201
# File 'lib/llvm/core/type.rb', line 196

def element_types=(elt_types)
  elt_types.map! { |ty| LLVM::Type(ty) }
  elt_types_ptr = FFI::MemoryPointer.new(FFI.type_size(:pointer) * elt_types.size)
  elt_types_ptr.write_array_of_pointer(elt_types)
  C.struct_set_body(self, elt_types_ptr, elt_types.size, 0)
end

#nameObject

Returns the name of the struct.



180
181
182
# File 'lib/llvm/core/type.rb', line 180

def name
  C.get_struct_name(self)
end