class IDL::Engine::ProductionStack

Public Class Methods

new() click to toggle source
# File lib/ridl/runner.rb, line 37
def initialize
  @stack = []
  @index = {}
end

Public Instance Methods

[](id) click to toggle source
# File lib/ridl/runner.rb, line 82
def [](id)
  @stack[@index[id.to_sym]].last
end
empty?() click to toggle source
# File lib/ridl/runner.rb, line 46
def empty?
  @stack.empty?
end
has?(id) click to toggle source
# File lib/ridl/runner.rb, line 78
def has?(id)
  @index.has_key?(id.to_sym)
end
peek() click to toggle source
# File lib/ridl/runner.rb, line 63
def peek
  return nil if empty?

  id, _ = @stack.first
  id
end
pop() click to toggle source
# File lib/ridl/runner.rb, line 55
def pop
  return nil if empty?

  id, prod = @stack.shift
  @index.delete(id)
  prod
end
push(id, prod) click to toggle source
# File lib/ridl/runner.rb, line 50
def push(id, prod)
  @index[id.to_sym] = @stack.size
  @stack << [id.to_sym, prod]
end
remove(id) click to toggle source
# File lib/ridl/runner.rb, line 70
def remove(id)
  return nil unless has?(id)

  i = @index.delete(id.to_sym)
  _, producer = @productionstack.delete(i)
  producer
end
size() click to toggle source
# File lib/ridl/runner.rb, line 42
def size
  @stack.size
end