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

This is the data structure that holds all instances and their associated types within a scope. Each user-defined type has an associated Scope, and so does each ActNamespace. More...

#include <namespaces.h>

Public Member Functions

 Scope (Scope *parent, int is_expanded=0)
 
 ~Scope ()
 
ScopeParent ()
 
InstTypeLookup (const char *s)
 
InstTypeLookup (ActId *id, int err=1)
 
void refineBaseType (const char *s, InstType *u)
 
InstTypeFullLookup (const char *s)
 
int isGlobal (const char *s)
 
InstTypeFullLookup (ActId *id, Array **aref)
 
InstTypelocalLookup (ActId *id, Array **aref)
 
ValueIdxLookupVal (const char *s)
 
ValueIdxFullLookupVal (const char *s)
 
int Add (const char *s, InstType *it)
 
void Del (const char *s)
 
void FlushExpand ()
 
void Merge (Scope *s)
 
void Print (FILE *fp)
 
void setUserDef (UserDef *_u)
 
void mkFunction ()
 
int isFunction ()
 
UserDefgetUserDef ()
 
void setNamespace (ActNamespace *_ns)
 
ActNamespacegetNamespace ()
 
unsigned long AllocPInt (int count=1)
 
void DeallocPInt (unsigned long idx, int count=1)
 
void setPInt (unsigned long id, unsigned long val)
 
int issetPInt (unsigned long id)
 
unsigned long getPInt (unsigned long id)
 
unsigned long AllocPInts (int count=1)
 
void DeallocPInts (unsigned long idx, int count=1)
 
int issetPInts (unsigned long id)
 
long getPInts (unsigned long id)
 
void setPInts (unsigned long id, long val)
 
unsigned long AllocPReal (int count=1)
 
void DeallocPReal (unsigned long idx, int count=1)
 
int issetPReal (unsigned long id)
 
double getPReal (unsigned long id)
 
void setPReal (unsigned long id, double val)
 
unsigned long AllocPBool (int count=1)
 
void DeallocPBool (unsigned long idx, int count=1)
 
int issetPBool (unsigned long id)
 
int getPBool (unsigned long id)
 
void setPBool (unsigned long id, int val)
 
unsigned long AllocPType (int count=1)
 
void DeallocPType (unsigned long idx, int count=1)
 
int issetPType (unsigned long id)
 
InstTypegetPType (unsigned long id)
 
void setPType (unsigned long id, InstType *val)
 
int isExpanded ()
 
void BindParam (const char *s, InstType *tt)
 
void BindParam (ActId *id, InstType *tt)
 
void BindParam (const char *s, AExpr *ae)
 
void BindParam (ActId *id, AExpr *ae)
 
void BindParam (ActId *id, AExprstep *aes, int idx=-1)
 
void playBody (ActBody *b)
 
const char * getName ()
 

Static Public Member Functions

static void printConnections (FILE *fp, act_connection *cx, bool force=false)
 

Private Member Functions

 A_DECL (unsigned long, vpint)
 
 A_DECL (long, vpints)
 
 A_DECL (double, vpreal)
 
 A_DECL (InstType *, vptype)
 

Private Attributes

struct Hashtable * H
 
Scopeup
 
UserDefu
 
unsigned int expanded:1
 
ActNamespacens
 
int is_function
 
bitset_t * vpint_set
 
bitset_t * vpints_set
 
bitset_t * vpreal_set
 
bitset_t * vptype_set
 
unsigned long vpbool_len
 
bitset_t * vpbool
 
bitset_t * vpbool_set
 

Friends

class ActInstiter
 
class ActUniqProcInstiter
 

Detailed Description

This is the data structure that holds all instances and their associated types within a scope. Each user-defined type has an associated Scope, and so does each ActNamespace.

Scopes also know about their parent (enclosing) scope. So a process definition would have a scope whose parent is the scope of the namespace in which it is defined. A namespace scope would have a parent scope that is the namespace within which it was created. The top-level scope of the entire design is the built-in global namespace.

