class TypeProf::Type::Hash

Attributes

base_type[R]
elems[R]

Public Class Methods

new(elems, base_type) click to toggle source
# File typeprof-0.15.2/lib/typeprof/container-type.rb, line 554
def initialize(elems, base_type)
  @elems = elems
  raise unless elems
  @base_type = base_type
end

Public Instance Methods

generate_substitution() click to toggle source
# File typeprof-0.15.2/lib/typeprof/container-type.rb, line 594
def generate_substitution
  tyvar_k = Type::Var.new(:K)
  tyvar_v = Type::Var.new(:V)
  k_ty0, v_ty0 = @elems.squash
  # XXX: need to heuristically replace ret type Hash[K, V] with self, instead of conversative type?
  { tyvar_k => k_ty0, tyvar_v => v_ty0 }
end
inspect() click to toggle source
# File typeprof-0.15.2/lib/typeprof/container-type.rb, line 562
def inspect
  "Type::Hash#{ @elems.inspect }"
end
limit_size(limit) click to toggle source
# File typeprof-0.15.2/lib/typeprof/container-type.rb, line 579
def limit_size(limit)
  return Type.any if limit <= 0
  Hash.new(@elems.limit_size(limit - 1), @base_type)
end
localize(env, alloc_site, depth) click to toggle source
# File typeprof-0.15.2/lib/typeprof/container-type.rb, line 570
def localize(env, alloc_site, depth)
  return env, Type.any if depth <= 0
  alloc_site = alloc_site.add_id(:hash).add_id(@base_type)
  env, elems = @elems.localize(env, alloc_site, depth - 1)
  ty = Local.new(Hash, alloc_site, @base_type)
  env = env.deploy_type(alloc_site, elems)
  return env, ty
end
method_dispatch_info() click to toggle source
# File typeprof-0.15.2/lib/typeprof/container-type.rb, line 584
def method_dispatch_info
  raise
end
screen_name(scratch) click to toggle source
# File typeprof-0.15.2/lib/typeprof/container-type.rb, line 566
def screen_name(scratch)
  @elems.screen_name(scratch)
end
substitute(subst, depth) click to toggle source
# File typeprof-0.15.2/lib/typeprof/container-type.rb, line 588
def substitute(subst, depth)
  return Type.any if depth <= 0
  elems = @elems.substitute(subst, depth - 1)
  Hash.new(elems, @base_type)
end