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.



175
176
177
# File 'lib/llvm/core/value.rb', line 175

def initialize(block)
  @block = block
end

Instance Method Details

#eachObject

Iterates through each Instruction in the collection.



180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/llvm/core/value.rb', line 180

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.



194
195
196
197
# File 'lib/llvm/core/value.rb', line 194

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.



200
201
202
203
# File 'lib/llvm/core/value.rb', line 200

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