Class: Dhallish::Ast::UnionType
- Inherits:
-
Object
- Object
- Dhallish::Ast::UnionType
- Defined in:
- lib/ast.rb
Instance Attribute Summary collapse
-
#map ⇒ Object
map: maps labels to ast-nodes that should be types.
Instance Method Summary collapse
- #compute_type(ctx) ⇒ Object
- #evaluate(ctx) ⇒ Object
-
#initialize(map) ⇒ UnionType
constructor
A new instance of UnionType.
Constructor Details
#initialize(map) ⇒ UnionType
713 714 715 |
# File 'lib/ast.rb', line 713 def initialize(map) @map = map end |
Instance Attribute Details
#map ⇒ Object
map: maps labels to ast-nodes that should be types
711 712 713 |
# File 'lib/ast.rb', line 711 def map @map end |
Instance Method Details
#compute_type(ctx) ⇒ Object
717 718 719 720 721 722 723 724 725 726 |
# File 'lib/ast.rb', line 717 def compute_type(ctx) types_map = {} @map.each { |key, type| assert ("Duplicate labels in Union Types are not allowed") { !types_map.include? key } type_type = type.compute_type ctx assert ("annotated type in union type not a type") { type_type.is_a? Types::Type } types_map[key] = type_type. } Types::Type.new(Types::Union.new types_map) end |