123456789_123456789_123456789_123456789_123456789_

Class: TypeProf::Type::ContainerType

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

Overview

Cell, Array, and Hash are types for global interface, e.g., TypedISeq. Do not push such types to local environment, stack, etc.

Constant Summary

::TypeProf::Type - Inherited

Builtin, DummySubstitution

Class Method Summary

Instance Method Summary

Constructor Details

This class inherits a constructor from TypeProf::Type

Class Method Details

.create_empty_instance(klass)

[ GitHub ]

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

def self.create_empty_instance(klass)
  base_type = Type::Instance.new(klass)
  case klass
  when Type::Builtin[:ary] # XXX: check inheritance...
    Type::Array.new(Type::Array::Elements.new([], Type.bot), base_type)
  when Type::Builtin[:hash]
    Type.gen_hash(base_type) {|h| }
  else
    Type::Cell.new(Type::Cell::Elements.new([Type.bot] * klass.type_params.size), base_type)
  end
end

Instance Method Details

#consistent?(other) ⇒ Boolean

[ GitHub ]

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

def consistent?(other)
  raise "must not be used"
end

#each_free_type_variable(&blk)

[ GitHub ]

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

def each_free_type_variable(&blk)
  @elems.each_free_type_variable(&blk)
end

#include_untyped?(scratch) ⇒ Boolean

[ GitHub ]

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

def include_untyped?(scratch)
  return true if @base_type.include_untyped?(scratch)
  return true if @elems.include_untyped?(scratch)
  false
end

#match?(other) ⇒ Boolean

[ GitHub ]

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

def match?(other)
  return nil if self.class != other.class
  return nil unless @base_type.consistent?(other.base_type)
  @elems.match?(other.elems)
end