class SyntaxTree::YARV::InstructionSequence::InstructionList
and other transformations like instruction specialization.
linked list. This is to make it easier to perform peephole optimizations
When the list of instructions is first being created, it’s stored as a
def each(&_blk)
def each(&_blk) return to_enum(__method__) unless block_given? each_node { |node| yield node.value } end
def each_node
def each_node return to_enum(__method__) unless block_given? node = head_node while node yield node, node.value node = node.next_node end end
def initialize
def initialize @head_node = nil @tail_node = nil end
def push(instruction)
def push(instruction) node = Node.new(instruction) if head_node.nil? @head_node = node @tail_node = node else @tail_node.next_node = node @tail_node = node end node end