Scopes can be either expanded or unexpanded. Expanded scopes and unexpanded scopes have different internals.

Constructor & Destructor Documentation

◆ Scope()

Scope::Scope ( Scope parent,
int  is_expanded = 0 
)
Parameters
parentis the parent scope for this namespace
is_expandedis 1 if this is an expanded scope, 0 otherwise

◆ ~Scope()

Scope::~Scope ( )

Member Function Documentation

◆ A_DECL() [1/4]

Scope::A_DECL ( double  ,
vpreal   
)
private

◆ A_DECL() [2/4]

Scope::A_DECL ( InstType ,
vptype   
)
private

◆ A_DECL() [3/4]

Scope::A_DECL ( long  ,
vpints   
)
private

◆ A_DECL() [4/4]

Scope::A_DECL ( unsigned long  ,
vpint   
)
private

◆ Add()

int Scope::Add ( const char *  s,
InstType it 
)

Add a new identifier to the scope.

Parameters
sis a string corresponding to the identifier being added to the scope
itis the instantiation type
Returns
0 on a failure, 1 on success.

◆ AllocPBool()

unsigned long Scope::AllocPBool ( int  count = 1)

Like AllocPInt(), but for pbools

◆ AllocPInt()

unsigned long Scope::AllocPInt ( int  count = 1)

Allocate space to hold a pint in the scope

Parameters
countis the number of pints to allocate
Returns
the index for the first new pint allocated.

◆ AllocPInts()

unsigned long Scope::AllocPInts ( int  count = 1)

◆ AllocPReal()

unsigned long Scope::AllocPReal ( int  count = 1)

Like AllocPInt(), but for preals

◆ AllocPType()

unsigned long Scope::AllocPType ( int  count = 1)

Like AllocPInt(), but for ptypes

◆ BindParam() [1/5]

void Scope::BindParam ( ActId id,
AExpr ae 
)

Bind a name to the array expression

Parameters
idis the name
aeis the array expression

◆ BindParam() [2/5]

void Scope::BindParam ( ActId id,
AExprstep aes,
int  idx = -1 
)

Bind a name at the specified offset (in idx) to the current element from the AExpr stepper AExprstep

◆ BindParam() [3/5]

void Scope::BindParam ( ActId id,
InstType tt 
)

Bind a name to a type. Must be a local name

Parameters
idis the name
ttis the type to use

◆ BindParam() [4/5]

void Scope::BindParam ( const char *  s,
AExpr ae 
)

Bind a name to the array expression

Parameters
sis the name to be set
aecontains the array expression

◆ BindParam() [5/5]

void Scope::BindParam ( const char *  s,
InstType tt 
)

Bind a name to a type. Allocates space for it if needed.

Parameters
sis the name
ttis the type to bind to the name

◆ DeallocPBool()

void Scope::DeallocPBool ( unsigned long  idx,
int  count = 1 
)

Like DeallocPInt(), but for pbools

◆ DeallocPInt()

void Scope::DeallocPInt ( unsigned long  idx,
int  count = 1 
)

De-allocate pints starting from the index. This only works if you are de-allocating from the end of the allocated pint array. Otherwise it is silently ignored.

Parameters
idxis index at which to de-allocate
countis the number to deallocate

◆ DeallocPInts()

void Scope::DeallocPInts ( unsigned long  idx,
int  count = 1 
)

◆ DeallocPReal()

void Scope::DeallocPReal ( unsigned long  idx,
int  count = 1 
)

Like DeallocPInt(), but for preals

◆ DeallocPType()

void Scope::DeallocPType ( unsigned long  idx,
int  count = 1 
)

Like DeallocPInt(), but for ptypes

◆ Del()

void Scope::Del ( const char *  s)

Delete a name from the current scope. This is used to delete loop index variables.

Parameters
sis the name to be deleted.

