class TypeProf::Type::Cell::Elements
Attributes
elems[R]
Public Class Methods
dummy_elements()
click to toggle source
# File typeprof-0.21.8/lib/typeprof/container-type.rb, line 126 def self.dummy_elements Elements.new([]) # XXX end
new(elems)
click to toggle source
# File typeprof-0.21.8/lib/typeprof/container-type.rb, line 122 def initialize(elems) @elems = elems end
Public Instance Methods
[](idx)
click to toggle source
# File typeprof-0.21.8/lib/typeprof/container-type.rb, line 186 def [](idx) @elems[idx] end
each_free_type_variable(&blk)
click to toggle source
# File typeprof-0.21.8/lib/typeprof/container-type.rb, line 176 def each_free_type_variable(&blk) @elems.each do |ty| ty.each_free_type_variable(&blk) end end
globalize(env, visited, depth)
click to toggle source
# File typeprof-0.21.8/lib/typeprof/container-type.rb, line 136 def globalize(env, visited, depth) Elements.new(@elems.map {|ty| ty.globalize(env, visited, depth) }) end
include_untyped?(scratch)
click to toggle source
# File typeprof-0.21.8/lib/typeprof/container-type.rb, line 206 def include_untyped?(scratch) return @elems.any? {|ty| ty.include_untyped?(scratch) } end
limit_size(limit)
click to toggle source
# File typeprof-0.21.8/lib/typeprof/container-type.rb, line 149 def limit_size(limit) Elements.new(@elems.map {|ty| ty.limit_size(limit) }) end
localize(env, alloc_site, depth)
click to toggle source
# File typeprof-0.21.8/lib/typeprof/container-type.rb, line 140 def localize(env, alloc_site, depth) elems = @elems.map.with_index do |ty, i| alloc_site2 = alloc_site.add_id(i) env, ty = ty.localize(env, alloc_site2, depth) ty end return env, Elements.new(elems) end
match?(other)
click to toggle source
# File typeprof-0.21.8/lib/typeprof/container-type.rb, line 165 def match?(other) return nil if @elems.size != other.elems.size subst = nil @elems.zip(other.elems) do |ty0, ty1| subst2 = Type.match?(ty0, ty1) return nil unless subst2 subst = Type.merge_substitution(subst, subst2) end subst end
pretty_print(q)
click to toggle source
# File typeprof-0.21.8/lib/typeprof/container-type.rb, line 157 def pretty_print(q) q.group(9, "Elements[", "]") do q.seplist(@elems) do |elem| q.pp elem end end end
screen_name(scratch)
click to toggle source
# File typeprof-0.21.8/lib/typeprof/container-type.rb, line 153 def screen_name(scratch) "*[#{ @elems.map {|ty| ty.screen_name(scratch) }.join(", ") }]" end
substitute(subst, depth)
click to toggle source
# File typeprof-0.21.8/lib/typeprof/container-type.rb, line 182 def substitute(subst, depth) Elements.new(@elems.map {|ty| ty.substitute(subst, depth) }) end
to_local_type(id, base_ty)
click to toggle source
# File typeprof-0.21.8/lib/typeprof/container-type.rb, line 132 def to_local_type(id, base_ty) Type::Local.new(Cell, id, base_ty) end
union(other)
click to toggle source
# File typeprof-0.21.8/lib/typeprof/container-type.rb, line 194 def union(other) return self if self == other if @elems.size != other.elems.size raise "#{ @elems.size } != #{ other.elems.size }" end elems = [] @elems.zip(other.elems) do |ty0, ty1| elems << ty0.union(ty1) end Elements.new(elems) end
update(idx, ty)
click to toggle source
# File typeprof-0.21.8/lib/typeprof/container-type.rb, line 190 def update(idx, ty) Elements.new(Utils.array_update(@elems, idx, @elems[idx].union(ty))) end