class Dhallish::Ast::FunctionDefinitionNode
argname should be the name of the argument. argtype should be an Ast-Node, as does body.
Attributes
argname[RW]
body[RW]
Public Class Methods
new(argname, argtype, body)
click to toggle source
# File lib/ast.rb, line 198 def initialize(argname, argtype, body) @argname = argname @argtype = argtype @body = body end
Public Instance Methods
compute_type(ctx)
click to toggle source
# File lib/ast.rb, line 204 def compute_type(ctx) argtype = @argtype.compute_type ctx assert("expected type as argument annotation: #{argtype}") { argtype.is_a? Types::Type } argtype = argtype.metadata unres = nil if argtype.is_a? Types::Type assert("DEBUG: wann passiert sowas? #{argtype.inspect}") { argtype.metadata.nil? } argtype = Types::Type.new(Types::Unresolved.new(@argname)) unres = @argname end newctx = Context.new ctx newctx[@argname] = argtype Types::Function.new(argtype, @body.compute_type(newctx), unres) end
evaluate(ctx)
click to toggle source
# File lib/ast.rb, line 222 def evaluate(ctx) Function.new(@argname, @body, ctx) end