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, #constant?, #dump, from_ptr, #name, #name=, #null?, to_ptr, #type, type, #undefined?

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.


78
79
80
# File 'lib/llvm/core/value.rb', line 78

def self.create(fun = nil, name = "")
  self.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.


83
84
85
86
87
88
89
90
91
92
93
# File 'lib/llvm/core/value.rb', line 83

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


113
114
115
# File 'lib/llvm/core/value.rb', line 113

def first_instruction  # deprecated
  instructions.first
end

#instructionsObject

Returns an Enumerable of the Instructions in the current block.


122
123
124
# File 'lib/llvm/core/value.rb', line 122

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

#last_instructionObject

deprecated


117
118
119
# File 'lib/llvm/core/value.rb', line 117

def last_instruction  # deprecated
  instructions.last
end

#nextObject

Returns the next basic block in the sequence.


102
103
104
105
# File 'lib/llvm/core/value.rb', line 102

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).


96
97
98
99
# File 'lib/llvm/core/value.rb', line 96

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.


108
109
110
111
# File 'lib/llvm/core/value.rb', line 108

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