Zen
A cross-platform functional programming language

RefCollector Class Reference

Class that collects external references from different AST nodes. More...

#include <GetXRef.hpp>

List of all members.

Classes

struct  DefStackItem
 Wrapper around a stack item. More...
struct  StackItem
 Class maintains a stack item of scopes. More...

Public Member Functions

 RefCollector (ParseContext &pctx, const Ast::Storage::T &storage)
 Default constructor.
 ~RefCollector ()
 Destructor.
void getInvokerRefList (const Ast::Invoker &invoker)
 Get the list of external references for an invoker.
void getImplItemRefList (const Ast::ImplItem &item)
 Get the list of external references for an item.
void getExprRefList (const Ast::Expr &expr)
 Get the list of external references for an expression.
void getExprListRefList (const Ast::ExprList &list)
 Get the list of external references for an expression list.
void getSharedDefRefList (const Ast::SharedDef &sdef)
 Get the list of external references for a shared definition.
void getStatementListRefList (const Ast::FunctionDef &fdef, const Ast::StatementList &list)
 Get the list of external references for a statement list.
const Ast::VariableRefListgetRefList () const
 Get the list of external references that has been collected.
void addDef (const Ast::VariableDef &def)
 Add a variable definition to the top item on the stack.
bool hasDefItem (const Ast::VariableDef &vdef)
 Check if a variable definition is present anywhere in the stack.
void setStorage (const Ast::VariableRef &vref, const Ast::Storage::T &storage)
 Set the staorage type for a variable definition.
bool addRef (const Ast::VariableRef &vref)
 Add a variable reference to the collection list.
void addRefWithStorage (const Ast::VariableRef &vref)
 Add a variable reference to the collection list and set the storage.
void addRefList (const Ast::VariableRefList &xRefList)
 Add a variable reference list to the collection list.

Private Types

typedef z::stack< StackItem * > DefStack
 The stack of scopes using StackItem.

Private Member Functions

 RefCollector (const RefCollector &src)
 Copy constructor.
z::string printStack () const
 Print the current stack for debugging.
StackItempushDefItem (const Ast::Scope::Type &type)
 Push a new scope on the stack.
void popDefItem (StackItem &item)
 Pop a scope off the stack.

Private Attributes

ParseContext_pctx
 The parse context.
const Ast::Storage::T _storage
 The storage type to set for external references.
Ast::VariableRefList _refList
 The list of external references.
DefStack _defStack
 The definition stack.

Detailed Description

Class that collects external references from different AST nodes.


Constructor & Destructor Documentation

RefCollector ( ParseContext pctx,
const Ast::Storage::T storage 
) [inline]

Default constructor.

Parameters:
pctxThe collector context
storageThe storage type to set for external references collected
RefCollector ( const RefCollector src) [inline, private]

Copy constructor.

This is private to prevent copy construction

Parameters:
srcThe source instance

Member Function Documentation

void addDef ( const Ast::VariableDef def) [inline]

Add a variable definition to the top item on the stack.

Parameters:
defThe variable definition to add
bool addRef ( const Ast::VariableRef vref) [inline]

Add a variable reference to the collection list.

Parameters:
vrefThe variable reference to add
Returns:
True if added, false if already present
void addRefList ( const Ast::VariableRefList xRefList) [inline]

Add a variable reference list to the collection list.

Parameters:
xRefListThe variable reference to merge
void addRefWithStorage ( const Ast::VariableRef vref) [inline]

Add a variable reference to the collection list and set the storage.

Parameters:
vrefThe variable reference to add
void getExprListRefList ( const Ast::ExprList list)

Get the list of external references for an expression list.

Parameters:
listThe expression list to visit
void getExprRefList ( const Ast::Expr expr)

Get the list of external references for an expression.

Parameters:
exprThe expression to visit
void getImplItemRefList ( const Ast::ImplItem item)

Get the list of external references for an item.

Parameters:
itemThe item to visit
void getInvokerRefList ( const Ast::Invoker invoker)

Get the list of external references for an invoker.

Parameters:
invokerThe invoker to visit
const Ast::VariableRefList& getRefList ( ) const [inline]

Get the list of external references that has been collected.

Returns:
The external reference list
void getSharedDefRefList ( const Ast::SharedDef sdef)

Get the list of external references for a shared definition.

Parameters:
sdefThe shared definition to visit
void getStatementListRefList ( const Ast::FunctionDef fdef,
const Ast::StatementList list 
)

Get the list of external references for a statement list.

Parameters:
fdefThe function definition whose in-params are to be added to the list
listThe statement list to visit
bool hasDefItem ( const Ast::VariableDef vdef) [inline]

Check if a variable definition is present anywhere in the stack.

Parameters:
vdefThe variable definition to check
Returns:
True if the variable definition is present anywhere on the stack, else false
void popDefItem ( StackItem item) [inline, private]

Pop a scope off the stack.

Parameters:
itemThe item to pop
z::string printStack ( ) const [inline, private]

Print the current stack for debugging.

Returns:
A string holding the current stack trace
StackItem& pushDefItem ( const Ast::Scope::Type type) [inline, private]

Push a new scope on the stack.

Parameters:
typeThe type of the new scope to push on the stack
Returns:
The newly pushed stack item
void setStorage ( const Ast::VariableRef vref,
const Ast::Storage::T storage 
) [inline]

Set the staorage type for a variable definition.

Parameters:
vrefThe variable reference to alter
storageThe storage type to set

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines