Class: LLVM::Function::BasicBlockCollection
- Inherits:
-
Object
- Object
- LLVM::Function::BasicBlockCollection
- Includes:
- Enumerable
- Defined in:
- lib/llvm/core/value.rb
Instance Method Summary collapse
-
#append(name = "") ⇒ Object
Adds a BasicBlock with the given name to the end of the collection.
-
#each ⇒ Object
Iterates through each BasicBlock in the collection.
-
#entry ⇒ Object
Returns the entry BasicBlock in the collection.
-
#first ⇒ Object
Returns the first BasicBlock in the collection.
-
#initialize(fun) ⇒ BasicBlockCollection
constructor
A new instance of BasicBlockCollection.
-
#last ⇒ Object
Returns the last BasicBlock in the collection.
-
#size ⇒ Object
Returns the number of BasicBlocks in the collection.
Constructor Details
#initialize(fun) ⇒ BasicBlockCollection
Returns a new instance of BasicBlockCollection.
818 819 820 |
# File 'lib/llvm/core/value.rb', line 818 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.
841 842 843 |
# File 'lib/llvm/core/value.rb', line 841 def append(name = "") BasicBlock.create(@fun, name) end |
#each ⇒ Object
Iterates through each BasicBlock in the collection.
828 829 830 831 832 833 834 835 836 837 838 |
# File 'lib/llvm/core/value.rb', line 828 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 |
#entry ⇒ Object
Returns the entry BasicBlock in the collection. This is the block the function starts on.
847 848 849 |
# File 'lib/llvm/core/value.rb', line 847 def entry BasicBlock.from_ptr(C.get_entry_basic_block(@fun)) end |
#first ⇒ Object
Returns the first BasicBlock in the collection.
852 853 854 855 |
# File 'lib/llvm/core/value.rb', line 852 def first ptr = C.get_first_basic_block(@fun) BasicBlock.from_ptr(ptr) unless ptr.null? end |
#last ⇒ Object
Returns the last BasicBlock in the collection.
858 859 860 861 |
# File 'lib/llvm/core/value.rb', line 858 def last ptr = C.get_last_basic_block(@fun) BasicBlock.from_ptr(ptr) unless ptr.null? end |
#size ⇒ Object
Returns the number of BasicBlocks in the collection.
823 824 825 |
# File 'lib/llvm/core/value.rb', line 823 def size C.count_basic_blocks(@fun) end |