class SFRP::Poly::Node
Constants
- NodeRef
Attributes
str[R]
Public Class Methods
new( str, node_refs, ftype_annot, eval_func_str, init_func_str = nil )
click to toggle source
# File lib/sfrp/poly/elements.rb, line 56 def initialize( str, node_refs, ftype_annot, eval_func_str, init_func_str = nil ) @str = str @node_refs = node_refs @ftype_annot = ftype_annot @eval_func_str = eval_func_str @init_func_str = init_func_str end
Public Instance Methods
check_recursion(set, path = [])
click to toggle source
# File lib/sfrp/poly/elements.rb, line 82 def check_recursion(set, path = []) if path.include?(@str) raise RecursiveError.new(path.drop_while { |s| s != @str }) end @node_refs.each do |nr| next if nr.last set.node(nr.node_str).check_recursion(set, path + [@str]) end end
to_mono(monofier)
click to toggle source
# File lib/sfrp/poly/elements.rb, line 92 def to_mono(monofier) raise UndeterminableTypeError.new(@str, @typing) unless @typing.mono? type_str = monofier.use_type(@typing) node_str = monofier.use_node(@str) eval_func_str = monofier.use_func(@eval_func_str, @ftyping) if @init_func_str init_func_str = monofier.use_func(@init_func_str, @init_ftyping) else init_func_str = nil end M.node(type_str, node_str, eval_func_str, init_func_str) do |n| @node_refs.each do |node_ref| node_str = monofier.use_node(node_ref.node_str) node_ref.last ? n.l(node_str) : n.c(node_str) end end end
typing(set)
click to toggle source
# File lib/sfrp/poly/elements.rb, line 66 def typing(set) return @typing if @typing @typing = Typing.new @ftyping = set.func(@eval_func_str).ftyping(set).instance do |eval_ft| @node_refs.zip(eval_ft.params) do |node_ref, typing| set.node(node_ref.node_str).typing(set).unify(typing) end next unless @init_func_str @init_ftyping = set.func(@init_func_str).ftyping(set).instance do |ft| raise unless ft.params.empty? ft.body.unify(eval_ft.body) end end @ftyping.unify(@ftype_annot.to_ftyping).body.unify(@typing) end