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

This class is used to store Act identifiers that correspond to instances. Identifiers have an optional namespace prefix (in the case of namespace global identifiers), followed by a list of components of the idenfier. More...

#include <act_id.h>

Public Member Functions

 ActId (const char *s, Array *_a=NULL)
 
 ~ActId ()
 release storage
 
int isRange ()
 
int isDeref ()
 
ArrayarrayInfo ()
 
void Append (ActId *id)
 
const char * getName ()
 
ActIdRest ()
 
void Print (FILE *fp, ActId *stop=NULL, int style=0)
 
void sPrint (char *buf, int sz, ActId *stop=NULL, int style=0)
 
ActIdClone ()
 
ActIdExpand (ActNamespace *ns, Scope *s)
 
ActIdExpandCHP (ActNamespace *ns, Scope *s)
 
ExprEval (ActNamespace *ns, Scope *s, int is_lval=0, int is_chp=0)
 
ExprEvalCHP (ActNamespace *ns, Scope *s, int is_lval=0)
 
act_connectionCanonical (Scope *s)
 
act_connectionmyConnection (Scope *s)
 
void setArray (Array *_a)
 
void prune ()
 
int isEqual (ActId *other)
 
int isExpanded ()
 
ActIdTail ()
 
ValueIdxrootVx (Scope *)
 
int isDynamicDeref ()
 
UserDefisFragmented (Scope *)
 
ActIdunFragment (Scope *)
 
UserDefcanFragment (Scope *)
 
act_connectionrootCanonical (Scope *)
 
int isNonLocal (Scope *s)
 
ActIdnonProcSuffix (Process *p, Process **ret)
 
int validateDeref (Scope *sc)
 
ActIdstripArray ()
 
int isNamespace ()
 
ActNamespacegetNamespace ()
 

Static Public Member Functions

static ActIdparseId (char *s, const char delim1, const char arrayL, const char arrayR, const char delim2)
 
static ActIdparseId (const char *s, const char delim1, const char arrayL, const char arrayR, const char delim2)
 
static ActIdparseId (const char *s)
 
static ActIdparseId (char *s)
 

Private Member Functions

ValueIdxrawValueIdx (Scope *)
 

Private Attributes

mstring_t * name
 
Arraya
 
ActIdnext
 

Detailed Description

This class is used to store Act identifiers that correspond to instances. Identifiers have an optional namespace prefix (in the case of namespace global identifiers), followed by a list of components of the idenfier.

Each identifier component has a name, and an optional array reference. Examples of identifiers include foo, name::foo, foo.bar, foo[3].bar[7][8].b, foo[3..7], etc.

In the case of something like "foo[3].bar.baz", "bar.baz" is viewed as a sub-identifier of "foo[3]", and "foo[3]" is the root of the identifier. Similarly, "baz" is a sub-identifier of "bar.baz".

All strings stored in any ActId are cached using the string_cache mechanism in the common library.

Constructor & Destructor Documentation

◆ ActId()

ActId::ActId ( const char *  s,
Array _a = NULL 
)

Create a simple ACT identifier with name "s" and an optional array reference.

Parameters
sis the name of the identifier
_ais the optional array specfier

◆ ~ActId()

ActId::~ActId ( )

release storage

Member Function Documentation

◆ Append()

void ActId::Append ( ActId id)

Make the current identifier into identifier . id, assuming that this ActId does not have a sub-identifier. If the ActId in fact has a sub-identifier, an assertion failure will occur.

Parameters
idis the sub-identifer to be appended to the current identifier.

◆ arrayInfo()

Array * ActId::arrayInfo ( )
inline

Return a reference to the array associated with this piece of the identifier.

Returns
the array reference

◆ canFragment()

UserDef * ActId::canFragment ( Scope )

If this identifier is a reference to a user-defined type, then you may be able to fragment it further into ports/etc. This method can be used to return the type for the identifier.

Returns
the user-defined type pointer, or NULL if this identifier does not correspond to a user-defined type.

◆ Canonical()

act_connection * ActId::Canonical ( Scope s)

Find canonical root identifier in the current scope. When an identifier is connected to others, one of them is the "canonical" identifier. This returns its connection pointer.

Parameters
sis the scope
Returns
the act_connection pointer, which is the canonical/unique representation for any identifier with all connections resolved.

