class TypeProf::Core::AST::SigFuncType::SigTyAliasNode::SigTyUnionNode::SigTySingletonNode - typeprof: Ruby Standard Library Documentation

# class TypeProf::Core::AST::SigFuncType::SigTyAliasNode::SigTyUnionNode::SigTySingletonNode

### Attributes

cpath[R]
toplevel[R]

### Public Class Methods

new(raw_decl, lenv) click to toggle source
Calls superclass method `TypeProf::Core::AST::Node::new`

    # File typeprof-0.30.1/lib/typeprof/core/ast/sig_type.rb, line 334
    def initialize(raw_decl, lenv)
      super(raw_decl, lenv)
      name = raw_decl.name
      @cpath = name.namespace.path + [name.name]
      @toplevel = name.namespace.absolute?
    end

### Public Instance Methods

attrs(= { cpath:, toplevel: }) click to toggle source

    # File typeprof-0.30.1/lib/typeprof/core/ast/sig_type.rb, line 342
      def attrs = { cpath:, toplevel: }

      def define0(genv)
        const_reads = []
        const_read = BaseConstRead.new(genv, @cpath.first, @toplevel ? CRef::Toplevel : @lenv.cref)
        const_reads << const_read
        unless @cpath.empty?
          @cpath[1..].each do |cname|
            const_read = ScopedConstRead.new(cname, const_read)
            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 show
        s = "::#{ @cpath.join("::") }"
        if !@args.empty?
          s << "[...]"
        end
        "singleton(#{ s })"
      end
    end

contravariant_vertex0(genv, changes, vtx, subst) click to toggle source

    # File typeprof-0.30.1/lib/typeprof/core/ast/sig_type.rb, line 372
    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

covariant_vertex0(genv, changes, vtx, subst) click to toggle source

    # File typeprof-0.30.1/lib/typeprof/core/ast/sig_type.rb, line 363
    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

define0(genv) click to toggle source

    # File typeprof-0.30.1/lib/typeprof/core/ast/sig_type.rb, line 344
    def define0(genv)
      const_reads = []
      const_read = BaseConstRead.new(genv, @cpath.first, @toplevel ? CRef::Toplevel : @lenv.cref)
      const_reads << const_read
      unless @cpath.empty?
        @cpath[1..].each do |cname|
          const_read = ScopedConstRead.new(cname, const_read)
          const_reads << const_read
        end
      end
      const_reads
    end

show() click to toggle source

    # File typeprof-0.30.1/lib/typeprof/core/ast/sig_type.rb, line 381
    def show
      s = "::#{ @cpath.join("::") }"
      if !@args.empty?
        s << "[...]"
      end
      "singleton(#{ s })"
    end

undefine0(genv) click to toggle source

    # File typeprof-0.30.1/lib/typeprof/core/ast/sig_type.rb, line 357
    def undefine0(genv)
      @static_ret.each do |const_read|
        const_read.destroy(genv)
      end
    end