#include <expression.hh>
Public Member Functions | |
expression_t () | |
Default constructor. | |
expression_t (const expression_t &) | |
Copy constructor. | |
~expression_t () | |
Destructor. | |
Constants::kind_t | getKind () const |
Returns the kind of the expression. | |
uint32_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. | |
char * | 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 |
Equallity operator. | |
symbol_t | getSymbol () |
Returns the symbol this expression evaluates to. | |
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 | dependsOn (const std::set< symbol_t > &) const |
True if the evaluation of this expression depends on any of the symbols in the given set. | |
Static Public Member Functions | |
expression_t | createConstant (const position_t &, int32_t) |
Create a CONSTANT expression. | |
expression_t | createIdentifier (const position_t &, symbol_t) |
Create an IDENTIFIER expression. | |
expression_t | createUnary (const position_t &, Constants::kind_t, expression_t, type_t=type_t::UNKNOWN) |
Create a unary expression. | |
expression_t | createBinary (const position_t &, Constants::kind_t, expression_t, expression_t, type_t=type_t::UNKNOWN) |
Create a binary expression. | |
expression_t | createTernary (const position_t &, Constants::kind_t, expression_t, expression_t, expression_t, type_t=type_t::UNKNOWN) |
Create a ternary expression. | |
expression_t | createNary (const position_t &, Constants::kind_t, const std::vector< expression_t > &, type_t=type_t::UNKNOWN) |
Create an n-ary expression. | |
expression_t | createDot (const position_t &, expression_t, int32_t=-1, type_t=type_t::UNKNOWN) |
Create a DOT expression. | |
expression_t | createSync (const position_t &, expression_t, Constants::synchronisation_t) |
Create a SYNC expression. | |
expression_t | createDeadlock (const 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.
|
Default constructor. Creates an empty expression. |
|
Copy constructor.
|
|
Destructor.
|
|
True if this expression can change any of the variables identified by the given symbols.
|
|
Create a binary expression.
|
|
Create a CONSTANT expression.
|
|
Create a DEADLOCK expression.
|
|
Create a DOT expression.
|
|
Create an IDENTIFIER expression.
|
|
Create an n-ary expression.
|
|
Create a SYNC expression.
|
|
Create a ternary expression.
|
|
Create a unary expression.
|
|
True if the evaluation of this expression depends on any of the symbols in the given set.
|
|
Returns true if this is an empty expression.
|
|
Equallity operator.
|
|
Returns the ith subexpression.
|
|
Returns the ith subexpression.
|
|
Returns the index field of this expression.
|
|
Returns the kind of the expression.
|
|
Returns the position of this expression.
|
|
Returns the number of subexpression.
|
|
Returns the symbol this expression evaluates to. Notice that not all expression evaluate to a symbol. |
|
Returns the symbol this expression evaluates to. Notice that not all expression evaluate to a symbol. |
|
Returns the synchronisation type of SYNC operations.
|
|
Returns the type of the expression.
|
|
Returns the value field of this expression. This call is not valid for all expressions. |
|
Returns true if this expression is a reference to a symbol in the given set. NOTE: This method does not use the getSymbol() call, since that one always returns the 'true' result of an inline if. |
|
Assignment operator.
|
|
Returns the ith subexpression.
|
|
Returns the ith subexpression.
|
|
Sets the type of the expression.
|
|
Returns a string representation of the expression. The string returned must be deallocated with delete[]. Returns NULL is the expression is empty. |