UserDef stores information that is common to all user-defined types. User-defined types are more complex, because they can have definitions and template parameters. To handle this complexity and to reduce storage requirements, the "shared" part of a user-defined type is factored out into this class. That way the body of a channel x1of2 is shared with x1of2? and x1of2!, as well as an array of x1of2 (for example).
More...
#include <types.h>
|
| 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 |
|
InstType * | getPortType (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) |
|
InstType * | getParent () const |
|
int | isDefined () |
|
void | MkDefined () |
|
int | isPort (const char *name) |
|
int | getNumParams () const |
|
int | getRemainingParams () const |
|
int | getNumPorts () const |
|
InstType * | Lookup (ActId *id) |
|
InstType * | Lookup (const char *nm) |
|
Scope * | CurScope () |
|
int | isStrictPort (const char *name) |
|
virtual void | Print (FILE *) |
|
void | PrintHeader (FILE *fp, const char *type) |
|
void | setBody (ActBody *x) |
|
void | AppendBody (ActBody *x) |
|
ActBody * | getBody () |
|
UserDef * | Expand (ActNamespace *, Scope *, int, inst_param *) |
|
UserDef * | Expand (ActNamespace *ns, Scope *s, int nt, inst_param *u, int *cache_hit, int is_process=0) |
|
ActNamespace * | getns () |
|
InstType * | root () const |
|
act_prs * | getprs () |
|
act_spec * | getspec () |
|
act_languages * | getlang () |
|
int | isLeaf () |
|
void | mkRefined () |
|
int | hasRefinement () |
|
UserMacro * | newMacro (const char *name) |
|
UserMacro * | getMacro (const char *name) |
|
| Type () |
|
| ~Type () |
| constructor
|
|
virtual const char * | getName ()=0 |
| destructor
|
|
virtual Type * | Expand (ActNamespace *ns, Scope *s, int nt, inst_param *ip)=0 |
|
virtual int | isEqual (const Type *t) const =0 |
|
|
InstType * | parent |
| 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_languages * | lang |
| 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
|
|
Scope * | I |
| instances
|
|
const char * | name |
| Name of the user-defined type.
|
|
ActBody * | b |
| body of user-defined type
|
|
ActNamespace * | _ns |
| namespace within which this type is defined
|
|
UserDef * | unexpanded |
| 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
|
|
UserDef stores information that is common to all user-defined types. User-defined types are more complex, because they can have definitions and template parameters. To handle this complexity and to reduce storage requirements, the "shared" part of a user-defined type is factored out into this class. That way the body of a channel x1of2 is shared with x1of2? and x1of2!, as well as an array of x1of2 (for example).
UserDef types can be either a Process, Data, Channel, Function, or Interface.
Parameters to the type are
- ports, which correspond to signals/hardware
- template parameters, which correspond to circuit construction parameters
◆ UserDef() [1/2]
- Parameters
-
ns | is the namespace in which the type is defined |
◆ UserDef() [2/2]
This moves all the information from the specified user-defined type over into this one.
- Parameters
-
x | is a previously created UserDef type |
◆ ~UserDef()
virtual UserDef::~UserDef |
( |
| ) |
|
|
virtual |
destructor, releases storage
◆ A_DECL()
◆ AddMetaParam()
int UserDef::AddMetaParam |
( |
InstType * |
t, |
|
|
const char * |
id |
|
) |
| |
Add a new template ("meta") parameter
- Parameters
-
t | is the type of the parameter |
id | is the the identifier for this parameter |
- Returns
- 1 on success, 0 on error (duplicate parameter name)
◆ AddPort()
int UserDef::AddPort |
( |
InstType * |
t, |
|
|
const char * |
id |
|
) |
| |
Add a new port
- Parameters
-
t | is the type of the port |
id | is the the identifier for this parameter |
- Returns
- 1 on success, 0 on error (duplicate parameter name)
◆ AppendBody()
void UserDef::AppendBody |
( |
ActBody * |
x | ) |
|
Append to the current body of the user-defined type
- Parameters
-
x | is the additional body to append |
◆ CurScope()
Scope * UserDef::CurScope |
( |
| ) |
|
|
inline |
- Returns
- the scope pointer for the user-defined type
◆ emitMacros()
int UserDef::emitMacros |
( |
FILE * |
fp | ) |
|
|
protected |
Used to print macros in the type
- Parameters
-
- Returns
- 1 if there are some macros, 0 otherwise
◆ Expand() [1/2]
◆ Expand() [2/2]
Expand the user-defined type
- Parameters
-
ns | is the namespace |
s | is the scope |
nt | is the number of specified template parameters |
u | holds the template parameters |
cache_hit | returns 1 on a hit (i.e. found a previously expanded identical type that is being returned), 0 otherwise |
is_process | is 0 by default, 1 for processes, 2 for functions |
- Returns
- expanded type either from the construction, or from the cache
◆ FindPort()
int UserDef::FindPort |
( |
const char * |
id | ) |
|
Find a port. Returns the port number encoded in the following way:
- if the parameter is a port at position k in the port list, the value returned is (k+1)
- if the parameter is a port at position k in the meta-parameter/template parameter list, the value returned is -(k+1)
- if the name is not in the port list, 0 is returned
- Parameters
-
id | is the name of the port |
- Returns
- 0 if not found. Positive values mean ports; negative values mean template parameters
◆ getBody()
- Returns
- the current body of the user-defined type
◆ getFile()
const char * UserDef::getFile |
( |
| ) |
|
|
inline |
Get file name where this was defined
- Returns
- the file name
◆ getFullName()
char * UserDef::getFullName |
( |
| ) |
|
- Returns
- a freshly allocated string with full name (including namespace) for the type.
◆ getlang()
- Returns
- all the sub-language bodies, NULL if there are none
◆ getLine()
- Returns
- the line number where this was defined
◆ getMacro()
UserMacro * UserDef::getMacro |
( |
const char * |
name | ) |
|
Return a user-defined macro
- Parameters
-
name | is the name of the macro |
- Returns
- the user-defined macro (NULL if it doesn't exist)
◆ getName()
const char * UserDef::getName |
( |
| ) |
|
|
virtual |
- Returns
- the name of the type. For expanded types, this uses the expanded type naming convention.
Implements Type.
◆ getns()
- Returns
- the namespace in which the user-defined type was defined
◆ getNumParams()
int UserDef::getNumParams |
( |
| ) |
const |
|
inline |
- Returns
- the number of template parameters
◆ getNumPorts()
int UserDef::getNumPorts |
( |
| ) |
const |
|
inline |
- Returns
- the number of ports
◆ getParent()
- Returns
- the parent type in the implementation hierarchy, if any
◆ getPortName()
const char * UserDef::getPortName |
( |
int |
pos | ) |
const |
Returns name of port at specified position. 0..k are the port list, -1 to -(l+1) are the template parameters.
- Parameters
-
pos | is the position of the port in the port list. Negative numbers indicate meta-parameters, 0 and positive parameters indicate physical port parameters. |
- Returns
- the name of the specified port
◆ getPortType()
InstType * UserDef::getPortType |
( |
int |
pos | ) |
const |
Returns the type of the port at specified position. 0..k are the port list, -1 to -(l+1) are the template parameters.
- Parameters
-
pos | is the position of the port in the port list. Negative numbers indicate meta-parameters, 0 and positive parameters indicate physical port parameters. |
- Returns
- the name of the specified port
◆ getprs()
- Returns
- the prs body (NULL if it does not exist)
◆ getRemainingParams()
int UserDef::getRemainingParams |
( |
| ) |
const |
|
inline |
Template parameters may be explicitly declared, or inherited by un-specified template parameters in parent types. The "remaining" template parameters are the fresh ones for this user-defined type.
- Returns
- the number of remaining template parameters
◆ getspec()
- Returns
- the spec body (NULL if it does not exist)
◆ hasRefinement()
int UserDef::hasRefinement |
( |
| ) |
|
|
inline |
- Returns
- 1 if this has a refinement body, 0 otherwise
◆ isDefined()
int UserDef::isDefined |
( |
| ) |
|
|
inline |
Specify if this type has been fully defined yet or not. It may only be a declared type at this point.
- Returns
- 1 if the type has been defined, 0 if it has only been declared.
◆ isEqual() [1/2]
int UserDef::isEqual |
( |
const Type * |
t | ) |
const |
|
virtual |
Check if two types are equal to each other.
- Parameters
-
t | is the type to compare against |
- Returns
- the result of comparing two types
Implements Type.
Reimplemented in Data.
◆ isEqual() [2/2]
int UserDef::isEqual |
( |
const UserDef * |
u | ) |
const |
Compare user-defined types to see if the port parameters match
- Parameters
-
u | is the user-defined type to compare with |
- Returns
- 1 if the types are equal, 0 otherwise
◆ isExpanded()
int UserDef::isExpanded |
( |
| ) |
const |
|
inline |
- Returns
- 1 if the type is expanded, or 0 if it is not
◆ IsExported()
int UserDef::IsExported |
( |
| ) |
|
|
inline |
Specifies if this is an exported user-defined type or not
- Returns
- 1 if this is an exported type, 0 otherwise
◆ isLeaf()
Only useful for process types.
- Returns
- 1 if there are no sub-circuits within this type, 0 otherwise
◆ isPort()
int UserDef::isPort |
( |
const char * |
name | ) |
|
Is this parameter a port?
- Parameters
-
name | is the name of the instance to be checked. |
- Returns
- 1 if name is a port, 0 otherwise
◆ isStrictPort()
int UserDef::isStrictPort |
( |
const char * |
name | ) |
|
THIS IS NOT USED NOW. Always returns 1.
- Parameters
-
name | is the name of the port to be checked |
- Returns
- 1 if this is a port name that is also in the "strict" parameter list
◆ Lookup() [1/2]
Looks up an identifier within the scope of the body of the type
- Parameters
-
id | is the ActId to look up |
- Returns
- the type for the identifier in the local scope, or NULL if it does not exist. Essentially a direct way to call Lookup() for the scope.
◆ Lookup() [2/2]
InstType * UserDef::Lookup |
( |
const char * |
nm | ) |
|
|
inline |
Looks up an identifier within the scope of the body of the type
- Parameters
-
- Returns
- the type for the identifier in the local scope, or NULL if it does not exist. Essentially a direct way to call Lookup() for the scope.
◆ MkCopy()
void UserDef::MkCopy |
( |
UserDef * |
u | ) |
|
Make a copy: copy over all fields from u, and clear the fields of u at the same time.
- Parameters
-
u | is the user-defined type to "take over" |
◆ MkDefined()
void UserDef::MkDefined |
( |
| ) |
|
|
inline |
Mark this type as defined
◆ MkExported()
void UserDef::MkExported |
( |
| ) |
|
|
inline |
Set this to be an exported type
◆ mkRefined()
void UserDef::mkRefined |
( |
| ) |
|
|
inline |
Mark this as a type that has a refinement body
◆ newMacro()
UserMacro * UserDef::newMacro |
( |
const char * |
name | ) |
|
Create a new user-defined macro
- Parameters
-
name | is the name of the macro |
- Returns
- the blank macro
◆ Print()
virtual void UserDef::Print |
( |
FILE * |
| ) |
|
|
inlinevirtual |
◆ printActName()
void UserDef::printActName |
( |
FILE * |
fp | ) |
|
Print the ACT name for the type. WARNING: this does not do the right thing for array template parameters.
- Parameters
-
◆ PrintHeader()
void UserDef::PrintHeader |
( |
FILE * |
fp, |
|
|
const char * |
type |
|
) |
| |
Print out the header for the type. This function can be used for all the different ways a UserDef can be used. The type field is used to print out one of the following strings: "defproc", "deftype", "defchan", "interface", "function".
- Parameters
-
fp | is the output file |
type | is the string for the kind of user-defined type. |
◆ refinePortType()
void UserDef::refinePortType |
( |
int |
pos, |
|
|
InstType * |
u |
|
) |
| |
Used for overrides. Refine the type for the port parameter at the specified position.
- Parameters
-
pos | is 0..k for the port list (temlpate parameters are never refined) |
u | is the updated instance type |
◆ root()
This should only be called for user-defined data types or channels.
- Returns
- the root type for this one in the implementation hierarchy. NULL if there is no root non user-defined type.
◆ setBody()
void UserDef::setBody |
( |
ActBody * |
x | ) |
|
|
inline |
Directly set the body of the user-defined type
- Parameters
-
x | the body to assign to this user-defined type |
◆ setFile()
void UserDef::setFile |
( |
const char * |
s | ) |
|
|
inline |
Set file name for this type
- Parameters
-
◆ setLine()
void UserDef::setLine |
( |
int |
num | ) |
|
|
inline |
Set the line number where this type was defined
- Parameters
-
◆ setName()
void UserDef::setName |
( |
const char * |
s | ) |
|
|
inline |
Set the name of the type. Used to share the string pointer between this data structure and the hash table that holds the type name as well.
- Parameters
-
s | is the new string pointer to use for the type name |
◆ SetParent()
Setup parent relationship for the imlementation relation between types.
- Parameters
-
◆ _ns
namespace within which this type is defined
body of user-defined type
◆ defined
unsigned int UserDef::defined |
|
protected |
1 if this has been defined, 0 otherwise
◆ expanded
unsigned int UserDef::expanded |
|
protected |
1 if this has been expanded, 0 otherwise
◆ exported
unsigned int UserDef::exported |
|
protected |
1 if the type is exported, 0 otherwise
◆ file
const char* UserDef::file |
|
protected |
file name (if known) where this was defined
◆ has_refinement
int UserDef::has_refinement |
|
protected |
1 if there is a refinement body
◆ inherited_param
◆ inherited_templ
int UserDef::inherited_templ |
|
protected |
number of inherited template parameters
◆ lang
sub-languages within this type
◆ level
default modeling level for the type
◆ lineno
line number (if known) where this was defined
◆ name
const char* UserDef::name |
|
protected |
Name of the user-defined type.
◆ nports
◆ nt
number of template parameters
◆ parent
implementation relationship, if any
◆ pending
unsigned int UserDef::pending |
|
protected |
1 if this is currently being expanded, 0 otherwise
◆ pn
◆ port_n
const char** UserDef::port_n |
|
protected |
◆ port_t
◆ pt
◆ unexpanded
The documentation for this class was generated from the following file: