Class: LLVM::Function::AttributeCollection
- Inherits:
-
Object
- Object
- LLVM::Function::AttributeCollection
- Defined in:
- lib/llvm/core/value.rb
Instance Method Summary collapse
- #add(attr) ⇒ Object
- #count ⇒ Object
-
#initialize(fun, index) ⇒ AttributeCollection
constructor
A new instance of AttributeCollection.
- #remove(attr) ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(fun, index) ⇒ AttributeCollection
Returns a new instance of AttributeCollection.
863 864 865 866 |
# File 'lib/llvm/core/value.rb', line 863 def initialize(fun, index) @fun = fun @index = index end |
Instance Method Details
#add(attr) ⇒ Object
868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 |
# File 'lib/llvm/core/value.rb', line 868 def add(attr) attr_ref = case attr when Attribute attr when Symbol, String attr_kind_id = attribute_id(attr) if attr_kind_id.is_a?(Integer) ctx = Context.global C.create_enum_attribute(ctx, attr_kind_id, 0) else attr_kind_id end else raise "Adding unknown attribute type: #{attr.inspect}" end C.add_attribute_at_index(@fun, @index, attr_ref) end |
#count ⇒ Object
891 892 893 |
# File 'lib/llvm/core/value.rb', line 891 def count C.get_attribute_count_at_index(@fun, @index) end |
#remove(attr) ⇒ Object
886 887 888 889 |
# File 'lib/llvm/core/value.rb', line 886 def remove(attr) attr_kind_id = attribute_id(attr) C.remove_enum_attribute_at_index(@fun, @index, attr_kind_id) end |
#to_a ⇒ Object
895 896 897 898 899 900 901 902 903 904 |
# File 'lib/llvm/core/value.rb', line 895 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| Attribute.send(:from_ptr, e) } end |