Class: LLVM::BasicBlock

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

Defined Under Namespace

Classes: InstructionCollection

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Value

#add_attribute, #allocated_type, #allocated_type?, #constant?, #dump, from_ptr, from_ptr_kind, #gep_source_element_type, #gep_source_element_type?, #global_parent, #kind, #name, #name=, #null?, #poison?, #remove_attribute, to_ptr, #to_s, type, #type, #undef?

Methods included from PointerIdentity

#==, #eql?, #hash, #to_ptr

Class Method Details

.create(fun = nil, name = "") ⇒ Object

Creates a basic block for the given function with the given name.



178
179
180
# File 'lib/llvm/core/value.rb', line 178

def self.create(fun = nil, name = "")
  from_ptr(C.append_basic_block(fun, name))
end

Instance Method Details

#build(builder = nil) ⇒ Object

Build the basic block with the given builder. Creates a new one if nil. Yields the builder.



183
184
185
186
187
188
189
190
191
192
193
# File 'lib/llvm/core/value.rb', line 183

def build(builder = nil)
  if builder.nil?
    builder = Builder.new
    builder.position_at_end(self)
    yield builder
    builder.dispose
  else
    builder.position_at_end(self)
    yield builder
  end
end

#first_instructionObject

deprecated



214
215
216
# File 'lib/llvm/core/value.rb', line 214

def first_instruction
  instructions.first
end

#instructionsObject

Returns an Enumerable of the Instructions in the current block.



224
225
226
# File 'lib/llvm/core/value.rb', line 224

def instructions
  @instructions ||= InstructionCollection.new(self)
end

#last_instructionObject

deprecated



219
220
221
# File 'lib/llvm/core/value.rb', line 219

def last_instruction
  instructions.last
end

#nextObject

Returns the next basic block in the sequence.



202
203
204
205
# File 'lib/llvm/core/value.rb', line 202

def next
  ptr = C.get_next_basic_block(self)
  BasicBlock.from_ptr(ptr) unless ptr.null?
end

#parentObject

Returns the parent of this basic block (a Function).



196
197
198
199
# File 'lib/llvm/core/value.rb', line 196

def parent
  fp = C.get_basic_block_parent(self)
  LLVM::Function.from_ptr(fp) unless fp.null?
end

#previousObject

Returns the previous basic block in the sequence.



208
209
210
211
# File 'lib/llvm/core/value.rb', line 208

def previous
  ptr = C.get_previous_basic_block(self)
  BasicBlock.from_ptr(ptr) unless ptr.null?
end