ACT Library
|
This is the class used to create all instance types. It also caches types to reduce memory usage. More...
#include <types.h>
Public Member Functions | |
TypeFactory () | |
~TypeFactory () | |
void * | operator new (size_t) |
void | operator delete (void *) |
InstType * | NewPInt () |
InstType * | NewPInts () |
InstType * | NewPBool () |
InstType * | NewPReal () |
InstType * | NewPType (Scope *s, InstType *t) |
PType * | NewPType (InstType *t) |
InstType * | NewBool (Type::direction dir) |
InstType * | NewInt (Scope *s, Type::direction dir, int sig, Expr *w) |
Int * | NewInt (int sig, int w) |
InstType * | NewEnum (Scope *s, Type::direction dir, Expr *w) |
InstType * | NewChan (Scope *s, Type::direction dir, InstType *l, InstType *ack) |
Chan * | NewChan (InstType *l, InstType *ack) |
InstType * | NewUserDef (Scope *s, InstType *it) |
Static Public Member Functions | |
static Expr * | NewExpr (Expr *e) |
static TypeFactory * | Factory () |
static void | Init () |
static int | isDataType (const Type *t) |
static int | isDataType (const InstType *t) |
static int | isIntType (const Type *t) |
static int | isIntType (const InstType *t) |
static int | isPIntType (const Type *t) |
static int | isPIntType (const InstType *t) |
static int | isPIntsType (const Type *t) |
static int | isPIntsType (const InstType *t) |
static int | isBoolType (const Type *t) |
static int | isBoolType (const InstType *it) |
static int | isPBoolType (const Type *t) |
static int | isPBoolType (const InstType *it) |
static int | isPRealType (const Type *t) |
static int | isPRealType (const InstType *it) |
static int | isUserType (const Type *t) |
static int | isUserType (const InstType *it) |
static int | isChanType (const Type *t) |
static int | isChanType (const InstType *it) |
static int | isExactChanType (const Type *t) |
static int | isExactChanType (const InstType *it) |
static int | isValidChannelDataType (const Type *t) |
static int | isValidChannelDataType (const InstType *t) |
static int | isProcessType (const Type *t) |
static int | isProcessType (const InstType *it) |
static int | isFuncType (const Type *t) |
static int | isFuncType (const InstType *it) |
static int | isInterfaceType (const Type *t) |
static int | isInterfaceType (const InstType *it) |
static int | isPTypeType (const Type *t) |
static int | isPTypeType (const InstType *it) |
static int | isParamType (const Type *t) |
static int | isParamType (const InstType *it) |
static int | bitWidth (const Type *t) |
static int | bitWidth (const InstType *t) |
static int | bitWidthTwo (const Type *t) |
static int | bitWidthTwo (const InstType *t) |
static int | boolType (const Type *t) |
static int | boolType (const InstType *t) |
static int | isStructure (const Type *t) |
static int | isStructure (const InstType *it) |
static int | isUserEnum (const Type *t) |
static int | isUserEnum (const InstType *it) |
static int | isUserPureEnum (const Type *t) |
static int | isUserPureEnum (const InstType *it) |
static int | enumNum (const Type *t) |
static int | enumNum (const InstType *t) |
static int | isEnum (const Type *t) |
static int | isEnum (const InstType *t) |
static int | isBaseBoolType (const Type *t) |
static int | isBaseBoolType (const InstType *t) |
static int | isBaseIntType (const Type *t) |
static int | isBaseIntType (const InstType *t) |
static InstType * | getChanDataType (const InstType *t) |
static InstType * | getChanAckType (const InstType *t) |
Static Private Member Functions | |
static int | inthashfn (int, void *) |
static int | intmatchfn (void *, void *) |
static void * | intdupfn (void *) |
static void | intfreefn (void *) |
static int | chanhashfn (int, void *) |
static int | chanmatchfn (void *, void *) |
static void * | chandupfn (void *) |
static void | chanfreefn (void *) |
Static Private Attributes | |
static TypeFactory * | tf |
static InstType * | pint |
static InstType * | pints |
static InstType * | preal |
static InstType * | pbool |
static InstType * | bools [5] |
static Expr * | expr_true |
static Expr * | expr_false |
static struct iHashtable * | expr_int |
static struct cHashtable * | inthash |
static struct cHashtable * | enumhash |
static struct cHashtable * | ptypehash |
static struct cHashtable * | chanhash |
This is the class used to create all instance types. It also caches types to reduce memory usage.
All types should be created using the static TypeFactory methods. In addition, the TypeFactory provides methods that can be used to inspect attributes of types (e.g. is this a user-defined type?)
TypeFactory::TypeFactory | ( | ) |
TypeFactory::~TypeFactory | ( | ) |
|
static |
see other bitWidth() method
|
static |
Determines the bit-width of the type. The type must be either a channel or a data type. If it isn't, the function returns -1. If the type is an enumeration, the bitwidth is the smallest # of bits needed to hold the enumeration count.
|
static |
see other bitWidthTwo() method
|
static |
For bidirectional channels only. Returns 0 for normal channels, -1 for non-channels. This returns the bit-width (like the bitWidth() method) for the acknowledge type for the channel.
|
static |
see other boolType() method
|
static |
1 if a boolean within a channel or a boolean type, -1 if NULL parent
|
staticprivate |
|
staticprivate |
|
staticprivate |
Helper functions for hash table operations
|
staticprivate |
|
static |
|
static |
Used to determine the # of values in the enumeration. Return enumeartion width, -1 if not a nenumeration. Works for channels too, except it refers to the type within the channel.
|
inlinestatic |
|
static |
Initialize and allocate the first type factory object.
|
staticprivate |
|
staticprivate |
|
staticprivate |
Helper functions for hash table operations. ALSO used for enumeration hashes.
|
staticprivate |
|
static |
see other isBaseBoolType() method
|
static |
This is used to check if a user type that is rooted in a bool or a bool itself
|
static |
see other isBaseIntType() method
|
static |
This is used to check if a user type that is rooted in an int/int-enum or an int/int-enum itself. An "int-enum" is an enum that can also be treated as an int.
|
static |
see other isBoolType() method
|
static |
Determines if the specified type is a built-in bool type.
t | is the type to be inspected |
|
static |
see other isChanType() method
|
static |
Determines if the specified type is a channel type or not. This returns 1 if it is a user-defined channel or a built-in channel type.
t | is the type to be inspected |
|
static |
see the other isDataType() method
|
static |
Determines if the specified type is a data type or not. Note: if the type is a structure, then isDataType will return 0.
t | is the type to be inspected |
|
static |
Test if a type is an enumeration (user-defined or built-in)
|
static |
see other isExactChanType() method
|
static |
Determines if the specified type is a built-in chan(...) type.
t | is the type to be inspected |
|
static |
see other isFuncType() method
|
static |
Determines if the specified type is a function type or not
t | is the type to be inspected |
|
static |
see other isInterfaceType() method
|
static |
Determines if the specified type is an interface type or not
t | is the type to be inspected |
|
static |
see the other isIntType() method
|
static |
Determines if the specified type is a built-in int<> type.
t | is the type to be inspected |
|
static |
see other isParamType() method
|
static |
Determines if the specified type is a parameter type (pint, pints (UNUSED), pbool, preal, ptype).
t | is the type to be inspected |
|
static |
see other isPBoolType() method
|
static |
Determines if the specified type is a built-in pbool type.
t | is the type to be inspected |
|
static |
see other isPIntsType() method
|
static |
Determines if the specified type is a built-in pints type.
t | is the type to be inspected |
|
static |
see other isPIntType() method
|
static |
Determines if the specified type is a built-in pint type.
t | is the type to be inspected |
|
static |
see other isPRealType() method
|
static |
Determines if the specified type is a built-in preal type.
t | is the type to be inspected |
|
static |
see other isProcessType() method
|
static |
Determines if the specified type is a process type or not
t | is the type to be inspected |
|
static |
see other isPTypeType() method
|
static |
Determines if the specified type is a ptype or not
t | is the type to be inspected |
|
static |
see other isStructure() method
|
static |
|
static |
see other isUserEnum() method
|
static |
Is this a user-defined enumeration?
|
static |
see other isUserPureEnum() method
|
static |
Is this a user-defined pure enumeration (one that cannot be used as an integer)
|
static |
see other isUserType() method
|
static |
Determines if the specified type is a user-defined type
t | is the type to be inspected |
|
static |
see other isValidChannelDataType() method
|
static |
Determines if the specified type is a valid type to be included within the data type for a built-in chan(..).
Assumes that "t" is in fact a data type as a pre-condition.
t | is the type to be inspected |
InstType * TypeFactory::NewBool | ( | Type::direction | dir | ) |
Return unique pointer to the bool type
dir | is the direction flag for the type |
InstType * TypeFactory::NewChan | ( | Scope * | s, |
Type::direction | dir, | ||
InstType * | l, | ||
InstType * | ack | ||
) |
Return unique pointer to the chan type
dir | is the direction flag for the type |
s | is the scope in which the channel is created |
l | is the data type for the channel |
ack | is the "ack" type for the channel (bi-directional channels) |
InstType * TypeFactory::NewEnum | ( | Scope * | s, |
Type::direction | dir, | ||
Expr * | w | ||
) |
Return unique pointer to the enum type
dir | is the direction flag for the type |
w | is an integer expression that specifies the width of the integer (if it is a constant expression, the type can be finalized) |
s | is the scope in which this integer is created. This scope is used to evaluate any variables specified in w |
Returns a unique pointer to a constant expression. This expression pointer is cached so this should never be free'ed.
Int * TypeFactory::NewInt | ( | int | sig, |
int | w | ||
) |
InstType * TypeFactory::NewInt | ( | Scope * | s, |
Type::direction | dir, | ||
int | sig, | ||
Expr * | w | ||
) |
Return unique pointer to the int type
dir | is the direction flag for the type |
w | is an integer expression that specifies the width of the integer (if it is a constant expression, the type can be finalized) |
s | is the scope in which this integer is created. This scope is used to evaluate any variables specified in w |
sig | is 1 if this is a signed integer, 0 otherwise |
|
inline |
|
inline |
|
inline |
|
inline |
Returns a unique pointer to the instance type specified
it | is the input instance type. This MAY BE FREE'D |
s | is the scope in which the user-defined type is being created |
void TypeFactory::operator delete | ( | void * | ) |
void * TypeFactory::operator new | ( | size_t | ) |
|
staticprivate |
Five types of bool types: NONE, IN, OUT, INOUT, OUTIN.
|
staticprivate |
Hash table for channel types parameterized by direction, and type list
|
staticprivate |
Hash table for enumeration types parameterized by the range of the enumeration and direction flags.
|
staticprivate |
Constant expr E_FALSE. This is used to cache expressions.
|
staticprivate |
Constant expr E_INT. This is used to cache constant integer expressions. The hash table maps integers to the Expr *.
|
staticprivate |
Constant expr E_TRUE. This is used to cache expressions.
|
staticprivate |
Hash table for integer types parameterized by bit-width and direction flags.
|
staticprivate |
Built-in parameter type for a pbool: only one copy of this type can exist, since there are no parameters.
|
staticprivate |
Built-in parameter type for a pint: only one copy of this type can exist, since there are no parameters.
|
staticprivate |
Built-in parameter type for a pints: only one copy of this type can exist, since there are no parameters. NOTE: THIS IS UNUSED
|
staticprivate |
Built-in parameter type for a preal: only one copy of this type can exist, since there are no parameters.
|
staticprivate |
Hash table for ptype types. Uses channel hash functions.
|
staticprivate |
there can only be one TypeFactory in the system, and this is it.