ACT Library
|
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>
Static Public Member Functions | |
static ActId * | parseId (char *s, const char delim1, const char arrayL, const char arrayR, const char delim2) |
static ActId * | parseId (const char *s, const char delim1, const char arrayL, const char arrayR, const char delim2) |
static ActId * | parseId (const char *s) |
static ActId * | parseId (char *s) |
Private Member Functions | |
ValueIdx * | rawValueIdx (Scope *) |
Private Attributes | |
mstring_t * | name |
Array * | a |
ActId * | next |
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.
ActId::ActId | ( | const char * | s, |
Array * | _a = NULL |
||
) |
Create a simple ACT identifier with name "s" and an optional array reference.
s | is the name of the identifier |
_a | is the optional array specfier |
ActId::~ActId | ( | ) |
release storage
void ActId::Append | ( | ActId * | id | ) |
|
inline |
Return a reference to the array associated with this piece of the identifier.
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.
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.
s | is the scope |
ActId * ActId::Clone | ( | ) |
Returns a deep copy of the ActID. Note that string pointers are shared across all ActIDs, and clones are no different.
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.
ns | is the namespace where the evaluation is performed |
s | is the evaluation scope |
is_lval | is 0 for identifiers that appear in an expression context, and 1 otherwise (for "left values"). |
is_chp | is 1 for identifiers that are within a CHP body, 0 otherwise. |
|
inline |
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.
ns | is the namespace in which the ID was found |
s | is the evaluation scope |
ActId * ActId::ExpandCHP | ( | ActNamespace * | ns, |
Scope * | s | ||
) |
|
inline |
ActNamespace * ActId::getNamespace | ( | ) |
Returns the ActNamespace pointer for a namespace global.
|
inline |
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).
int ActId::isEqual | ( | ActId * | other | ) |
Checks if this identifier is equal to the one passed in.
other | is the identifier to compare against |
int ActId::isExpanded | ( | ) |
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.
int ActId::isNamespace | ( | ) |
int ActId::isNonLocal | ( | Scope * | s | ) |
A non-local ID is a port or global.
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
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
s | is the scope |
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.
p | is the process where the identifier exists |
ret | is used to return the process type |
|
static |
|
static |
|
static |
|
static |
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).
fp | is the output stream to be used |
stop | is the stopping criteria: the sub-identifier that should not be printed. |
style | specifies the printing style |
|
inline |
This prunes the sub-identifer by setting it to NULL / empty
used to return the ValueIdx for this ID, potentially allocating the initial connection pointer if needed
|
inline |
This method is used to return the sub-identifier.
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".
This method returns the ValueIdx pointer for the identifier.
|
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.
_a | is the new array specifier for this identifier |
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
buf | is the output buffer |
sz | is the size of the output buffer |
stop | is the stopping condition |
style | is the array style |
ActId * ActId::stripArray | ( | ) |
This returns a freshly allocated ID where the final array de-reference from the current ID has been removed.
ActId * ActId::Tail | ( | ) |
If an ID is fragmented, this returns the prefix of the identifier that corresponds to the unfragmented part.
int ActId::validateDeref | ( | Scope * | sc | ) |
Check that any array indices are valid and this is a non-arrayed identifier.
|
private |
array reference/dereference
|
private |
name of the identifier
|
private |
any ‘.’ reference