#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 | 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.
|
Default constructor. Creates an empty expression. |
|
Copy constructor.
|
|
Destructor.
|
|
True if this expression can change any of the variables identified by the given symbols.
|
|
Make a shallow clone of the expression.
|
|
|
|
|
|
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.
|
|
Equality 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 of a variable reference. The expression must be a left-hand side value. In case of dot-expressions, the member field is returned. In case of an inline if, the 'true' branch is returned. (a=1).getSymbol() returns 'a' (s.f).getSymbol() returns 'f' (i<1?j:k).getSymbol() returns 'j' |
|
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' |
|
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.
|
|
Less-than operator. Makes it possible to put expression_t objects into an STL set. |
|
Assignment operator.
|
|
Equallity operator. Returns true if the two references point to the same expression object. |
|
Returns the ith subexpression.
|
|
Returns the ith subexpression.
|
|
Sets the type of the expression.
|
|
|
|
Returns a string representation of the expression.
|