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.
605 606 607 |
# File 'lib/llvm/core/value.rb', line 605 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.
628 629 630 |
# File 'lib/llvm/core/value.rb', line 628 def append(name = "") BasicBlock.create(@fun, name) end |
#each ⇒ Object
Iterates through each BasicBlock in the collection.
615 616 617 618 619 620 621 622 623 624 625 |
# File 'lib/llvm/core/value.rb', line 615 def each return to_enum :each unless block_given? ptr = C.LLVMGetFirstBasicBlock(@fun) 0.upto(size-1) do |i| yield BasicBlock.from_ptr(ptr) ptr = C.LLVMGetNextBasicBlock(ptr) end self end |
#entry ⇒ Object
Returns the entry BasicBlock in the collection. This is the block the function starts on.
634 635 636 |
# File 'lib/llvm/core/value.rb', line 634 def entry BasicBlock.from_ptr(C.LLVMGetEntryBasicBlock(@fun)) end |
#first ⇒ Object
Returns the first BasicBlock in the collection.
639 640 641 642 |
# File 'lib/llvm/core/value.rb', line 639 def first ptr = C.LLVMGetFirstBasicBlock(@fun) BasicBlock.from_ptr(ptr) unless ptr.null? end |
#last ⇒ Object
Returns the last BasicBlock in the collection.
645 646 647 648 |
# File 'lib/llvm/core/value.rb', line 645 def last ptr = C.LLVMGetLastBasicBlock(@fun) BasicBlock.from_ptr(ptr) unless ptr.null? end |
#size ⇒ Object
Returns the number of BasicBlocks in the collection.
610 611 612 |
# File 'lib/llvm/core/value.rb', line 610 def size C.LLVMCountBasicBlocks(@fun) end |