libutap
|
A reference to a frame. More...
#include <symbols.h>
Public Member Functions | |
frame_t () | |
Default constructor. More... | |
frame_t (const frame_t &) | |
Copy constructor. More... | |
~frame_t () | |
Destructor. More... | |
const frame_t & | operator= (const frame_t &) |
Assignment operator. More... | |
bool | operator== (const frame_t &) const |
Equality operator. More... | |
bool | operator!= (const frame_t &) const |
Inequality operator. More... | |
uint32_t | getSize () const |
Returns the number of symbols in this frame. More... | |
symbol_t | getSymbol (int32_t) |
Returns the Nth symbol in this frame. More... | |
int32_t | getIndexOf (std::string name) const |
Returns the index of the symbol with the given name. More... | |
int32_t | getIndexOf (symbol_t) const |
Returns the index of a symbol or -1 if not present. More... | |
symbol_t | operator[] (int32_t) |
Returns the Nth symbol in this frame. More... | |
const symbol_t | operator[] (int32_t) const |
Returns the Nth symbol in this frame. More... | |
symbol_t | addSymbol (std::string name, type_t, void *user=NULL) |
Adds a symbol of the given name and type to the frame. More... | |
void | add (symbol_t) |
Add all symbols from the given frame. More... | |
void | add (frame_t) |
Add all symbols from the given frame. More... | |
void | moveTo (frame_t) |
Move all symbols from this to a given one (leaving this empty). More... | |
void | remove (symbol_t s) |
removes the given symbol More... | |
bool | resolve (std::string name, symbol_t &symbol) |
Resolves a name in this frame or a parent frame. More... | |
frame_t | getParent () throw (NoParentException) |
Returns the parent frame. More... | |
bool | hasParent () const |
Returns true if this frame has a parent. More... | |
std::string | toString () |
bool | empty () |
Static Public Member Functions | |
static frame_t | createFrame () |
Creates and returns a new root-frame. More... | |
static frame_t | createFrame (const frame_t &parent) |
Creates and returns a new sub-frame. More... | |
Protected Member Functions | |
frame_t (void *) | |
Friends | |
class | symbol_t |
A reference to a frame.
A frame is an ordered collection of symbols (see also symbol_t). Frames can only be accessed via an instance of frame_t. Internally, frames are reference counted and do not need to be deallocated manually.
A frame can either be a root-frame or a sub-frame. Sub-frames have a parent frame; root frames do not. When a symbol name cannot be resolved in the current frame, it is resolved recursively in the parent frame.
Frames are constructed using one of the static factory methods of frame_t.
In order to avoid cyclic references no counted reference to the parent frame is maintained. Hence, the existence of the parent frame must be ensured by other means throughout the lifetime of the sub-frame.
|
protected |
frame_t::frame_t | ( | ) |
Default constructor.
Referenced by createFrame(), and getParent().
frame_t::frame_t | ( | const frame_t & | frame | ) |
Copy constructor.
frame_t::~frame_t | ( | ) |
Destructor.
void frame_t::add | ( | symbol_t | symbol | ) |
Add all symbols from the given frame.
Add symbol.
Notice that the symbol will be in two frames at the same time, but the symbol will only "point back" to the first frame it was added to.
References UTAP::symbol_t::getName().
Referenced by add(), UTAP::TimedAutomataSystem::addDynamicTemplate(), UTAP::TimedAutomataSystem::addInstance(), UTAP::TimedAutomataSystem::addLscInstance(), UTAP::instanceLine_t::addParameters(), UTAP::TimedAutomataSystem::addTemplate(), UTAP::TimedAutomataSystem::copyVariablesFromTo(), UTAP::SystemBuilder::instanceNameBegin(), UTAP::SystemBuilder::instantiationBegin(), moveTo(), and remove().
void frame_t::add | ( | frame_t | frame | ) |
Adds a symbol of the given name and type to the frame.
References UTAP::symbol_t::getName(), and UTAP::symbol().
Referenced by UTAP::TimedAutomataSystem::addDynamicTemplate(), UTAP::TimedAutomataSystem::addInstance(), UTAP::TimedAutomataSystem::addLscInstance(), UTAP::TimedAutomataSystem::addProcess(), UTAP::SystemBuilder::addSelectSymbolToFrame(), UTAP::TimedAutomataSystem::addTemplate(), UTAP::StatementBuilder::declParameter(), and UTAP::SystemBuilder::instanceName().
|
static |
Creates and returns a new root-frame.
References frame_t().
Referenced by UTAP::TimedAutomataSystem::addDynamicTemplate(), UTAP::TimedAutomataSystem::addTemplate(), UTAP::StatementBuilder::blockBegin(), UTAP::SystemBuilder::declDynamicTemplate(), UTAP::StatementBuilder::declFuncBegin(), UTAP::ExpressionBuilder::exprExistsDynamicBegin(), UTAP::ExpressionBuilder::exprForAllBegin(), UTAP::ExpressionBuilder::exprForAllDynamicBegin(), UTAP::ExpressionBuilder::exprForeachDynamicBegin(), UTAP::ExpressionBuilder::exprSumDynamicBegin(), UTAP::SystemBuilder::ganttDeclStart(), UTAP::SystemBuilder::ganttEntryStart(), UTAP::SystemBuilder::instanceNameBegin(), UTAP::SystemBuilder::instantiationBegin(), UTAP::StatementBuilder::iterationBegin(), UTAP::SystemBuilder::procBegin(), UTAP::SystemBuilder::procEdgeBegin(), UTAP::StatementBuilder::StatementBuilder(), and UTAP::TimedAutomataSystem::TimedAutomataSystem().
Creates and returns a new sub-frame.
References frame_t().
bool UTAP::frame_t::empty | ( | ) |
int32_t UTAP::frame_t::getIndexOf | ( | std::string | name | ) | const |
Returns the index of the symbol with the given name.
Referenced by UTAP::SignalFlow::checkParams(), and resolve().
int32_t frame_t::getIndexOf | ( | symbol_t | symbol | ) | const |
Returns the index of a symbol or -1 if not present.
frame_t frame_t::getParent | ( | ) | ||
throw | ( | NoParentException | ||
) |
uint32_t frame_t::getSize | ( | ) | const |
Returns the number of symbols in this frame.
Referenced by UTAP::TimedAutomataSystem::accept(), add(), UTAP::TimedAutomataSystem::addDynamicTemplate(), UTAP::TimedAutomataSystem::addInstance(), UTAP::TimedAutomataSystem::addLscInstance(), UTAP::instanceLine_t::addParameters(), UTAP::TimedAutomataSystem::addTemplate(), UTAP::TypeChecker::checkExpression(), UTAP::type_t::createInstance(), UTAP::type_t::createLscInstance(), UTAP::type_t::createProcess(), UTAP::SystemBuilder::declDynamicTemplate(), UTAP::StatementBuilder::declFuncBegin(), UTAP::SystemBuilder::instanceName(), UTAP::SystemBuilder::instantiationEnd(), UTAP::XMLWriter::labels(), operator<<(), UTAP::SystemBuilder::procBegin(), visit(), UTAP::TypeChecker::visitBlockStatement(), UTAP::ExpressionVisitor::visitBlockStatement(), UTAP::TypeChecker::visitEdge(), UTAP::TypeChecker::visitGanttChart(), and UTAP::CompileTimeComputableValues::visitInstance().
symbol_t frame_t::getSymbol | ( | int32_t | n | ) |
Returns the Nth symbol in this frame.
bool frame_t::hasParent | ( | ) | const |
Returns true if this frame has a parent.
Referenced by UTAP::SignalFlow::visitExpression().
void frame_t::moveTo | ( | frame_t | frame | ) |
Move all symbols from this to a given one (leaving this empty).
Move all symbols from this to the given frame.
Notice that the symbols will be updated to point to the given frame, while this frame will be emptied and ready for recycling.
References add(), and UTAP::symbol().
Referenced by UTAP::StatementBuilder::declFuncBegin().
bool frame_t::operator!= | ( | const frame_t & | frame | ) | const |
Inequality operator.
bool frame_t::operator== | ( | const frame_t & | frame | ) | const |
Equality operator.
symbol_t frame_t::operator[] | ( | int32_t | n | ) |
Returns the Nth symbol in this frame.
const symbol_t frame_t::operator[] | ( | int32_t | n | ) | const |
Returns the Nth symbol in this frame.
void frame_t::remove | ( | symbol_t | s | ) |
removes the given symbol
References add(), and UTAP::symbol().
Referenced by UTAP::TimedAutomataSystem::removeProcess().
bool frame_t::resolve | ( | std::string | name, |
symbol_t & | symbol | ||
) |
Resolves a name in this frame or a parent frame.
Resolves the name in this frame or the parent frame and returns the corresponding symbol.
References getIndexOf(), and getParent().
Referenced by UTAP::expression_t::deeperClone().
std::string UTAP::frame_t::toString | ( | ) |
|
friend |