123456789_123456789_123456789_123456789_123456789_

Class: TypeProf::Type::Cell::Elements

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: lib/typeprof/container-type.rb

Overview

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(elems) ⇒ Elements

[ GitHub ]

  
# File 'lib/typeprof/container-type.rb', line 122

def initialize(elems)
  @elems = elems
end

Class Method Details

.dummy_elements

[ GitHub ]

  
# File 'lib/typeprof/container-type.rb', line 126

def self.dummy_elements
  Elements.new([]) # XXX
end

Instance Attribute Details

#elems (readonly)

[ GitHub ]

  
# File 'lib/typeprof/container-type.rb', line 130

attr_reader :elems

Instance Method Details

#[](idx)

[ GitHub ]

  
# File 'lib/typeprof/container-type.rb', line 186

def [](idx)
  @elems[idx]
end

#each_free_type_variable(&blk)

[ GitHub ]

  
# File '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)

[ GitHub ]

  
# File '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) ⇒ Boolean

[ GitHub ]

  
# File 'lib/typeprof/container-type.rb', line 206

def include_untyped?(scratch)
  return @elems.any? {|ty| ty.include_untyped?(scratch) }
end

#limit_size(limit)

[ GitHub ]

  
# File '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)

[ GitHub ]

  
# File '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) ⇒ Boolean

[ GitHub ]

  
# File '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)

[ GitHub ]

  
# File '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)

[ GitHub ]

  
# File 'lib/typeprof/container-type.rb', line 153

def screen_name(scratch)
  "*[#{ @elems.map {|ty| ty.screen_name(scratch) }.join(", ") }]"
end

#substitute(subst, depth)

[ GitHub ]

  
# File '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)

[ GitHub ]

  
# File 'lib/typeprof/container-type.rb', line 132

def to_local_type(id, base_ty)
  Type::Local.new(Cell, id, base_ty)
end

#union(other)

[ GitHub ]

  
# File '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)

[ GitHub ]

  
# File 'lib/typeprof/container-type.rb', line 190

def update(idx, ty)
  Elements.new(Utils.array_update(@elems, idx, @elems[idx].union(ty)))
end