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, #constant?, #dump, from_ptr, #name, #name=, #null?, #remove_attribute, to_ptr, #to_s, #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.



125
126
127
# File 'lib/llvm/core/value.rb', line 125

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.



130
131
132
133
134
135
136
137
138
139
140
# File 'lib/llvm/core/value.rb', line 130

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



161
162
163
# File 'lib/llvm/core/value.rb', line 161

def first_instruction
  instructions.first
end

#instructionsObject

Returns an Enumerable of the Instructions in the current block.



171
172
173
# File 'lib/llvm/core/value.rb', line 171

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

#last_instructionObject

deprecated



166
167
168
# File 'lib/llvm/core/value.rb', line 166

def last_instruction
  instructions.last
end

#nextObject

Returns the next basic block in the sequence.



149
150
151
152
# File 'lib/llvm/core/value.rb', line 149

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



143
144
145
146
# File 'lib/llvm/core/value.rb', line 143

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.



155
156
157
158
# File 'lib/llvm/core/value.rb', line 155

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