Class: Dhallish::Ast::FunctionDefinitionNode
- Inherits:
-
Object
- Object
- Dhallish::Ast::FunctionDefinitionNode
- Defined in:
- lib/ast.rb
Overview
argname should be the name of the argument. argtype should be an Ast-Node, as does body.
Instance Attribute Summary collapse
-
#argname ⇒ Object
Returns the value of attribute argname.
-
#body ⇒ Object
Returns the value of attribute body.
Instance Method Summary collapse
- #compute_type(ctx) ⇒ Object
- #evaluate(ctx) ⇒ Object
-
#initialize(argname, argtype, body) ⇒ FunctionDefinitionNode
constructor
A new instance of FunctionDefinitionNode.
Constructor Details
#initialize(argname, argtype, body) ⇒ FunctionDefinitionNode
Returns a new instance of FunctionDefinitionNode.
198 199 200 201 202 |
# File 'lib/ast.rb', line 198 def initialize(argname, argtype, body) @argname = argname @argtype = argtype @body = body end |
Instance Attribute Details
#argname ⇒ Object
Returns the value of attribute argname.
196 197 198 |
# File 'lib/ast.rb', line 196 def argname @argname end |
#body ⇒ Object
Returns the value of attribute body.
197 198 199 |
# File 'lib/ast.rb', line 197 def body @body end |
Instance Method Details
#compute_type(ctx) ⇒ Object
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# 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. unres = nil if argtype.is_a? Types::Type assert("DEBUG: wann passiert sowas? #{argtype.inspect}") { argtype..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 |