class TypeProf::Core::AST::SigFuncType::SigTyAliasNode::SigTyUnionNode::SigTyIntersectionNode::SigTySingletonNode::SigTyInstanceNode::SigTyTupleNode::SigTyRecordNode
Attributes
Public Class Methods
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/sig_type.rb, line 741 def initialize(raw_decl, lenv) super(raw_decl, lenv) @fields = raw_decl.fields.transform_values { |val| AST.create_rbs_type(val, lenv) } end
Calls superclass method
TypeProf::Core::AST::Node::new
Public Instance Methods
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/sig_type.rb, line 767 def contravariant_vertex0(genv, changes, vtx, subst) field_vertices = {} @fields.each do |key, field_node| field_vertices[key] = field_node.contravariant_vertex(genv, changes, subst) end # Create base Hash type for Record key_vtx = Source.new(genv.symbol_type) # Create union of all field values for the Hash value type val_vtx = changes.new_contravariant_vertex(genv, [self, :union]) field_vertices.each_value do |field_vtx| changes.add_edge(genv, field_vtx, val_vtx) end base_hash_type = genv.gen_hash_type(key_vtx, val_vtx) changes.add_edge(genv, Source.new(Type::Record.new(genv, field_vertices, base_hash_type)), vtx) end
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/sig_type.rb, line 749 def covariant_vertex0(genv, changes, vtx, subst) field_vertices = {} @fields.each do |key, field_node| field_vertices[key] = field_node.covariant_vertex(genv, changes, subst) end # Create base Hash type for Record key_vtx = Source.new(genv.symbol_type) # Create union of all field values for the Hash value type val_vtx = changes.new_covariant_vertex(genv, [self, :union]) field_vertices.each_value do |field_vtx| changes.add_edge(genv, field_vtx, val_vtx) end base_hash_type = genv.gen_hash_type(key_vtx, val_vtx) changes.add_edge(genv, Source.new(Type::Record.new(genv, field_vertices, base_hash_type)), vtx) end
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/sig_type.rb, line 800 def show field_strs = @fields.map do |key, field_node| "#{ key }: #{ field_node.show }" end "{ #{ field_strs.join(", ") } }" end
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/sig_type.rb, line 747 def subnodes = { fields: } def covariant_vertex0(genv, changes, vtx, subst) field_vertices = {} @fields.each do |key, field_node| field_vertices[key] = field_node.covariant_vertex(genv, changes, subst) end # Create base Hash type for Record key_vtx = Source.new(genv.symbol_type) # Create union of all field values for the Hash value type val_vtx = changes.new_covariant_vertex(genv, [self, :union]) field_vertices.each_value do |field_vtx| changes.add_edge(genv, field_vtx, val_vtx) end base_hash_type = genv.gen_hash_type(key_vtx, val_vtx) changes.add_edge(genv, Source.new(Type::Record.new(genv, field_vertices, base_hash_type)), vtx) end def contravariant_vertex0(genv, changes, vtx, subst) field_vertices = {} @fields.each do |key, field_node| field_vertices[key] = field_node.contravariant_vertex(genv, changes, subst) end # Create base Hash type for Record key_vtx = Source.new(genv.symbol_type) # Create union of all field values for the Hash value type val_vtx = changes.new_contravariant_vertex(genv, [self, :union]) field_vertices.each_value do |field_vtx| changes.add_edge(genv, field_vtx, val_vtx) end base_hash_type = genv.gen_hash_type(key_vtx, val_vtx) changes.add_edge(genv, Source.new(Type::Record.new(genv, field_vertices, base_hash_type)), vtx) end def typecheck(genv, changes, vtx, subst) changes.add_edge(genv, vtx, changes.target) vtx.each_type do |ty| case ty when Type::Hash @fields.each do |key, field_node| val_vtx = ty.get_value(key) return false unless field_node.typecheck(genv, changes, val_vtx, subst) end return true end end false end def show field_strs = @fields.map do |key, field_node| "#{ key }: #{ field_node.show }" end "{ #{ field_strs.join(", ") } }" end end
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/sig_type.rb, line 785 def typecheck(genv, changes, vtx, subst) changes.add_edge(genv, vtx, changes.target) vtx.each_type do |ty| case ty when Type::Hash @fields.each do |key, field_node| val_vtx = ty.get_value(key) return false unless field_node.typecheck(genv, changes, val_vtx, subst) end return true end end false end