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.



209
210
211
# File 'lib/llvm/core/value.rb', line 209

def initialize(block)
  @block = block
end

Instance Method Details

#eachObject

Iterates through each Instruction in the collection.



214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/llvm/core/value.rb', line 214

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.



228
229
230
231
# File 'lib/llvm/core/value.rb', line 228

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.



234
235
236
237
# File 'lib/llvm/core/value.rb', line 234

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