Class: TypeProf::Type::Local
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
ContainerType ,
::TypeProf::Type
|
|
Instance Chain:
|
|
Inherits: |
TypeProf::Type::ContainerType
|
Defined in: | lib/typeprof/container-type.rb |
Constant Summary
::TypeProf::Type
- Inherited
Class Method Summary
- .new(kind, id, base_type) ⇒ Local constructor
ContainerType
- Inherited
::TypeProf::Type
- Inherited
Instance Attribute Summary
- #base_type readonly
- #id readonly
- #kind readonly
Instance Method Summary
- #globalize(env, visited, depth)
- #inspect
- #method_dispatch_info
- #screen_name(scratch)
- #update_container_elem_type(subst, env, caller_ep, scratch)
ContainerType
- Inherited
::TypeProf::Type
- Inherited
Constructor Details
.new(kind, id, base_type) ⇒ Local
Instance Attribute Details
#base_type (readonly)
[ GitHub ]#id (readonly)
[ GitHub ]#kind (readonly)
[ GitHub ]Instance Method Details
#globalize(env, visited, depth)
[ GitHub ]# File 'lib/typeprof/container-type.rb', line 840
def globalize(env, visited, depth) if visited[self] || depth <= 0 Type.any else visited[self] = true elems = env.get_container_elem_types(@id) if elems elems = elems.globalize(env, visited, depth - 1) else # TODO: currently out-of-scope array cannot be accessed elems = @kind::Elements.dummy_elements end visited.delete(self) @kind.new(elems, @base_type) end end
#inspect
[ GitHub ]# File 'lib/typeprof/container-type.rb', line 831
def inspect "Type::Local[#{ @kind }, #{ @id }, base_type: #{ @base_type.inspect }]" end
#method_dispatch_info
[ GitHub ]# File 'lib/typeprof/container-type.rb', line 857
def method_dispatch_info @base_type.method_dispatch_info end
#screen_name(scratch)
[ GitHub ]# File 'lib/typeprof/container-type.rb', line 835
def screen_name(scratch) #raise "Local type must not be included in signature" "Local[#{ @kind }]" end
#update_container_elem_type(subst, env, caller_ep, scratch)
[ GitHub ]# File 'lib/typeprof/container-type.rb', line 861
def update_container_elem_type(subst, env, caller_ep, scratch) case when @kind == Cell tyvars = @base_type.klass.type_params.map {|name,| Type::Var.new(name) } # XXX: This should be skipped when the called methods belongs to superclass tyvars.each_with_index do |tyvar, idx| ty = subst[tyvar] if ty env, ty = scratch.localize_type(ty, env, caller_ep) env = scratch.update_container_elem_types(env, caller_ep, @id, @base_type) do |elems| elems.update(idx, ty) end end end when @kind == Array tyvar_elem = Type::Var.new(:Elem) if subst[tyvar_elem] ty = subst[tyvar_elem] env, ty = scratch.localize_type(ty, env, caller_ep) env = scratch.update_container_elem_types(env, caller_ep, @id, @base_type) do |elems| elems.update(nil, ty) end end when @kind == Hash tyvar_k = Type::Var.new(:K) tyvar_v = Type::Var.new(:V) if subst[tyvar_k] && subst[tyvar_v] k_ty = subst[tyvar_k] v_ty = subst[tyvar_v] alloc_site = AllocationSite.new(caller_ep) env, k_ty = scratch.localize_type(k_ty, env, caller_ep, alloc_site.add_id(:k)) env, v_ty = scratch.localize_type(v_ty, env, caller_ep, alloc_site.add_id(:v)) env = scratch.update_container_elem_types(env, caller_ep, @id, @base_type) do |elems| elems.update(k_ty, v_ty) end end end env end