◆ Clone()

ActId * ActId::Clone ( )

Returns a deep copy of the ActID. Note that string pointers are shared across all ActIDs, and clones are no different.

Returns
a freshly allocated ActID

◆ Eval()

Expr * ActId::Eval ( ActNamespace ns,
Scope s,
int  is_lval = 0,
int  is_chp = 0 
)

Evaluate identifier: It either returns an evaluated identifier (i.e. all items expanded out), or in the case of something that isn't an lval, the value of the parameter.

Return expression types are: for lval: E_VAR otherwise: E_VAR (for non-parameter types) E_TRUE, E_FALSE, E_TYPE, E_REAL, E_INT, E_ARRAY, E_SUBRANGE – for parameter types

The CHP variant of the call permits an identifier to have a dynamic de-reference. Non-CHP array references must be fully evaluated to constant expressions.

Parameters
nsis the namespace where the evaluation is performed
sis the evaluation scope
is_lvalis 0 for identifiers that appear in an expression context, and 1 otherwise (for "left values").
is_chpis 1 for identifiers that are within a CHP body, 0 otherwise.
Returns
The evaluated Expr data structure.

◆ EvalCHP()

Expr * ActId::EvalCHP ( ActNamespace ns,
Scope s,
int  is_lval = 0 
)
inline

A short-hand for Eval(), to make it easier to read.

Parameters
nssame as in Eval()
ssame as in Eval()
is_lvalsame as in Eval()
Returns
The evaluated expression, in a CHP context.

◆ Expand()

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

Returns an expanded ID where any parameters are substituted and any expressions that can be evaluated are evaluated.

Parameters
nsis the namespace in which the ID was found
sis the evaluation scope
Returns
A freshly allocated ActId corresponding to the expanded identifier.

◆ ExpandCHP()

ActId * ActId::ExpandCHP ( ActNamespace ns,
Scope s 
)

Similar to Expand(), except the identifier comes from the CHP context. This means it can have array expressions that contain other identifers.

Parameters
nsis the namespace in which the ID was found
sis the evaluation scope
Returns
A freshly allocated ActId corresponding to the expanded identifer.

◆ getName()

const char * ActId::getName ( )
inline
Returns
the simple identifier name for the root of the idenfier.

◆ getNamespace()

ActNamespace * ActId::getNamespace ( )

Returns the ActNamespace pointer for a namespace global.

Returns
NULL if this is not a namespace global ID, or the namespace pointer otherwise.

◆ isDeref()

int ActId::isDeref ( )
inline
Returns
1 if there is an array specifier as part of this id, but it is not a range specifier. NOTE that this does not mean this specifies a full dereference or that the dimensions match/etc.

◆ isDynamicDeref()

int ActId::isDynamicDeref ( )

This method is used to check if this ID has any array index that is not a constant value after expansion. Such indicies can only be resolved at hardware runtime (i.e. dynamically).

Returns
1 if the ID contains a dynamic de-reference, 0 otherwise.

◆ isEqual()

int ActId::isEqual ( ActId other)

Checks if this identifier is equal to the one passed in.

Parameters
otheris the identifier to compare against
Returns
1 if equal, zero otherwise.

◆ isExpanded()

int ActId::isExpanded ( )
Returns
1 if this is an expanded identifier, 0 otherwise

◆ isFragmented()

UserDef * ActId::isFragmented ( Scope )

An identifier can correspond to a "fragmented" integer or channel type. This would be because the identifier accesses part of a channel or integer data type via their port lists. This returns the user-defined type that this identifier fragments, if any.

Returns
NULL if this is not a fragmented integer/channel, or the user-defined type corresponding to the fragmented type otherwise.

◆ isNamespace()

int ActId::isNamespace ( )

Return 1 if this ActId is a namespace prefix, 0 otherwise. This can only be true for the first part of an ActId

Returns
1 if this is a namespace, 0 otherwise.

◆ isNonLocal()

int ActId::isNonLocal ( Scope s)

A non-local ID is a port or global.

Returns
1 if this ID is a non-local identifier, 0 otherwise.

◆ isRange()

int ActId::isRange ( )

This can be used to check if any part of the identifier includes a range specification as part of the array component

Returns
1 if this has a range specifier, 0 otherwise.

◆ myConnection()

