ACT Library
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Data Class Reference

A user-defined data types. More...

#include <types.h>

Inheritance diagram for Data:
UserDef Type

Public Member Functions

 Data (UserDef *u)
 
virtual ~Data ()
 
int isEqual (const Type *t) const
 equality test
 
void MkEnum (int is_int)
 
int isEnum () const
 
int isPureEnum () const
 
void addEnum (const char *s)
 
int numEnums () const
 
int enumVal (const char *s) const
 
void setMethod (int t, struct act_chp_lang *h)
 
struct act_chp_langgetMethod (int t)
 
void copyMethods (Data *d)
 
DataExpand (ActNamespace *ns, Scope *s, int nt, inst_param *u)
 
void Print (FILE *fp)
 
void getStructCount (int *nbools, int *nints)
 
int getStructOffset (ActId *field, int *sz)
 
ActId ** getStructFields (int **types)
 
- Public Member Functions inherited from UserDef
 UserDef (ActNamespace *ns)
 
 UserDef (UserDef *x)
 
virtual ~UserDef ()
 destructor, releases storage
 
const char * getFile ()
 
void setFile (const char *s)
 
int getLine ()
 
void setLine (int num)
 
int IsExported ()
 
void MkExported ()
 
int isExpanded () const
 
int AddMetaParam (InstType *t, const char *id)
 
int AddPort (InstType *t, const char *id)
 
int FindPort (const char *id)
 
const char * getPortName (int pos) const
 
InstTypegetPortType (int pos) const
 
void refinePortType (int pos, InstType *u)
 
const char * getName ()
 
char * getFullName ()
 
void printActName (FILE *fp)
 
int isEqual (const Type *t) const
 
void setName (const char *s)
 
void MkCopy (UserDef *u)
 
int isEqual (const UserDef *u) const
 
void SetParent (InstType *t)
 
InstTypegetParent () const
 
int isDefined ()
 
void MkDefined ()
 
int isPort (const char *name)
 
int getNumParams () const
 
int getRemainingParams () const
 
int getNumPorts () const
 
InstTypeLookup (ActId *id)
 
InstTypeLookup (const char *nm)
 
ScopeCurScope ()
 
int isStrictPort (const char *name)
 
virtual void Print (FILE *)
 
void PrintHeader (FILE *fp, const char *type)
 
void setBody (ActBody *x)
 
void AppendBody (ActBody *x)
 
ActBodygetBody ()
 
UserDefExpand (ActNamespace *, Scope *, int, inst_param *)
 
UserDefExpand (ActNamespace *ns, Scope *s, int nt, inst_param *u, int *cache_hit, int is_process=0)
 
ActNamespacegetns ()
 
InstTyperoot () const
 
act_prsgetprs ()
 
act_specgetspec ()
 
act_languagesgetlang ()
 
int isLeaf ()
 
void mkRefined ()
 
int hasRefinement ()
 
UserMacronewMacro (const char *name)
 
UserMacrogetMacro (const char *name)
 
- Public Member Functions inherited from Type
 Type ()
 
 ~Type ()
 constructor
 
virtual const char * getName ()=0
 destructor
 
virtual TypeExpand (ActNamespace *ns, Scope *s, int nt, inst_param *ip)=0
 
virtual int isEqual (const Type *t) const =0
 

Private Member Functions

void _get_struct_count (int *nbools, int *nints)
 
void _get_struct_fields (ActId **a, int *types, int *pos, ActId *prefix)
 

Private Attributes

unsigned int is_enum:1
 
unsigned int is_eint:1
 1 if this enum can be treated as an int
 
struct act_chp_langmethods [ACT_NUM_STD_METHODS]
 
list_t * enum_vals
 

Additional Inherited Members

- Public Types inherited from Type
enum  direction {
  NONE = 0 , IN = 1 , OUT = 2 , INOUT = 3 ,
  OUTIN = 4
}
 
- Static Public Member Functions inherited from Type
static void Init ()
 
static const char * dirstring (direction d)
 
- Protected Member Functions inherited from UserDef
int emitMacros (FILE *fp)
 
 A_DECL (UserMacro *, um)
 user-defined macros
 
- Protected Attributes inherited from UserDef
InstTypeparent
 implementation relationship, if any
 
unsigned int defined:1
 1 if this has been defined, 0 otherwise
 
unsigned int expanded:1
 1 if this has been expanded, 0 otherwise
 
unsigned int pending:1
 1 if this is currently being expanded, 0 otherwise
 
unsigned int exported:1
 1 if the type is exported, 0 otherwise
 
act_languageslang
 sub-languages within this type
 
int nt
 number of template parameters
 
InstType ** pt
 parameter types
 
const char ** pn
 parameter names
 
int nports
 number of ports
 
InstType ** port_t
 port types
 