◆ FlushExpand()

void Scope::FlushExpand ( )

Clear the scope table, and mark this as an expanded scope.

◆ FullLookup() [1/2]

InstType * Scope::FullLookup ( ActId id,
Array **  aref 
)

To a complete lookup of the ActId. The (possibly NULL) array reference at the end of the ID is returned in aref, if aref is non-NULL.

Parameters
idis the identifier to be looked up in the current scope (and its parents if necessary)
arefis used to return the array specifier in the ID
Returns
the actual type of the identifier

◆ FullLookup() [2/2]

InstType * Scope::FullLookup ( const char *  s)

Similar to lookup, but instead of just looking in the local scope also look at the parent scopes as well—i.e. any visible scope where the name can be found

Parameters
sis the name to be looked up
Returns
the InstType for the name if found, NULL otherwise

◆ FullLookupVal()

ValueIdx * Scope::FullLookupVal ( const char *  s)

Like LookupVal(), but also looks in the parent scope if you can't find the specified name in the current scope.

Parameters
sis the name to lookup
Returns
the ValueIdx for the specified name

◆ getName()

const char * Scope::getName ( )
Returns
the name of the user-defined type or namespace corresponding to this scope. Returns -unknown- if neither exist.

◆ getNamespace()

ActNamespace * Scope::getNamespace ( )
inline
Returns
the namespace associated with the scope, NULL if there isn't one

◆ getPBool()

int Scope::getPBool ( unsigned long  id)

Like getPInt(), but for pbools

◆ getPInt()

unsigned long Scope::getPInt ( unsigned long  id)
Parameters
idis the index of the pint
Returns
the value of the pint at the specified index

◆ getPInts()

long Scope::getPInts ( unsigned long  id)

◆ getPReal()

double Scope::getPReal ( unsigned long  id)

Like getPInt(), but for preals

◆ getPType()

InstType * Scope::getPType ( unsigned long  id)

Like getPInt(), but for ptypes

◆ getUserDef()

UserDef * Scope::getUserDef ( )
inline
Returns
the user-defined type this scope is for, if it exists. NULL means this is not associated with a user-defined type.

◆ isExpanded()

int Scope::isExpanded ( )
inline
Returns
1 if this is an expanded scope, 0 otherwise

◆ isFunction()

int Scope::isFunction ( )
inline

Check if this is a function scope

◆ isGlobal()

int Scope::isGlobal ( const char *  s)

Do a lookup and see if the lookup succeeded in a namespace or in a user-defined type

Parameters
sis the name to be looked up
Returns
1 if this was in namespace (i.e. a namespace global), 0 otherwise

◆ issetPBool()

int Scope::issetPBool ( unsigned long  id)

Like issetPInt(), but for pbools

◆ issetPInt()

int Scope::issetPInt ( unsigned long  id)

Check if the pint is in fact set

Parameters
idis the index of the pint
Returns
1 if it is set, 0 otherwise

◆ issetPInts()

int Scope::issetPInts ( unsigned long  id)

◆ issetPReal()

int Scope::issetPReal ( unsigned long  id)

Like issetPInt(), but for preals

◆ issetPType()

int Scope::issetPType ( unsigned long  id)

Like issetPInt(), but for ptypes

◆ localLookup()

InstType * Scope::localLookup ( ActId id,
Array **  aref 
)

Only looks in the current scope for the ID. However, the type returned is the actual type of the full ID (not just the root), and aref is used to return any array reference associated with the specified id.

Parameters
idis the ID to lookup in the local scope
arefreturns the array reference in the id, if any
Returns
the type of the id, if found in the current scope.

◆ Lookup() [1/2]

InstType * Scope::Lookup ( ActId id,
int  err = 1 
)

Similar to Lookup(), but takes an ActId as a parameter. Only looks up the root of the identifier. By default this reports an error if the ActId has a sub-identifier. This error is suppressed by the err flag.