act_connection * ActId::myConnection ( Scope s)

Return the connection pointer corresponding to this particular id, NULL if something unexpected occurred.

Note: we assume this connection pointer already exists, and this is only used for either foo or foo.bar

TODO : generalize this if needed later

Parameters
sis the scope
Returns
the connection pointer corresponding to my ID

◆ nonProcSuffix()

ActId * ActId::nonProcSuffix ( Process p,
Process **  ret 
)

Precondition: this ID path exists in the process.

For an ID a.b.c.d.e where the prefix a.b.c are processes, and d.e are not, this returns "c.d.e" as the rest, and the type of "a.b" as the process that contains "c.d.e". If none of them are processes, it returns the ID and the process argument.

So looking up the return value in the return process guarantees it is a non-process.

Parameters
pis the process where the identifier exists
retis used to return the process type
Returns
the suffix of the identifier.

◆ parseId() [1/4]

static ActId * ActId::parseId ( char *  s)
static

◆ parseId() [2/4]

static ActId * ActId::parseId ( char *  s,
const char  delim1,
const char  arrayL,
const char  arrayR,
const char  delim2 
)
static

◆ parseId() [3/4]

static ActId * ActId::parseId ( const char *  s)
static

◆ parseId() [4/4]

static ActId * ActId::parseId ( const char *  s,
const char  delim1,
const char  arrayL,
const char  arrayR,
const char  delim2 
)
static

◆ Print()

void ActId::Print ( FILE *  fp,
ActId stop = NULL,
int  style = 0 
)

Print ID to the specified output stream, stopping at the specified point. Default is print the entire ID.

Multi-dimensional arrays can be printed in two styles: either in the form [a][b][c] (style = 0), or [a,b,c] (style = 1).

Parameters
fpis the output stream to be used
stopis the stopping criteria: the sub-identifier that should not be printed.
stylespecifies the printing style

◆ prune()

void ActId::prune ( )
inline

This prunes the sub-identifer by setting it to NULL / empty

◆ rawValueIdx()

ValueIdx * ActId::rawValueIdx ( Scope )
private

used to return the ValueIdx for this ID, potentially allocating the initial connection pointer if needed

◆ Rest()

ActId * ActId::Rest ( )
inline

This method is used to return the sub-identifier.

Returns
an ActId corresponding to the sub-identifier, NULL if there isn't one.

◆ rootCanonical()

act_connection * ActId::rootCanonical ( Scope )

This finds the canonical connection pointer for the object, and then traverses it to the canonical root. For example if you have an identifier like x.y.z, then the "root" of it would be "x".

Returns
the root of the canonical pointer for the object

◆ rootVx()

ValueIdx * ActId::rootVx ( Scope )

This method returns the ValueIdx pointer for the identifier.

Returns
the root valueidx pointer

◆ setArray()

void ActId::setArray ( Array _a)
inline

This method is used to replace the array de-reference of the identifier with the newly specified one. It can also be used to remove the array specifier by setting it to NULL.

Parameters
_ais the new array specifier for this identifier

◆ sPrint()

void ActId::sPrint ( char *  buf,
int  sz,
ActId stop = NULL,
int  style = 0 
)

This is like Print(), except the ID is printed to a buffer

Parameters
bufis the output buffer
szis the size of the output buffer
stopis the stopping condition
styleis the array style

◆ stripArray()

ActId * ActId::stripArray ( )

This returns a freshly allocated ID where the final array de-reference from the current ID has been removed.

Returns
the freshly allocated ID without any final array dereference

◆ Tail()

ActId * ActId::Tail ( )
Returns
the sub-identifier reference for the current identifier

◆ unFragment()

ActId * ActId::unFragment ( Scope )

If an ID is fragmented, this returns the prefix of the identifier that corresponds to the unfragmented part.

Returns
a new ActId corresponding to the unfragmented part of the ID, NULL if this is not possible.

◆ validateDeref()

int ActId::validateDeref ( Scope sc)

Check that any array indices are valid and this is a non-arrayed identifier.

Returns
1 if validation succeeded, 0 otherwise

Member Data Documentation

◆ a

Array* ActId::a
private

array reference/dereference

◆ name

mstring_t* ActId::name
private

name of the identifier

◆ next

ActId* ActId::next
private

any ‘.’ reference


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