class SFRP::Poly::Set

Public Class Methods

new(&block) click to toggle source
# File lib/sfrp/poly/set.rb, line 11
def initialize(&block)
  @func_h = {}
  @node_h = {}
  @tconst_h = {}
  @vconst_h = {}
  @output_node_strs = []
  @init_func_strs = []
  block.call(self) if block
end

Public Instance Methods

<<(element) click to toggle source
# File lib/sfrp/poly/set.rb, line 46
def <<(element)
  case element
  when Function
    @func_h[element.str] = element
  when Node
    @node_h[element.str] = element
  when TConst
    @tconst_h[element.str] = element
  when VConst
    @vconst_h[element.str] = element
  else
    raise
  end
end
append_init_func_str(init_func_str) click to toggle source
# File lib/sfrp/poly/set.rb, line 65
def append_init_func_str(init_func_str)
  @init_func_strs << init_func_str
end
append_output_node_str(node_str) click to toggle source
# File lib/sfrp/poly/set.rb, line 61
def append_output_node_str(node_str)
  @output_node_strs << node_str
end
func(func_str) click to toggle source
# File lib/sfrp/poly/set.rb, line 69
def func(func_str)
  raise func_str unless @func_h.key?(func_str)
  @func_h[func_str]
end
node(node_str) click to toggle source
# File lib/sfrp/poly/set.rb, line 74
def node(node_str)
  raise node_str unless @node_h.key?(node_str)
  @node_h[node_str]
end
tconst(tconst_str) click to toggle source
# File lib/sfrp/poly/set.rb, line 79
def tconst(tconst_str)
  raise tconst_str unless @tconst_h.key?(tconst_str )
  @tconst_h[tconst_str ]
end
to_mono() click to toggle source
# File lib/sfrp/poly/set.rb, line 21
def to_mono
  Mono::Set.new do |dest_set|
    @func_h.values.each do |f|
      f.check_recursion(self)
      f.ftyping(self)
    end
    @node_h.values.each do |n|
      n.check_recursion(self)
      n.typing(self)
    end
    Monofier.new(self, dest_set) do |m|
      @init_func_strs.each do |func_str|
        mono_func_str = m.use_func(func_str, func(func_str).ftyping(self))
        dest_set.append_init_func_str(mono_func_str)
      end
      @node_h.values.each do |node|
        dest_set << node.to_mono(m)
      end
      @output_node_strs.each do |node_str|
        dest_set.append_output_node_str(m.use_node(node_str))
      end
    end
  end
end
vconst(vconst_str) click to toggle source
# File lib/sfrp/poly/set.rb, line 84
def vconst(vconst_str)
  raise vconst_str unless @vconst_h.key?(vconst_str)
  @vconst_h[vconst_str]
end