Class: LLVM::Function::BasicBlockCollection

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

Instance Method Summary collapse

Constructor Details

#initialize(fun) ⇒ BasicBlockCollection

Returns a new instance of BasicBlockCollection.



1110
1111
1112
# File 'lib/llvm/core/value.rb', line 1110

def initialize(fun)
  @fun = fun
end

Instance Method Details

#append(name = "") ⇒ Object

Adds a BasicBlock with the given name to the end of the collection. : (?String) -> BasicBlock



1135
1136
1137
# File 'lib/llvm/core/value.rb', line 1135

def append(name = "")
  BasicBlock.create(@fun, name)
end

#eachObject

Iterates through each BasicBlock in the collection.



1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
# File 'lib/llvm/core/value.rb', line 1121

def each(&)
  return to_enum :each unless block_given?

  ptr = C.get_first_basic_block(@fun)
  0.upto(size - 1) do |i|
    yield BasicBlock.from_ptr(ptr)
    ptr = C.get_next_basic_block(ptr)
  end

  self
end

#entryObject

Returns the entry BasicBlock in the collection. This is the block the function starts on. : -> BasicBlock



1142
1143
1144
# File 'lib/llvm/core/value.rb', line 1142

def entry
  BasicBlock.from_ptr(C.get_entry_basic_block(@fun))
end

#firstObject

Returns the first BasicBlock in the collection. : -> BasicBlock?



1148
1149
1150
1151
# File 'lib/llvm/core/value.rb', line 1148

def first
  ptr = C.get_first_basic_block(@fun)
  BasicBlock.from_ptr(ptr) unless ptr.null?
end

#lastObject

Returns the last BasicBlock in the collection. : -> BasicBlock?



1155
1156
1157
1158
# File 'lib/llvm/core/value.rb', line 1155

def last
  ptr = C.get_last_basic_block(@fun)
  BasicBlock.from_ptr(ptr) unless ptr.null?
end

#sizeObject

Returns the number of BasicBlocks in the collection. : -> Integer



1116
1117
1118
# File 'lib/llvm/core/value.rb', line 1116

def size
  C.count_basic_blocks(@fun)
end