Class: SFRP::Poly::FuncCallExp

Inherits:
Object
  • Object
show all
Defined in:
lib/sfrp/poly/expression.rb

Instance Method Summary collapse

Constructor Details

#initialize(func_str, arg_exps, id = nil) ⇒ FuncCallExp

Returns a new instance of FuncCallExp.



45
46
47
48
49
# File 'lib/sfrp/poly/expression.rb', line 45

def initialize(func_str, arg_exps, id = nil)
  @func_str = func_str
  @arg_exps = arg_exps
  @id = id
end

Instance Method Details

#called_func_strsObject



63
64
65
# File 'lib/sfrp/poly/expression.rb', line 63

def called_func_strs
  [@func_str, *@arg_exps.flat_map(&:called_func_strs)]
end

#cloneObject



59
60
61
# File 'lib/sfrp/poly/expression.rb', line 59

def clone
  FuncCallExp.new(@func_str, @arg_exps.map(&:clone), @id)
end

#to_mono(monofier) ⇒ Object



67
68
69
70
71
72
# File 'lib/sfrp/poly/expression.rb', line 67

def to_mono(monofier)
  raise UndeterminableTypeError.new(@id, @typing) unless @typing.mono?
  mono_func_str = monofier.use_func(@func_str, @ftyping)
  args = @arg_exps.map { |e| e.to_mono(monofier) }
  M.call_e(monofier.use_type(@typing), mono_func_str, *args)
end

#typing(set, var_env) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/sfrp/poly/expression.rb', line 51

def typing(set, var_env)
  raise if @typing
  @ftyping = set.func(@func_str).ftyping(set).instance do |ft|
    ft.params.zip(@arg_exps) { |t, e| e.typing(set, var_env).unify(t) }
  end
  @typing = @ftyping.body
end