Class: RCGTK::BasicBlock::InstructionCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rcgtk/basic_block.rb

Overview

This class is used to access all of the Instructions that have been added to a RCGTK::BasicBlock.

Instance Method Summary collapse

Constructor Details

#initialize(bb) ⇒ InstructionCollection

Returns a new instance of InstructionCollection.

Parameters:

  • bb (BasicBlock)

    BasicBlock this collection belongs to.



125
126
127
# File 'lib/rcgtk/basic_block.rb', line 125

def initialize(bb)
  @bb = bb
end

Instance Method Details

#each {|inst| ... } ⇒ Enumerator

Iterate over each Instruction in this collection.

Yield Parameters:

Returns:

  • (Enumerator)

    An Enumerator is returned if no block is given.



134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/rcgtk/basic_block.rb', line 134

def each
  return to_enum(:each) unless block_given?

  inst = self.first

  while inst
    yield inst
    inst = inst.next
  end

  self
end

#firstInstruction

Returns First instruction in this collection.

Returns:

  • (Instruction)

    First instruction in this collection.



148
149
150
# File 'lib/rcgtk/basic_block.rb', line 148

def first
  if (ptr = Bindings.get_first_instruction(@bb)).null? then nil else Instruction.from_ptr(ptr) end
end

#lastInstruction

Returns Last instruction in this collection.

Returns:

  • (Instruction)

    Last instruction in this collection.



153
154
155
# File 'lib/rcgtk/basic_block.rb', line 153

def last
  if (ptr = Bindings.get_last_instruction(@bb)).null? then nil else Instruction.from_ptr(ptr) end
end