Type.hxx File Reference

#include <stdlib.h>
#include <dirent.h>
#include <fstream>
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <libsherpa/INOstream.hxx>
#include <libsherpa/EnumSet.hxx>
#include "AST.hxx"
#include "debug.hxx"
#include "TvPrinter.hxx"
#include "Environment.hxx"
#include "TypeInfer.hxx"
#include "Trail.hxx"
#include "types.def"

Go to the source code of this file.

Data Structures

struct  comp
struct  ArrLen
struct  Type

Defines

#define DEFTYPE(nm, prim, csimp, atom, scalar, ref, impint, impfloat)   ty_##nm,
#define DEFTYPE(nm, prim, csimp, atom, scalar, ref, impint, impfloat)   ty_##nm,

Typedefs

typedef long long TargetSWord
typedef sherpa::EnumSet< CompFlagValuesCompFlagSet
typedef sherpa::EnumSet< MarkFlagValuesMarkFlags
typedef sherpa::EnumSet< TypeFlagValuesTypeFlags
typedef sherpa::EnumSet< PrintOptionValuesPrintOptions
typedef std::less< boost::shared_ptr<
Type > > 
TypePtrLess
typedef std::set< boost::shared_ptr<
Type >, TypePtrLess
TypeSet

Enumerations

enum  TypeTag {
  nm, prim, csimp, atom,
  scalar, ref, impint, impfloat
}
enum  CompFlagValues {
  COMP_NO_FLAGS = 0u, COMP_UNIN_DISCM = 0x01u, COMP_INVALID = 0x02u, COMP_BYREF = 0x04u,
  COMP_MAYBE_BYREF = 0x08u
}
enum  MarkFlagValues {
  MARK_NONE = 0x0, MARK_PREDICATE = 0x0000001u, MARK_GET_BARE_TYPE = 0x0000002u, MARK_GET_THE_TYPE = 0x0000004u,
  MARK_SIZE = 0x0000008u, MARK_MANGLED_STRING = 0x0000010u, MARK_EMIT_ARR_VEC_FN_TYPES = 0x0000020u, MARK_CHECK_CONSTRAINTS = 0x0000040u,
  MARK_CHECK_MUT_CONSISTENCY = 0x0000080u, MARK_COLLECT_FTVS_WRT_GAMMA = 0x0000100u, MARK_COLLECT_ALL_FTVS = 0x0000200u, MARK_MAXIMIZE_MUTABILITY = 0x0000400u,
  MARK_MINIMIZE_MUTABILITY = 0x0000800u, MARK_MINIMIZE_DEEP_MUTABILITY = 0x0001000u, MARK_MIN_MUT_CONSTLESS = 0x0002000u, MARK_NORMALIZE_CONST = 0x0004000u,
  MARK_SIGN_MBS = 0x0008000u, MARK_ADJ_MAYBE = 0x0010000u, MARK_FIXUP_FN_TYPES = 0x0020000u, MARK_PROPAGATE_MUTABILITY = 0x0040000u,
  MARK_NORMALIZE_MBFULL = 0x0080000u, MARK_NORMALIZE_CONST_INPLACE = 0x0100000u, MARK_ENSURE_MINIMIZABILITY = 0x0200000u
}
 Mark values for types. More...
enum  TypeFlagValues {
  TY_NO_FLAGS = 0x0, TY_CT_SUBSUMED = 0x01u, TY_CT_SELF = 0x02u, TY_RIGID = 0x04u,
  TY_CCC = 0x10u, TY_CLOS = 0x20u, TY_COERCE = 0x40u, TY_ARG_IN_CONST = 0x80u
}
 Definition for Type flags. More...
enum  PrintOptionValues { PO_NO_FLAGS = 0x0, PO_NO_TRAVERSE = 0x01u, PO_SHOW_LINKS = 0x02u, PO_SHOW_FIELDS = 0x04u }

Functions

const char * TypeTagName (TypeTag tt)
static int operator< (const boost::shared_ptr< Type > &lhs, const boost::shared_ptr< Type > &rhs)
std::ostream & operator<< (std::ostream &strm, Type &t)

Variables

const TypeFlags TY_SP_MASK


Define Documentation

#define DEFTYPE ( nm,
prim,
csimp,
atom,
scalar,
ref,
impint,
impfloat   )     ty_##nm,

#define DEFTYPE ( nm,
prim,
csimp,
atom,
scalar,
ref,
impint,
impfloat   )     ty_##nm,


Typedef Documentation

typedef sherpa::EnumSet<CompFlagValues> CompFlagSet

Definition at line 118 of file Type.hxx.

typedef sherpa::EnumSet<MarkFlagValues> MarkFlags

Definition at line 217 of file Type.hxx.

typedef sherpa::EnumSet<PrintOptionValues> PrintOptions

Definition at line 281 of file Type.hxx.

typedef long long TargetSWord

Definition at line 69 of file Type.hxx.

typedef sherpa::EnumSet<TypeFlagValues> TypeFlags

Definition at line 256 of file Type.hxx.

typedef std::less<boost::shared_ptr<Type> > TypePtrLess

Definition at line 288 of file Type.hxx.

typedef std::set<boost::shared_ptr<Type>, TypePtrLess > TypeSet

Definition at line 292 of file Type.hxx.


Enumeration Type Documentation

enum CompFlagValues

