ACT Library
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | Friends | List of all members
InstType Class Reference

An instance type. More...

#include <inst.h>

Public Member Functions

 InstType (Scope *_s, Type *_t, int is_temp=1)
 
 InstType (InstType *i, int skip_array=0)
 
 ~InstType ()
 
void MkArray (Array *a)
 
ArrayarrayInfo ()
 
void clrArray ()
 
int isEqual (InstType *t, int weak=0)
 
int isEqualDir (InstType *t, int weak=0)
 
TypeisConnectable (InstType *t, int weak=0)
 
void Print (FILE *fp, int nl_mode=0)
 
void sPrint (char *buf, int sz, int nl_mode=0)
 
TypeBaseType () const
 
void setNumParams (int n)
 
void appendParams (int na, inst_param *a)
 
void setParam (int pn, AExpr *a)
 
void setParam (int pn, Expr *e)
 
void setParam (int pn, InstType *t)
 
InstTypegetTypeParam (int pn)
 
AExprgetAExprParam (int pn)
 
int getNumParams ()
 
inst_paramallParams ()
 
void SetDir (Type::direction d)
 
Type::direction getDir ()
 
void MkCached ()
 
int isTemp ()
 
void * operator new (size_t count)
 
void operator delete (void *ptr)
 
InstTypeExpand (ActNamespace *ns, Scope *s)
 
int isExpanded () const
 
int israwExpanded () const
 
void mkExpanded ()
 
ActNamespacegetNamespace ()
 
UserDefgetUserDef ()
 
int isParamAType (int k)
 
TypeisRelated (InstType *it, InstType **common=NULL)
 
int hasinstGlobal ()
 
InstTyperefineBaseType (InstType *update)
 
InstTyperefineBaseType (Type *update)
 
void setPTypeID (char *s)
 
const char * getPTypeID ()
 
void setIfaceType (InstType *x)
 
InstTypegetIfaceType ()
 

Private Attributes

Typet
 
Type::direction dir
 
Scopes
 
Arraya
 
int nt
 
inst_paramu
 
unsigned int temp_type:1
 
unsigned int expanded:1
 
const char * ptype_id
 
InstTypeiface_type
 

Friends

class TypeFactory
 

Detailed Description

An instance type.

An instance type contains

An instance type can be unexpanded or expanded.

InstType pointers are recorded in various data strutures like the instance table in a Scope. They are also used temporarily for type-checking. InstType pointers held in other data structures are marked as "cached", and deleting those pointers does nothing. Hence it should always be safe to delete an InstType pointer even if its use is recorded elsewhere.

Constructor & Destructor Documentation

◆ InstType() [1/2]

InstType::InstType ( Scope _s,
Type _t,
int  is_temp = 1 
)

The standard constructor. create instance type with the specified type as the root/base of the instance. By default an InstType is marked "temporary" (i.e. uncached).

Parameters
_sis the scope in which the type is created
_tis the base type
is_tempis used to create permanent InstType pointers

◆ InstType() [2/2]

InstType::InstType ( InstType i,
int  skip_array = 0 
)

This creates a duplicate of the InstType passed in, making sure it is a temp type by default. You can optionally skip any array specifiers for the type

Parameters
iis the InstType to be copied
skip_arrayis set to 1 when you want the copy to omit any array specifier. If skip_array is set to 0 and the type has an array specifier, this is flagged as an error (assertion failure).

◆ ~InstType()

InstType::~InstType ( )

Free the type if it is an uncached (is_temp = 1) type. If the type is marked as cached, then this desctructor does nothing.

Member Function Documentation

◆ allParams()

inst_param * InstType::allParams ( )
inline
Returns
direct access to the template parameter array

◆ appendParams()

void InstType::appendParams ( int  na,
inst_param a 
)

Append parameters to the list of current template parameters.

Parameters
naare the additional parameters
ais an array of template parameters that are to be appended.

◆ arrayInfo()

Array * InstType::arrayInfo ( )
inline
Returns
the Array specifier for this InstType

