class Dhallish::Ast::FunctionCallNode
Attributes
arg[RW]
fn[RW]
Public Class Methods
new(fn, arg)
click to toggle source
# File lib/ast.rb, line 231 def initialize(fn, arg) @fn = fn @arg = arg end
Public Instance Methods
compute_type(ctx)
click to toggle source
# File lib/ast.rb, line 236 def compute_type(ctx) arg_type = @arg.compute_type ctx fn_type = @fn.compute_type ctx assert("only functions can be called, not #{fn_type}") { fn_type.is_a? Types::Function } if arg_type.is_a? Types::Type and !fn_type.unres.nil? assert ("argument type mismatch: expected: #{fn_type.argtype}, got: #{arg_type}") { fn_type.argtype.is_a? Types::Type } Types::resolve(fn_type.restype, fn_type.unres, arg_type.metadata) else unification = Types::unification(fn_type.argtype, arg_type) assert ("argument type mismatch: expected: #{fn_type.argtype}, got: #{arg_type}") { !unification.nil? } fn_type.restype end end
evaluate(ctx)
click to toggle source
# File lib/ast.rb, line 252 def evaluate(ctx) fn = @fn.evaluate ctx arg = @arg.evaluate ctx fn.call arg end