Class: 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 = '', context = nil, builder = 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 = '', context = nil, builder = nil, *block_args, &block) ⇒ BasicBlock
Add a BasicBlock to the end of this function.
130 131 132 |
# File 'lib/rltk/cg/function.rb', line 130 def append(name = '', context = nil, builder = nil, *block_args, &block) BasicBlock.new(@fun, name, context, builder, *block_args, &block) end |
#each {|block| ... } ⇒ Enumerator
An iterator for each block inside this collection.
139 140 141 142 143 144 145 146 147 148 |
# File 'lib/rltk/cg/function.rb', line 139 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.
151 152 153 |
# File 'lib/rltk/cg/function.rb', line 151 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.
156 157 158 |
# File 'lib/rltk/cg/function.rb', line 156 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.
161 162 163 |
# File 'lib/rltk/cg/function.rb', line 161 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.
166 167 168 |
# File 'lib/rltk/cg/function.rb', line 166 def size Bindings.count_basic_blocks(@fun) end |