The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Devel::TypeCheck::Type - base type for the type language representation of Devel::TypeCheck

SYNOPSIS

Devel::TypeCheck::Type is an abstract class and should not be instantiated directly. However, all types used in the type system are inheritors of this class and rely on methods defined here.

DESCRIPTION

The data structure is essentially a linked list from Mu at the head of the list to terminal or variable types at the end. Thus, most of the functions defined here support that by relaying the request to the subtype member (the next link in the linked list) instead of actually doing anything themselves.

VAR, M, H, K, P, N, O, X, Y, Z, IO, PV, IV, DV

Class methods implemented through AUTOLOAD to return a unique number for each different function. This is used to represent type for certain queries.

new($subtype)

Create a new Type instance with the given item as the next link in the list data structure. This will control the subtypes allowed, so that illegal types cannot be created when using this constructor. This method is abstract for this class, but works with subtypes. Types are never constructed by the user -- they should always be generated with the fresh* and gen* methods of the type environment, Devel::TypeCheck::Environment.

type

Return the numerical type of the instance.

subtype

Returns the next link in the list.

hasSubtype($type)

Returns true if the given instance has the given type.

str($env)

Return a string constructed from this type and subtypes. This is the "ugly" string as output by the B::TypeCheck backend module.

pretty

The human readable description of this type.

is($type)

Indicate whether some instance in the list of types is the same as the numerical type passed to this method.

getParent

Return the parent type of the instance. This always returns undef for internal and most terminal types, but returns the variable's parent in the union-find data structure (if it has one).

complete

True if the type is completely specified and has no unbound type variables.

deref

Dereference this type.

homogeneous

Whether the underlying array or hash is homogeneous.

arity

The size of the tuple, if the type at the end of the linked list is a tuple type for an array. This fails otherwise.

append

Append a given type to an array type. Promotes to homogeneous list as necessary.

ary

Get the underlying tuple from a tuple type.

derefIndex($index, $env)

Dereference the type from the array or hash at the given index.

derefHomogeneous

Dereference the homogeneous type for lists and associative arrays.

referize

Generate a list of references from the underlying array. Exists solely to support the srefgen operator on items of array type.

derefKappa

Get the scalar type out of a glob type. This is roughly equivalent to <*foo{SCALAR}>.

derefOmicron

Get the array type out of a glob type. This is roughly equivalent to <*foo{ARRAY}>.

derefChi

Get the hash type out of a glob type. This is roughly equivalent to <*foo{HASH}>.

derefZeta

Get the CV type out of a glob type. This is roughly equivalent to <*foo{CODE}>.

listCoerce

Coerce a hash in to an array.

derefParam

Dereference the parameter list type from a CV.

derefReturn

Dereference the return value type from a CV.

AUTHOR

Gary Jackson, <bargle at umiacs.umd.edu>

BUGS

This version is specific to Perl 5.8.1. It may work with other versions that have the same opcode list and structure, but this is entirely untested. It definitely will not work if those parameters change.

Please report any bugs or feature requests to bug-devel-typecheck at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Devel-TypeCheck. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT & LICENSE

Copyright 2005 Gary Jackson, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.