[](idx)
click to toggle source
def [](idx)
@elems[idx]
end
each_free_type_variable(&blk)
click to toggle source
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
def globalize(env, visited, depth)
Elements.new(@elems.map {|ty| ty.globalize(env, visited, depth) })
end
include_untyped?(scratch)
click to toggle source
def include_untyped?(scratch)
return @elems.any? {|ty| ty.include_untyped?(scratch) }
end
limit_size(limit)
click to toggle source
def limit_size(limit)
Elements.new(@elems.map {|ty| ty.limit_size(limit) })
end
localize(env, alloc_site, depth)
click to toggle source
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
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
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
def screen_name(scratch)
"*[#{ @elems.map {|ty| ty.screen_name(scratch) }.join(", ") }]"
end
substitute(subst, depth)
click to toggle source
def substitute(subst, depth)
Elements.new(@elems.map {|ty| ty.substitute(subst, depth) })
end
to_local_type(id, base_ty)
click to toggle source
def to_local_type(id, base_ty)
Type::Local.new(Cell, id, base_ty)
end
union(other)
click to toggle source
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
def update(idx, ty)
Elements.new(Utils.array_update(@elems, idx, @elems[idx].union(ty)))
end