class TypeProf::Core::AST::SigFuncType::SigTyAliasNode::SigTyUnionNode::SigTyIntersectionNode::SigTySingletonNode
Attributes
Public Class Methods
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/sig_type.rb, line 528 def initialize(raw_decl, lenv) super(raw_decl, lenv) name = raw_decl.name @cpath = name.namespace.path + [name.name] @toplevel = name.namespace.absolute? 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 536 def attrs = { cpath:, toplevel: } def define0(genv) const_reads = [] const_read = BaseConstRead.new(genv, @cpath.first, @toplevel ? CRef::Toplevel : @lenv.cref, false) const_reads << const_read unless @cpath.empty? @cpath[1..].each do |cname| const_read = ScopedConstRead.new(cname, const_read, false) const_reads << const_read end end const_reads end def undefine0(genv) @static_ret.each do |const_read| const_read.destroy(genv) end end def covariant_vertex0(genv, changes, vtx, subst) # TODO: type.args changes.add_depended_static_read(@static_ret.last) cpath = @static_ret.last.cpath return unless cpath mod = genv.resolve_cpath(cpath) changes.add_edge(genv, Source.new(Type::Singleton.new(genv, mod)), vtx) end def contravariant_vertex0(genv, changes, vtx, subst) # TODO: type.args changes.add_depended_static_read(@static_ret.last) cpath = @static_ret.last.cpath return unless cpath mod = genv.resolve_cpath(cpath) changes.add_edge(genv, Source.new(Type::Singleton.new(genv, mod)), vtx) end def typecheck(genv, changes, vtx, subst) changes.add_depended_static_read(@static_ret.last) cpath = @static_ret.last.cpath return unless cpath f_mod = genv.resolve_cpath(cpath) changes.add_edge(genv, vtx, changes.target) vtx.each_type do |ty| case ty when Type::Singleton if f_mod.module? # TODO: implement else a_mod = ty.mod while a_mod return true if a_mod == f_mod changes.add_depended_superclass(a_mod) a_mod = a_mod.superclass end end end end false end def show s = "::#{ @cpath.join("::") }" if !@args.empty? s << "[...]" end "singleton(#{ s })" end end
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/sig_type.rb, line 566 def contravariant_vertex0(genv, changes, vtx, subst) # TODO: type.args changes.add_depended_static_read(@static_ret.last) cpath = @static_ret.last.cpath return unless cpath mod = genv.resolve_cpath(cpath) changes.add_edge(genv, Source.new(Type::Singleton.new(genv, mod)), vtx) end
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/sig_type.rb, line 557 def covariant_vertex0(genv, changes, vtx, subst) # TODO: type.args changes.add_depended_static_read(@static_ret.last) cpath = @static_ret.last.cpath return unless cpath mod = genv.resolve_cpath(cpath) changes.add_edge(genv, Source.new(Type::Singleton.new(genv, mod)), vtx) end
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/sig_type.rb, line 538 def define0(genv) const_reads = [] const_read = BaseConstRead.new(genv, @cpath.first, @toplevel ? CRef::Toplevel : @lenv.cref, false) const_reads << const_read unless @cpath.empty? @cpath[1..].each do |cname| const_read = ScopedConstRead.new(cname, const_read, false) const_reads << const_read end end const_reads end
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/sig_type.rb, line 599 def show s = "::#{ @cpath.join("::") }" if !@args.empty? s << "[...]" end "singleton(#{ s })" end
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/sig_type.rb, line 575 def typecheck(genv, changes, vtx, subst) changes.add_depended_static_read(@static_ret.last) cpath = @static_ret.last.cpath return unless cpath f_mod = genv.resolve_cpath(cpath) changes.add_edge(genv, vtx, changes.target) vtx.each_type do |ty| case ty when Type::Singleton if f_mod.module? # TODO: implement else a_mod = ty.mod while a_mod return true if a_mod == f_mod changes.add_depended_superclass(a_mod) a_mod = a_mod.superclass end end end end false end
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/sig_type.rb, line 551 def undefine0(genv) @static_ret.each do |const_read| const_read.destroy(genv) end end