#include <expression.h>
Public Member Functions | |
expression_t () | |
Default constructor. | |
expression_t (const expression_t &) | |
Copy constructor. | |
~expression_t () | |
Destructor. | |
expression_t | clone () const |
Make a shallow clone of the expression. | |
Constants::kind_t | getKind () const |
Returns the kind of the expression. | |
size_t | getSize () const |
Returns the number of subexpression. | |
const position_t & | getPosition () const |
Returns the position of this expression. | |
type_t | getType () const |
Returns the type of the expression. | |
void | setType (type_t) |
Sets the type of the expression. | |
int32_t | getValue () const |
Returns the value field of this expression. | |
int32_t | getIndex () const |
Returns the index field of this expression. | |
bool | empty () const |
Returns true if this is an empty expression. | |
Constants::synchronisation_t | getSync () const |
Returns the synchronisation type of SYNC operations. | |
std::string | toString (bool old=false) const |
Returns a string representation of the expression. | |
expression_t & | operator[] (uint32_t) |
Returns the ith subexpression. | |
const expression_t | operator[] (uint32_t) const |
Returns the ith subexpression. | |
expression_t & | get (uint32_t) |
Returns the ith subexpression. | |
const expression_t & | get (uint32_t) const |
Returns the ith subexpression. | |
expression_t & | operator= (const expression_t &) |
Assignment operator. | |
bool | equal (const expression_t &) const |
Equality operator. | |
symbol_t | getSymbol () |
Returns the symbol of a variable reference. | |
void | getSymbols (std::set< symbol_t > &symbols) const |
Returns the set of symbols this expression might resolve into. | |
const symbol_t | getSymbol () const |
Returns the symbol this expression evaluates to. | |
bool | isReferenceTo (const std::set< symbol_t > &) const |
Returns true if this expression is a reference to a symbol in the given set. | |
bool | changesVariable (const std::set< symbol_t > &) const |
True if this expression can change any of the variables identified by the given symbols. | |
bool | changesAnyVariable () const |
True if this expression can change any variable at all. | |
bool | dependsOn (const std::set< symbol_t > &) const |
True if the evaluation of this expression depends on any of the symbols in the given set. | |
void | collectPossibleWrites (std::set< symbol_t > &) const |
void | collectPossibleReads (std::set< symbol_t > &) const |
bool | operator< (const expression_t) const |
Less-than operator. | |
bool | operator== (const expression_t) const |
Equallity operator. | |
expression_t | subst (symbol_t, expression_t) const |
Static Public Member Functions | |
static int | getPrecedence (Constants::kind_t) |
static expression_t | createConstant (int32_t, position_t=position_t()) |
Create a CONSTANT expression. | |
static expression_t | createIdentifier (symbol_t, position_t=position_t()) |
Create an IDENTIFIER expression. | |
static expression_t | createUnary (Constants::kind_t, expression_t, position_t=position_t(), type_t=type_t()) |
Create a unary expression. | |
static expression_t | createBinary (Constants::kind_t, expression_t, expression_t, position_t=position_t(), type_t=type_t()) |
Create a binary expression. | |
static expression_t | createTernary (Constants::kind_t, expression_t, expression_t, expression_t, position_t=position_t(), type_t=type_t()) |
Create a ternary expression. | |
static expression_t | createNary (Constants::kind_t, const std::vector< expression_t > &, position_t=position_t(), type_t=type_t()) |
Create an n-ary expression. | |
static expression_t | createDot (expression_t, int32_t=-1, position_t=position_t(), type_t=type_t()) |
Create a DOT expression. | |
static expression_t | createSync (expression_t, Constants::synchronisation_t, position_t=position_t()) |
Create a SYNC expression. | |
static expression_t | createDeadlock (position_t=position_t()) |
Create a DEADLOCK expression. |
An expression is a tree of operations and is identified by the root of the tree. There are many kinds of operations (see kind_t), some are leafs in the tree (identifers, constants), some are unary operations (unary minus, negation), some are binary (plus, minus, etc.), and some are n-ary (lists, function calls).
Expressions can be annotated with types. The type of an expression should never contain information about whether the expression is a variable reference, a constant value or about the range of the result value. Use the TypeChecker and RangeChecker classes to determine these informations.
All nodes have the following attributes:
kind indicates the kind of operation position indicates the position of the expression in the input file. type the type of the result of evaluating the expression size the number of subexpressions sub the subexpressions
Some nodes have extra attributes (depending on the kind):
value the value of a CONSTANT node sync the synchronisation of a SYNC node index the index of a DOT node symbol the symbol of an IDENTIFIER node
Expressions are created by using the static factory methods.
UTAP::expression_t::expression_t | ( | ) |
Default constructor.
Creates an empty expression.
UTAP::expression_t::expression_t | ( | const expression_t & | ) |
Copy constructor.
UTAP::expression_t::~expression_t | ( | ) |
Destructor.
bool UTAP::expression_t::changesAnyVariable | ( | ) | const |
True if this expression can change any variable at all.
bool UTAP::expression_t::changesVariable | ( | const std::set< symbol_t > & | ) | const |
True if this expression can change any of the variables identified by the given symbols.
expression_t UTAP::expression_t::clone | ( | ) | const |
Make a shallow clone of the expression.
void UTAP::expression_t::collectPossibleReads | ( | std::set< symbol_t > & | ) | const |
void UTAP::expression_t::collectPossibleWrites | ( | std::set< symbol_t > & | ) | const |
static expression_t UTAP::expression_t::createBinary | ( | Constants::kind_t | , | |
expression_t | , | |||
expression_t | , | |||
position_t | = position_t() , |
|||
type_t | = type_t() | |||
) | [static] |
Create a binary expression.
static expression_t UTAP::expression_t::createConstant | ( | int32_t | , | |
position_t | = position_t() | |||
) | [static] |
Create a CONSTANT expression.
static expression_t UTAP::expression_t::createDeadlock | ( | position_t | = position_t() |
) | [static] |
Create a DEADLOCK expression.
static expression_t UTAP::expression_t::createDot | ( | expression_t | , | |
int32_t | = -1 , |
|||
position_t | = position_t() , |
|||
type_t | = type_t() | |||
) | [static] |
Create a DOT expression.
static expression_t UTAP::expression_t::createIdentifier | ( | symbol_t | , | |
position_t | = position_t() | |||
) | [static] |
Create an IDENTIFIER expression.
static expression_t UTAP::expression_t::createNary | ( | Constants::kind_t | , | |
const std::vector< expression_t > & | , | |||
position_t | = position_t() , |
|||
type_t | = type_t() | |||
) | [static] |
Create an n-ary expression.
static expression_t UTAP::expression_t::createSync | ( | expression_t | , | |
Constants::synchronisation_t | , | |||
position_t | = position_t() | |||
) | [static] |
Create a SYNC expression.
static expression_t UTAP::expression_t::createTernary | ( | Constants::kind_t | , | |
expression_t | , | |||
expression_t | , | |||
expression_t | , | |||
position_t | = position_t() , |
|||
type_t | = type_t() | |||
) | [static] |
Create a ternary expression.
static expression_t UTAP::expression_t::createUnary | ( | Constants::kind_t | , | |
expression_t | , | |||
position_t | = position_t() , |
|||
type_t | = type_t() | |||
) | [static] |
Create a unary expression.
bool UTAP::expression_t::dependsOn | ( | const std::set< symbol_t > & | ) | const |
True if the evaluation of this expression depends on any of the symbols in the given set.
bool UTAP::expression_t::empty | ( | ) | const |
Returns true if this is an empty expression.
bool UTAP::expression_t::equal | ( | const expression_t & | ) | const |
Equality operator.
const expression_t& UTAP::expression_t::get | ( | uint32_t | ) | const |
Returns the ith subexpression.
expression_t& UTAP::expression_t::get | ( | uint32_t | ) |
Returns the ith subexpression.
int32_t UTAP::expression_t::getIndex | ( | ) | const |
Returns the index field of this expression.
Constants::kind_t UTAP::expression_t::getKind | ( | ) | const |
Returns the kind of the expression.
const position_t& UTAP::expression_t::getPosition | ( | ) | const |
Returns the position of this expression.
static int UTAP::expression_t::getPrecedence | ( | Constants::kind_t | ) | [static] |
size_t UTAP::expression_t::getSize | ( | ) | const |
Returns the number of subexpression.
const symbol_t UTAP::expression_t::getSymbol | ( | ) | const |
Returns the symbol this expression evaluates to.
Notice that not all expression evaluate to a symbol.
symbol_t UTAP::expression_t::getSymbol | ( | ) |
Returns the symbol of a variable reference.
The expression must be a left-hand side value. In case of dot-expressions, the record/process symbol is returned. In case of an inline if, the 'true' branch is returned.
(a=1).getSymbol() returns 'a' (s.f).getSymbol() returns 's' (i<1?j:k).getSymbol() returns 'j'
void UTAP::expression_t::getSymbols | ( | std::set< symbol_t > & | symbols | ) | const |
Returns the set of symbols this expression might resolve into.
In case of inline if, both the 'true' and 'false' branch is added. In case of dot-expressions, both the left hand reference and the member field are returned.
(a=1).getSymbol() returns 'a' (s.f).getSymbol() returns 's,f' (i<1?j:k).getSymbol() returns 'j,k'
Constants::synchronisation_t UTAP::expression_t::getSync | ( | ) | const |
Returns the synchronisation type of SYNC operations.
type_t UTAP::expression_t::getType | ( | ) | const |
Returns the type of the expression.
int32_t UTAP::expression_t::getValue | ( | ) | const |
Returns the value field of this expression.
This call is not valid for all expressions.
bool UTAP::expression_t::isReferenceTo | ( | const std::set< symbol_t > & | ) | const |
Returns true if this expression is a reference to a symbol in the given set.
bool UTAP::expression_t::operator< | ( | const | expression_t | ) | const |
Less-than operator.
Makes it possible to put expression_t objects into an STL set.
expression_t& UTAP::expression_t::operator= | ( | const expression_t & | ) |
Assignment operator.
bool UTAP::expression_t::operator== | ( | const | expression_t | ) | const |
Equallity operator.
Returns true if the two references point to the same expression object.
const expression_t UTAP::expression_t::operator[] | ( | uint32_t | ) | const |
Returns the ith subexpression.
expression_t& UTAP::expression_t::operator[] | ( | uint32_t | ) |
Returns the ith subexpression.
void UTAP::expression_t::setType | ( | type_t | ) |
Sets the type of the expression.
expression_t UTAP::expression_t::subst | ( | symbol_t | , | |
expression_t | ||||
) | const |
std::string UTAP::expression_t::toString | ( | bool | old = false |
) | const |
Returns a string representation of the expression.