Class: Dhallish::Ast::RecordTypeNode

Inherits:
Object
  • Object
show all
Defined in:
lib/ast.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ RecordTypeNode

Returns a new instance of RecordTypeNode.



401
402
403
# File 'lib/ast.rb', line 401

def initialize(hash)
	@hash = hash
end

Instance Attribute Details

#hashObject

Returns the value of attribute hash.



400
401
402
# File 'lib/ast.rb', line 400

def hash
  @hash
end

Instance Method Details

#compute_type(ctx) ⇒ Object



405
406
407
408
409
410
411
412
413
414
# File 'lib/ast.rb', line 405

def compute_type(ctx)
	types = {}
	@hash.each { |name, type_expr|
		type_type = type_expr.compute_type ctx
		assert ("annotated expression of record member \"#{name}\" not a type") { type_type.is_a? Types::Type }
		types[name] = type_type.
	}

	Types::Type.new(Types::Record.new types)
end

#evaluate(ctx) ⇒ Object



416
417
418
419
420
421
422
# File 'lib/ast.rb', line 416

def evaluate(ctx)
	types = {}
	@hash.each { |key, node|
		types[key] = node.evaluate ctx
	}
	Types::Record.new types
end