Class: LLVM::BasicBlock::InstructionCollection

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

Instance Method Summary collapse

Constructor Details

#initialize(block) ⇒ InstructionCollection

Returns a new instance of InstructionCollection.



153
154
155
# File 'lib/llvm/core/value.rb', line 153

def initialize(block)
  @block = block
end

Instance Method Details

#eachObject

Iterates through each Instruction in the collection.



158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/llvm/core/value.rb', line 158

def each
  return to_enum :each unless block_given?
  inst, last = first, last

  while inst
    yield inst
    break if inst == last
    inst = inst.next
  end

  self
end

#firstObject

Returns the first Instruction in the collection.



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

def first
  ptr = C.LLVMGetFirstInstruction(@block)
  LLVM::Instruction.from_ptr(ptr) unless ptr.null?
end

#lastObject

Returns the last Instruction in the collection.



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

def last
  ptr = C.LLVMGetLastInstruction(@block)
  LLVM::Instruction.from_ptr(ptr) unless ptr.null?
end