Class: RLTK::CG::BasicBlock::InstructionCollection

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

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(bb) ⇒ InstructionCollection



124
125
126
# File 'lib/rltk/cg/basic_block.rb', line 124

def initialize(bb)
	@bb = bb
end

Instance Method Details

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

Iterate over each Instruction in this collection.

Yield Parameters:



133
134
135
136
137
138
139
140
141
142
143
144
# 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

#firstInstruction



147
148
149
# 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

#lastInstruction



152
153
154
# 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