const char ** port_n
 port names
 
ScopeI
 instances
 
const char * name
 Name of the user-defined type.
 
ActBodyb
 body of user-defined type
 
ActNamespace_ns
 namespace within which this type is defined
 
UserDefunexpanded
 unexpanded type, if any
 
int level
 default modeling level for the type
 
const char * file
 file name (if known) where this was defined
 
int lineno
 line number (if known) where this was defined
 
int has_refinement
 1 if there is a refinement body
 
int inherited_templ
 number of inherited template parameters
 
inst_param ** inherited_param
 the inherited parameters
 

Detailed Description

A user-defined data types.

This type is used to implement user-defined enumerations, structures, as well as implementations of int/bool/enum types.

Constructor & Destructor Documentation

◆ Data()

Data::Data ( UserDef u)

◆ ~Data()

virtual Data::~Data ( )
virtual

Member Function Documentation

◆ _get_struct_count()

void Data::_get_struct_count ( int *  nbools,
int *  nints 
)
private

◆ _get_struct_fields()

void Data::_get_struct_fields ( ActId **  a,
int *  types,
int *  pos,
ActId prefix 
)
private

◆ addEnum()

void Data::addEnum ( const char *  s)
inline

Add a new option to an enumeration data type

Parameters
sis the name of the new enumeration option

◆ copyMethods()

void Data::copyMethods ( Data d)

Copy over all the methods from the specified data type. This uses a shallow copy of the method body

Parameters
dis the Data type from which the method table should be copied

◆ enumVal()

int Data::enumVal ( const char *  s) const
inline

This is used to map enumeration constants to their value

Parameters
sis the name of the constant
Returns
the value of the enumeration constant specified, -1 if not found.

◆ Expand()

Data * Data::Expand ( ActNamespace ns,
Scope s,
int  nt,
inst_param u 
)
virtual

Expand the type

Reimplemented from UserDef.

◆ getMethod()

struct act_chp_lang * Data::getMethod ( int  t)
inline
Parameters
tis the method type from the datatype_methods enumeration
Returns
the method body for the specified method

◆ getStructCount()

void Data::getStructCount ( int *  nbools,
int *  nints 
)

Returns # of booleans and # of ints needed to implement the structure.

Parameters
nboolsused to return the # of bools in the structure
nintsused to return the # of int/enums in the structure

◆ getStructFields()

ActId ** Data::getStructFields ( int **  types)

Elaborate the structure into all the "leaf" field names, and also return the types for each field. The type is either 0 or 1, 0 for bools and 1 for ints.

Parameters
typesshould be an int array of size # of ints + # of bools for the structure (see getStructCount())
Returns
an ActId array of the same size that contains all the field names for the structure.

◆ getStructOffset()

int Data::getStructOffset ( ActId field,
int *  sz 
)

Returns offset of field within the structure. If sz is non-NULL, also returns the # of entries in case this is a sub-structure. The offset corresponds to the index into the structure where the field was found. For fields of the form foo.bar, it is the sum of the offsets for each field (so the offset for "foo", plus the offset of "bar" within "foo".

Parameters
fieldis the ActId that describes the field
szis used to return the size of the field (# of bools +

of ints)

Returns
the offset of the field, -1 if not found

◆ isEnum()

int Data::isEnum ( ) const
inline
Returns
1 if this is an enumeration type, 0 otherwise

◆ isEqual()

int Data::isEqual ( const Type t) const
virtual

equality test

Reimplemented from UserDef.

◆ isPureEnum()

int Data::isPureEnum ( ) const
inline
Returns
1 if this is an enumeration and one that cannot be used in an integer context (a "pure" enumeration)

◆ MkEnum()

void Data::MkEnum ( int  is_int)
inline

Convert this data type into an enumeration. Also indicate if this enumeration can be used as an integer data type or not.

Parameters
is_intis 1 to indicate the enumeration can be used in the contexts where an integer is needed

◆ numEnums()

int Data::numEnums ( ) const
inline
Returns
the number of enumeration options for this data type

◆ Print()

void Data::Print ( FILE *  fp)
virtual

Print the type

Reimplemented from UserDef.

◆ setMethod()

void Data::setMethod ( int  t,
struct act_chp_lang h 
)
inline

Set the specified method from the method table to the CHP.

Parameters
tis the method type from the datatype_methods enumeration
his the method body

Member Data Documentation

◆ enum_vals

list_t* Data::enum_vals
private

the list of enumeration values (char *) for enumeration types.

◆ is_eint

unsigned int Data::is_eint
private

1 if this enum can be treated as an int

◆ is_enum

unsigned int Data::is_enum
private

1 if this is an enumeration, 0 otherwise

◆ methods

struct act_chp_lang* Data::methods[ACT_NUM_STD_METHODS]
private

all the user-defined methods for this type


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