class RLTK::CG::BasicBlock::InstructionCollection

This class is used to access all of the {Instruction Instructions} that have been added to a {BasicBlock}.

Public Class Methods

new(bb) click to toggle source

@param [BasicBlock] bb BasicBlock this collection belongs to.

# File lib/rltk/cg/basic_block.rb, line 124
def initialize(bb)
        @bb = bb
end

Public Instance Methods

each() { |inst| ... } click to toggle source

Iterate over each {Instruction} in this collection.

@yieldparam inst [Instruction]

@return [Enumerator] An Enumerator is returned if no block is given.

# File lib/rltk/cg/basic_block.rb, line 133
def each
        return to_enum(:each) unless block_given?

        inst = self.first

        while inst
                yield inst
                inst = inst.next
        end

        self
end
first() click to toggle source

@return [Instruction] First instruction in this collection.

# File lib/rltk/cg/basic_block.rb, line 147
def first
        if (ptr = Bindings.get_first_instruction(@bb)).null? then nil else Instruction.from_ptr(ptr) end
end
last() click to toggle source

@return [Instruction] Last instruction in this collection.

# File lib/rltk/cg/basic_block.rb, line 152
def last
        if (ptr = Bindings.get_last_instruction(@bb)).null? then nil else Instruction.from_ptr(ptr) end
end