◆ BaseType()

Type * InstType::BaseType ( ) const
inline

Return root/base type

◆ clrArray()

void InstType::clrArray ( )
inline

Remove the array specifier from the type by setting it to NULL

◆ Expand()

InstType * InstType::Expand ( ActNamespace ns,
Scope s 
)

Return a fresh instance type that is the expanded version of the type we had originally!

Parameters
nsis the namespace in which any types should be looked up
sis the expanded scope in which any parameters should be evaluated

◆ getAExprParam()

AExpr * InstType::getAExprParam ( int  pn)
Parameters
pnis the slot number
Returns
the array expression AExpr at that slot number, assertion failure if it is not an array expression.

◆ getDir()

Type::direction InstType::getDir ( )
inline
Returns
the direction flag for this type

◆ getIfaceType()

InstType * InstType::getIfaceType ( )
inline
Returns
the interface type

◆ getNamespace()

ActNamespace * InstType::getNamespace ( )
inline
Returns
the namespace where this instance was created.

◆ getNumParams()

int InstType::getNumParams ( )
inline
Returns
the number of template parameters

◆ getPTypeID()

const char * InstType::getPTypeID ( )
inline
Returns
PType ID

◆ getTypeParam()

InstType * InstType::getTypeParam ( int  pn)
Parameters
pnis the slot number
Returns
the InstType at that slot number, assertion failure if it is not a type

◆ getUserDef()

UserDef * InstType::getUserDef ( )
inline
Returns
the user-defined type where this instance was created, if any

◆ hasinstGlobal()

int InstType::hasinstGlobal ( )
inline

XXX: Return 1 if any template parameter in inst_param involves global symbols. This may no longer be needed?

◆ isConnectable()

Type * InstType::isConnectable ( InstType t,
int  weak = 0 
)

check if two types are compatible for connections. Returns NULL if error, otherwise returns the most specific type. The weak flag has the same meaning as isEqual().

◆ isEqual()

int InstType::isEqual ( InstType t,
int  weak = 0 
)

Check if two instance types are identical. Note that this DOES NOT CHECK DIRECTION FLAGS! There are different degrees of equality checking that are controlled by the parameter weak.

The weak parameter only matters for array types. All cases check that the # of dimensions match. The remaining check for equality of array types is:

Weak Meaning
0 check that the arrays are in fact equal and have the same index ranges (and range expressions). Used for checking that port parameters are the same in the definition and declaration.
1 checks that arrays are compatible in terms of # of dimensions, rather than equal. Used to sanity check connections prior to expanding parameters.
2 check that array ranges have the same size; they could have different index ranges. Used to check that two types can be connected.
3 check that array ranges have the same size, except for the first dimension. Used to check that two types can be concatenated in an array expression.
Parameters
tis the InstType to compare with
weakis the weak parameter (default is zero)
Returns
1 if equal, 0 otherwise.

◆ isEqualDir()

int InstType::isEqualDir ( InstType t,
int  weak = 0 
)

The same as isEqual(), except it also checks that the direction flags for the type match.

◆ isExpanded()

int InstType::isExpanded ( ) const
Returns
1 if this is an expanded type or if this is a simple parameter type, 0 otherwise

◆ isParamAType()

int InstType::isParamAType ( int  k)
Returns
1 if the kth template parameter is a type

◆ israwExpanded()

int InstType::israwExpanded ( ) const
inline
Returns
1 if this is an expanded type, 0 otherwise

◆ isRelated()

Type * InstType::isRelated ( InstType it,
InstType **  common = NULL 
)

Check if two types are related in the implementation relation hierarchy. Array references are ignored.

Parameters
itis the type to compare against
commonis used to return the type where the relationship was found
Returns
the base type of either the current InstType or it, depending on which was the more specific type

◆ isTemp()

int InstType::isTemp ( )
inline
Returns
1 if this is a temporary (uncached) type

◆ MkArray()

void InstType::MkArray ( Array a)

