class TypeProf::Core::Type::Singleton

Attributes

mod[R]

Public Class Methods

new(genv, mod) click to toggle source

: (GlobalEnv, ModuleEntity) -> void

# File typeprof-0.30.1/lib/typeprof/core/type.rb, line 31
def initialize(genv, mod)
  raise unless mod.is_a?(ModuleEntity)
  # TODO: type_param
  @mod = mod
end

Public Instance Methods

base_type(_) click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/type.rb, line 39
def base_type(_)
  self
end
check_match(genv, changes, vtx) click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/type.rb, line 43
def check_match(genv, changes, vtx)
  vtx.each_type do |other_ty|
    case other_ty
    when Singleton
      other_mod = other_ty.mod
      if other_mod.module?
        # TODO: implement
      else
        mod = @mod
        while mod
          return true if mod == other_mod
          changes.add_depended_superclass(mod)
          mod = mod.superclass
        end
      end
    when Instance
      base_ty = @mod.module? ? genv.mod_type : genv.cls_type
      return true if base_ty.check_match(genv, changes, Source.new(other_ty))
    end
  end
  return false
end
get_instance_type(genv) click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/type.rb, line 70
def get_instance_type(genv)
  params = @mod.type_params
  Instance.new(genv, @mod, params ? params.map { Source.new } : [])
end
show() click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/type.rb, line 66
def show
  "singleton(#{ @mod.show_cpath })"
end