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

Class Method Details

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

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



100
101
102
# File 'lib/llvm/core/value.rb', line 100

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



105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/llvm/core/value.rb', line 105

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

#first_instructionObject

deprecated



136
137
138
# File 'lib/llvm/core/value.rb', line 136

def first_instruction  # deprecated
  instructions.first
end

#instructionsObject

Returns an Enumerable of the Instructions in the current block.



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

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

#last_instructionObject

deprecated



140
141
142
# File 'lib/llvm/core/value.rb', line 140

def last_instruction  # deprecated
  instructions.last
end

#nextObject

Returns the next basic block in the sequence.



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

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

#parentObject

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



119
120
121
122
# File 'lib/llvm/core/value.rb', line 119

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

#previousObject

Returns the previous basic block in the sequence.



131
132
133
134
# File 'lib/llvm/core/value.rb', line 131

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