Class: LLVM::Function::AttributeCollection

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

Instance Method Summary collapse

Constructor Details

#initialize(fun, index) ⇒ AttributeCollection

Returns a new instance of AttributeCollection.



762
763
764
765
# File 'lib/llvm/core/value.rb', line 762

def initialize(fun, index)
  @fun = fun
  @index = index
end

Instance Method Details

#add(attr) ⇒ Object



767
768
769
770
771
772
# File 'lib/llvm/core/value.rb', line 767

def add(attr)
  attr_kind_id = attribute_id(attr)
  ctx = Context.global
  attr_ref = C.create_enum_attribute(ctx, attr_kind_id, 0)
  C.add_attribute_at_index(@fun, @index, attr_ref)
end

#countObject



779
780
781
# File 'lib/llvm/core/value.rb', line 779

def count
  C.get_attribute_count_at_index(@fun, @index)
end

#remove(attr) ⇒ Object



774
775
776
777
# File 'lib/llvm/core/value.rb', line 774

def remove(attr)
  attr_kind_id = attribute_id(attr)
  C.remove_enum_attribute_at_index(@fun, @index, attr_kind_id)
end

#to_aObject



783
784
785
786
787
788
789
790
791
792
# File 'lib/llvm/core/value.rb', line 783

def to_a
  attr_refs = nil
  n = count
  FFI::MemoryPointer.new(:pointer, n) do |p|
    C.get_attributes_at_index(@fun, @index, p)
    attr_refs = p.read_array_of_type(:pointer, :read_pointer, n)
  end

  attr_refs.map { |e| C.get_enum_attribute_kind(e) }
end