class SyntaxTree::YARV::InstructionSequence::InstructionList

When the list of instructions is first being created, it’s stored as a linked list. This is to make it easier to perform peephole optimizations and other transformations like instruction specialization.

Attributes

head_node[R]
tail_node[R]

Public Class Methods

new() click to toggle source
# File lib/syntax_tree/yarv/instruction_sequence.rb, line 48
def initialize
  @head_node = nil
  @tail_node = nil
end

Public Instance Methods

each() { |value| ... } click to toggle source
# File lib/syntax_tree/yarv/instruction_sequence.rb, line 53
def each(&_blk)
  return to_enum(__method__) unless block_given?
  each_node { |node| yield node.value }
end
each_node() { |node, value| ... } click to toggle source
# File lib/syntax_tree/yarv/instruction_sequence.rb, line 58
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
push(instruction) click to toggle source
# File lib/syntax_tree/yarv/instruction_sequence.rb, line 68
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