Class: Stupidedi::Builder::InstructionTable

Inherits:
Object
  • Object
show all
Includes:
Inspect
Defined in:
lib/stupidedi/builder/instruction_table.rb

Direct Known Subclasses

NonEmpty

Defined Under Namespace

Classes: NonEmpty

Constant Summary collapse

Empty =
Class.new(InstructionTable) do
  # @return [Empty]
  def copy(changes = {})
    self
  end

  # @return [Integer]
  def length
    0
  end

  # @return nil
  def at(segment_use)
    nil
  end

  # @return [NonEmpty]
  def push(instructions)
    InstructionTable::NonEmpty.new(instructions, self)
  end

  def matches(segment_tok)
    raise Exceptions::ParseError,
      "empty stack"
  end

  # @return [Empty]
  def pop(count)
    if count.zero?
      self
    else
      "empty stack"
    end
  end

  # @return [Empty]
  def drop(count)
    self
  end

  # @return [void]
  def pretty_print(q)
    q.text "InstructionTable.empty"
  end
end.new

Constructors collapse

Methods included from Inspect

#inspect

Class Method Details

.build(instructions) ⇒ InstructionTable::NonEmpty



196
197
198
# File 'lib/stupidedi/builder/instruction_table.rb', line 196

def build(instructions)
  empty.push(instructions)
end

.emptyInstructionTable::Empty



191
192
193
# File 'lib/stupidedi/builder/instruction_table.rb', line 191

def empty
  InstructionTable::Empty
end