Enumerator:
COMP_NO_FLAGS 
COMP_UNIN_DISCM  Union discriminator of defrepr.
COMP_INVALID  Field (component) in a defrepr leg is marked invalid within switch statement when used in conjuction with other constructors (only the common fields must be valid) The switched value is only valid within select operations, and is therefore only checked there.
COMP_BYREF  This flag is marked on the components of a function argVec at positions where by-ref arguments are expected.

The Flag is not marked on the Component types themselves because this will cause problems with flag propagation during unification (especially since the component type may be a type variable. We do not have a (by-ref 'a) type itself because that will result in types such as (mutable (byref 'a)) during inference, and we will need normalization. Therefore, by-ref is marked on ty_argvec components. Two argVecs can unify only if all of their components and flags match.

Valid on ty_argvec only.

COMP_MAYBE_BYREF  This flag is marked on the components of a function argVec at whenever we don't know the by-ref status of the argument. Whenever this flag is set, this parameter's by-ref status is open, and can later become by-ref due to unification. If this flag is clear, the absence of COMP-BYREF flag decisively states that the argument is passed by value only.

This flag is used during inference when we construct a function type at the time of application, but do not know the exact by-ref state of the parameters.

Valid on ty_argvec only.

Definition at line 74 of file Type.hxx.

enum MarkFlagValues

Mark values for types.

The following marks are present on types to ensure that procedures that recurse over the structure of equi-recursive types do not recurse infinitely. We need to use differernt markers for procedures that are mutually recursive, or are otherwise used simultaneously. Here, we actually use different markers for each procedure that is recursive over type-structure, except for some simple self-recursive predicates which share the mark MARK_PREDICATE.

Enumerator:
MARK_NONE 
MARK_PREDICATE 
MARK_GET_BARE_TYPE 
MARK_GET_THE_TYPE 
MARK_SIZE 
MARK_MANGLED_STRING 
MARK_EMIT_ARR_VEC_FN_TYPES 
MARK_CHECK_CONSTRAINTS 
MARK_CHECK_MUT_CONSISTENCY 
MARK_COLLECT_FTVS_WRT_GAMMA 
MARK_COLLECT_ALL_FTVS 
MARK_MAXIMIZE_MUTABILITY 
MARK_MINIMIZE_MUTABILITY 
MARK_MINIMIZE_DEEP_MUTABILITY 
MARK_MIN_MUT_CONSTLESS 
MARK_NORMALIZE_CONST 
MARK_SIGN_MBS 
MARK_ADJ_MAYBE 
MARK_FIXUP_FN_TYPES 
MARK_PROPAGATE_MUTABILITY 
MARK_NORMALIZE_MBFULL 
MARK_NORMALIZE_CONST_INPLACE 
MARK_ENSURE_MINIMIZABILITY 

Definition at line 182 of file Type.hxx.

enum PrintOptionValues

Enumerator:
PO_NO_FLAGS 
PO_NO_TRAVERSE  Suppress link field traversal.

The pretty printer normally traverses the unification link fields to find the resolved type. If this option is set, traversal is suppressed, which can be useful for debugging purposes.

PO_SHOW_LINKS  Display type linkages.

If this option is set, the traversal information will be displayed, which can be useful for debugging purposes.

PO_SHOW_FIELDS  Display internal field types.

For debugging purposes it is often useful to see aggregate types displayed in "exploded" form.

Definition at line 258 of file Type.hxx.

enum TypeFlagValues

Definition for Type flags.

Enumerator:
TY_NO_FLAGS 
TY_CT_SUBSUMED  Typeclass constraint is subsumed by another (ex: by a derived class).
TY_CT_SELF  Typeclass constraint is due to self definition.
TY_RIGID 
TY_CCC  Candidate for Copy-Compatibility.

This flag is for type variables that are in type argument position for structure or union types only. If set, it means that this type variable has not been captured within another reference type constructor, and the composite type is free to be copy-compatible at this position.

TY_CLOS  A temporary flag used in closure computation of FTVs in a TypeScheme.
TY_COERCE  Flag used by adjMaybe to coerce only certain maybe-types.

This flag must be marked on maybe-Var()s. This flag is NOT cleared by the adjMaybe function.

TY_ARG_IN_CONST  Flag used to fixup const types within composite data-structure definitons.

If an argument appears within a const type, it must be instantiated to a mb_Full type to ensure completeness of inference. This flag identifies all such type arguments to structure/union definitions that appear somewhere within a const type.

Definition at line 221 of file Type.hxx.

enum TypeTag

Enumerator:
nm 
prim 
csimp 
atom 
scalar 
ref 
impint 
impfloat 

Definition at line 62 of file Type.hxx.


Function Documentation

static int operator< ( const boost::shared_ptr< Type > &  lhs,
const boost::shared_ptr< Type > &  rhs 
) [static]

Definition at line 884 of file Type.hxx.

std::ostream& operator<< ( std::ostream &  strm,
Type t 
) [inline]

Definition at line 891 of file Type.hxx.

References Type::asString().

const char* TypeTagName ( TypeTag  tt  ) 

Definition at line 210 of file Type.cxx.

Referenced by Type::typeTagName().


Variable Documentation

const TypeFlags TY_SP_MASK

Initial value:

Definition at line 285 of file Type.hxx.


Generated on Sat Feb 4 23:59:29 2012 for BitC Compiler by  doxygen 1.4.7