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


200
201
202
# File 'lib/stupidedi/builder/instruction_table.rb', line 200

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

.emptyInstructionTable::Empty


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

def empty
  InstructionTable::Empty
end