Parameters
idthe ActId to lookup in the local scope
err1 if a fatal error should be reported, 0 to ignore the error
Returns
the InstType for the specified name if it exists, NULL if not found

◆ Lookup() [2/2]

InstType * Scope::Lookup ( const char *  s)

Lookup an identifier in the specified scope only. Restrict the scope to a local lookup—don't look in parent scopes.

Parameters
sis the name to lookup
Returns
the InstType for the specified name, NULL if not found

◆ LookupVal()

ValueIdx * Scope::LookupVal ( const char *  s)

Only for expanded scopes. This returns ValueIdx information for identifier.

Parameters
sis the name to lookup
Returns
the ValueIdx associated with s in the current scope

◆ Merge()

void Scope::Merge ( Scope s)

Merge in instances into the scope. This must be called before any other instances have been created.

◆ mkFunction()

void Scope::mkFunction ( )
inline

Use to indicate that this scope is part of a function

◆ Parent()

Scope * Scope::Parent ( )
inline
Returns
the parent scope

◆ playBody()

void Scope::playBody ( ActBody b)

Create instances given the body

Parameters
bis the body to be processed.

◆ Print()

void Scope::Print ( FILE *  fp)

Print out the scope

Parameters
fpis the output file

◆ printConnections()

static void Scope::printConnections ( FILE *  fp,
act_connection cx,
bool  force = false 
)
static

Print the connections specified by the cx pointer. Normally this only prints the essential connections—i.e. if cx is a primary. The force flag can be used to override this, forcing redundant connections to be printed.

Parameters
fpis the output file
cxis the connection
forceis used to force the printing of non-primary connections

◆ refineBaseType()

void Scope::refineBaseType ( const char *  s,
InstType u 
)

Look up the local variable specified, and if it exists then refine its base type using the new type information. Used to update scope tables while processing overrides.

Parameters
sis the name of the instance whose type is to be updated
uis the updated type for the instance

◆ setNamespace()

void Scope::setNamespace ( ActNamespace _ns)
inline

Set the namespace associated with this scope

Parameters
_nsis the namespace to be associated with the scope

◆ setPBool()

void Scope::setPBool ( unsigned long  id,
int  val 
)

Like setPInt(), but for pbools

◆ setPInt()

void Scope::setPInt ( unsigned long  id,
unsigned long  val 
)

Set the pint at index id to the specified value

Parameters
idis the index of the pint
valis the value to set

◆ setPInts()

void Scope::setPInts ( unsigned long  id,
long  val 
)

◆ setPReal()

void Scope::setPReal ( unsigned long  id,
double  val 
)

Like setPInt(), but for preals

◆ setPType()

void Scope::setPType ( unsigned long  id,
InstType val 
)

Like setPInt(), but for ptypes

◆ setUserDef()

void Scope::setUserDef ( UserDef _u)
inline

Associate scope with a user defined type.

Parameters
_uis the user-defined type to be associated with this scope

Friends And Related Function Documentation

◆ ActInstiter

friend class ActInstiter
friend

◆ ActUniqProcInstiter

friend class ActUniqProcInstiter
friend

Member Data Documentation

◆ expanded

unsigned int Scope::expanded
private

◆ H

struct Hashtable* Scope::H
private

◆ is_function

int Scope::is_function
private

◆ ns

ActNamespace* Scope::ns
private

◆ u

UserDef* Scope::u
private

◆ up

Scope* Scope::up
private

◆ vpbool

bitset_t* Scope::vpbool
private

◆ vpbool_len

unsigned long Scope::vpbool_len
private

◆ vpbool_set

bitset_t* Scope::vpbool_set
private

◆ vpint_set

bitset_t* Scope::vpint_set
private

◆ vpints_set

bitset_t* Scope::vpints_set
private

◆ vpreal_set

bitset_t* Scope::vpreal_set
private

◆ vptype_set

bitset_t* Scope::vptype_set
private

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