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.



246
247
248
# File 'lib/llvm/core/value.rb', line 246

def initialize(block)
  @block = block
end

Instance Method Details

#eachObject

Iterates through each Instruction in the collection.



251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/llvm/core/value.rb', line 251

def each(&)
  return to_enum :each unless block_given?
  inst = first
  final = last

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

  self
end

#firstObject

Returns the first Instruction in the collection.



266
267
268
269
# File 'lib/llvm/core/value.rb', line 266

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

#lastObject

Returns the last Instruction in the collection.



272
273
274
275
# File 'lib/llvm/core/value.rb', line 272

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