class FunctionTable

Public Class Methods

new() click to toggle source
# File lib/function_table.rb, line 3
def initialize
  @functions = Hash.new do |h,k|
    h[k] = []
  end
end

Public Instance Methods

[](name) click to toggle source
# File lib/function_table.rb, line 14
def [](name) # HACK: just here for transition
  puts "\n# WARNING: FunctionTable.[] called from #{caller[0]}" if $DEBUG
  @functions[name].first
end
add_function(name, type) click to toggle source
# File lib/function_table.rb, line 24
def add_function(name, type)
  @functions[name] << type
  type
end
cheat(name) click to toggle source
# File lib/function_table.rb, line 9
def cheat(name) # HACK: just here for debugging
  puts "\n# WARNING: FunctionTable.cheat called from #{caller[0]}" if $DEBUG
  @functions[name]
end
has_key?(name) click to toggle source
# File lib/function_table.rb, line 19
def has_key?(name) # HACK: just here for transition
  puts "\n# WARNING: FunctionTable.has_key? called from #{caller[0]}" if $DEBUG
  @functions.has_key?(name)
end
unify(name, type) { |name, type| ... } click to toggle source
# File lib/function_table.rb, line 29
def unify(name, type)
  success = false
  @functions[name].each do |o| # unify(type)
    begin
      o.unify type
      success = true
    rescue
      # ignore
    end
  end
  unless success then
    yield(name, type) if block_given?
  end
  type
end