class TypeProf::Core::AST::SigFuncType::SigTyAliasNode::SigTyUnionNode::SigTyIntersectionNode::SigTySingletonNode::SigTyInstanceNode::SigTyTupleNode
Attributes
Public Class Methods
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/sig_type.rb, line 687 def initialize(raw_decl, lenv) super(raw_decl, lenv) @types = raw_decl.types.map {|type| AST.create_rbs_type(type, 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 705 def contravariant_vertex0(genv, changes, vtx, subst) unified_elem = changes.new_contravariant_vertex(genv, [self, :Elem]) # TODO elems = @types.map do |type| nvtx = type.contravariant_vertex(genv, changes, subst) changes.add_edge(genv, nvtx, unified_elem) nvtx end changes.add_edge(genv, Source.new(Type::Array.new(genv, elems, genv.gen_ary_type(unified_elem))), vtx) end
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/sig_type.rb, line 695 def covariant_vertex0(genv, changes, vtx, subst) unified_elem = changes.new_covariant_vertex(genv, [self, :Elem]) # TODO elems = @types.map do |type| nvtx = type.covariant_vertex(genv, changes, subst) changes.add_edge(genv, nvtx, unified_elem) nvtx end changes.add_edge(genv, Source.new(Type::Array.new(genv, elems, genv.gen_ary_type(unified_elem))), vtx) end
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/sig_type.rb, line 735 def show "[#{ @types.map {|ty| ty.show }.join(", ") }]" end
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/sig_type.rb, line 693 def subnodes = { types: } def covariant_vertex0(genv, changes, vtx, subst) unified_elem = changes.new_covariant_vertex(genv, [self, :Elem]) # TODO elems = @types.map do |type| nvtx = type.covariant_vertex(genv, changes, subst) changes.add_edge(genv, nvtx, unified_elem) nvtx end changes.add_edge(genv, Source.new(Type::Array.new(genv, elems, genv.gen_ary_type(unified_elem))), vtx) end def contravariant_vertex0(genv, changes, vtx, subst) unified_elem = changes.new_contravariant_vertex(genv, [self, :Elem]) # TODO elems = @types.map do |type| nvtx = type.contravariant_vertex(genv, changes, subst) changes.add_edge(genv, nvtx, unified_elem) nvtx end changes.add_edge(genv, Source.new(Type::Array.new(genv, elems, genv.gen_ary_type(unified_elem))), vtx) end def typecheck(genv, changes, vtx, subst) changes.add_edge(genv, vtx, changes.target) vtx.each_type do |ty| case ty when Type::Array next if ty.elems.size != @types.size @types.zip(ty.elems) do |f_ty, a_ty| return false unless f_ty.typecheck(genv, changes, a_ty, subst) end return true when Type::Instance @types.each do |f_ty| return false unless f_ty.typecheck(genv, changes, vtx, subst) end return true end end false end def show "[#{ @types.map {|ty| ty.show }.join(", ") }]" end end
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/sig_type.rb, line 715 def typecheck(genv, changes, vtx, subst) changes.add_edge(genv, vtx, changes.target) vtx.each_type do |ty| case ty when Type::Array next if ty.elems.size != @types.size @types.zip(ty.elems) do |f_ty, a_ty| return false unless f_ty.typecheck(genv, changes, a_ty, subst) end return true when Type::Instance @types.each do |f_ty| return false unless f_ty.typecheck(genv, changes, vtx, subst) end return true end end false end