Class: RLTK::CG::Function::BasicBlockCollection
- Inherits:
-
Object
- Object
- RLTK::CG::Function::BasicBlockCollection
- Includes:
- Enumerable
- Defined in:
- lib/rltk/cg/function.rb
Overview
This class is used to access a function’s BasicBlocks
Instance Method Summary collapse
-
#append(name = '', builder = nil, context = nil, *block_args, &block) ⇒ BasicBlock
Add a BasicBlock to the end of this function.
-
#each {|block| ... } ⇒ Enumerator
An iterator for each block inside this collection.
-
#entry ⇒ BasicBlock?
The function’s entry block if it has been added.
-
#first ⇒ BasicBlock?
The function’s first block if one has been added.
-
#initialize(fun) ⇒ BasicBlockCollection
constructor
A new instance of BasicBlockCollection.
-
#last ⇒ BasicBlock?
The function’s last block if one has been added.
-
#size ⇒ Integer
Number of basic blocks that comprise this function.
Constructor Details
#initialize(fun) ⇒ BasicBlockCollection
Returns a new instance of BasicBlockCollection.
117 118 119 |
# File 'lib/rltk/cg/function.rb', line 117 def initialize(fun) @fun = fun end |
Instance Method Details
#append(name = '', builder = nil, context = nil, *block_args, &block) ⇒ BasicBlock
The first argument to any proc passed to this function
Add a BasicBlock to the end of this function.
will be the function the block is being appended to.
133 134 135 |
# File 'lib/rltk/cg/function.rb', line 133 def append(name = '', builder = nil, context = nil, *block_args, &block) BasicBlock.new(@fun, name, builder, context, *block_args, &block) end |
#each {|block| ... } ⇒ Enumerator
An iterator for each block inside this collection.
142 143 144 145 146 147 148 149 150 151 |
# File 'lib/rltk/cg/function.rb', line 142 def each return to_enum :each unless block_given? ptr = Bindings.get_first_basic_block(@fun) self.size.times do |i| yield BasicBlock.new(ptr) ptr = Bindings.get_next_basic_block(ptr) end end |
#entry ⇒ BasicBlock?
Returns The function’s entry block if it has been added.
154 155 156 |
# File 'lib/rltk/cg/function.rb', line 154 def entry if (ptr = Bindings.get_entry_basic_block(@fun)) then BasicBlock.new(ptr) else nil end end |
#first ⇒ BasicBlock?
Returns The function’s first block if one has been added.
159 160 161 |
# File 'lib/rltk/cg/function.rb', line 159 def first if (ptr = Bindings.get_first_basic_block(@fun)) then BasicBlock.new(ptr) else nil end end |
#last ⇒ BasicBlock?
Returns The function’s last block if one has been added.
164 165 166 |
# File 'lib/rltk/cg/function.rb', line 164 def last if (ptr = Bindings.get_last_basic_block(@fun)) then BasicBlock.new(ptr) else nil end end |
#size ⇒ Integer
Returns Number of basic blocks that comprise this function.
169 170 171 |
# File 'lib/rltk/cg/function.rb', line 169 def size Bindings.count_basic_blocks(@fun) end |