Make this an arrayed type, where the array size is specified by the argument

Parameters
ais the Array specifier that corresponds to the array dimensions to be added to this InstType

◆ MkCached()

void InstType::MkCached ( )
inline

Mark this InstType as cached

◆ mkExpanded()

void InstType::mkExpanded ( )
inline

Mark this type as expanded

◆ operator delete()

void InstType::operator delete ( void *  ptr)
inline

◆ operator new()

void * InstType::operator new ( size_t  count)
inline

◆ Print()

void InstType::Print ( FILE *  fp,
int  nl_mode = 0 
)

print inst type string

◆ refineBaseType() [1/2]

InstType * InstType::refineBaseType ( InstType update)

Used to change the type signature during overrides.

Parameters
updateis the updated type.
Returns
an in-place updated (for temp types) or a fresh InstType where the base type and template parameters are updated from the specified updated type

◆ refineBaseType() [2/2]

InstType * InstType::refineBaseType ( Type update)

Used to change the type signature during overrides.

Parameters
updateis the updated type.
Returns
an in-place updated (for temp types) or a fresh InstType where the base type and template parameters are updated from the specified updated type.

◆ SetDir()

void InstType::SetDir ( Type::direction  d)
inline

Set direction flags

Parameters
dis the direction flag to be used.

◆ setIfaceType()

void InstType::setIfaceType ( InstType x)
inline

Set the interface type

Parameters
xis the interface type

◆ setNumParams()

void InstType::setNumParams ( int  n)

Used to create slots for template parameters

Parameters
nis the number of template parameter slots to be created.

◆ setParam() [1/3]

void InstType::setParam ( int  pn,
AExpr a 
)

Sets the template parameter at the specified slot number to be an array expression

Parameters
pnis the slot number
ais the array expression. This does not copy it, but keeps a reference to the parameter. Do not free!

◆ setParam() [2/3]

void InstType::setParam ( int  pn,
Expr e 
)

Sets the template parameter at the specified slot number to be a simple expression

Parameters
pnis the slot number
eis the expression. This does not copy it, but keeps a reference to the parameter. Do not free!

◆ setParam() [3/3]

void InstType::setParam ( int  pn,
InstType t 
)

Sets the template parameter at the specified slot number to be an InstType. This is used for channels and ptype parameters.

Parameters
pnis the slot number
tis the type. This does not copy it, but keeps a reference to the parameter. Do not free!

◆ setPTypeID()

void InstType::setPTypeID ( char *  s)
inline

set PType ID. When an instance is created using a "ptype" type, we need a dummy place-holder name for the type itself. When this is expanded out, the type is replaced with the actual value of this parameter. Additionally, the Type pointer is actually set to the interface so that one can determine that this is a ptype. XXX: this can be cleaned up.

Parameters
sis the name of the ID that is the ptype

◆ sPrint()

void InstType::sPrint ( char *  buf,
int  sz,
int  nl_mode = 0 
)

snprintf

Friends And Related Function Documentation

◆ TypeFactory

friend class TypeFactory
friend

Member Data Documentation

◆ a

Array* InstType::a
private

array specification, if any

◆ dir

Type::direction InstType::dir
private

Direction flags for types. ? = in, ! = out. ?! and !? used to specify modifiers in port parameters for channels and data

◆ expanded

unsigned int InstType::expanded
private

set if this is expanded

◆ iface_type

InstType* InstType::iface_type
private

if you're expanded, this is your interface (for ptypes)

◆ nt

int InstType::nt
private

template parameters, if any

◆ ptype_id

const char* InstType::ptype_id
private

for inst-types, this is the name of the ptype

◆ s

Scope* InstType::s
private

Scope in which the expanded instance was created

◆ t

Type* InstType::t
private

root/base type

◆ temp_type

unsigned int InstType::temp_type
private

set if this is an uncached inst type

◆ u

inst_param* InstType::u
private

array of parameters, if any


The documentation for this class was generated from the following file: