libutap
Public Member Functions | Static Public Member Functions | List of all members
UTAP::expression_t Class Reference

A reference to an expression. More...

#include <expression.h>

Public Member Functions

 expression_t ()
 Default constructor. More...
 
 expression_t (const expression_t &)
 Copy constructor. More...
 
 ~expression_t ()
 Destructor. More...
 
bool usesFP () const
 
bool usesClock () const
 
bool isDynamic () const
 
bool hasDynamicSub () const
 
expression_t clone () const
 Make a shallow clone of the expression. More...
 
expression_t deeperClone () const
 Makes a deep clone of the expression. More...
 
expression_t deeperClone (symbol_t from, symbol_t to) const
 Makes a deep clone of the expression and replaces the symbol "from" with the symbol "to". More...
 
expression_t deeperClone (frame_t frame, frame_t select=frame_t()) const
 Makes a deep clone of the expression and replaces each symbol with a symbol from the given frame(s), with the same name. More...
 
Constants::kind_t getKind () const
 Returns the kind of the expression. More...
 
size_t getSize () const
 Returns the number of subexpression. More...
 
const position_tgetPosition () const
 Returns the position of this expression. More...
 
type_t getType () const
 Returns the type of the expression. More...
 
void setType (type_t)
 Sets the type of the expression. More...
 
int32_t getValue () const
 Returns the value field of this expression. More...
 
int32_t getIndex () const
 Returns the index field of this expression. More...
 
double getDoubleValue () const
 Returns the value field of this expression. More...
 
bool empty () const
 Returns true if this is an empty expression. More...
 
Constants::synchronisation_t getSync () const
 Returns the synchronisation type of SYNC operations. More...
 
std::string toString (bool old=false) const
 Returns a string representation of the expression. More...
 
expression_toperator[] (uint32_t)
 Returns the ith subexpression. More...
 
const expression_t operator[] (uint32_t) const
 Returns the ith subexpression. More...
 
expression_tget (uint32_t)
 Returns the ith subexpression. More...
 
const expression_tget (uint32_t) const
 Returns the ith subexpression. More...
 
expression_toperator= (const expression_t &)
 Assignment operator. More...
 
bool equal (const expression_t &) const
 Equality operator. More...
 
symbol_t getSymbol ()
 Returns the symbol of a variable reference. More...
 
void getSymbols (std::set< symbol_t > &symbols) const
 Returns the set of symbols this expression might resolve into. More...
 
const symbol_t getSymbol () const
 Returns the symbol this expression evaluates to. More...
 
bool isReferenceTo (const std::set< symbol_t > &) const
 Returns true if this expression is a reference to a symbol in the given set. More...
 
bool changesVariable (const std::set< symbol_t > &) const
 True if this expression can change any of the variables identified by the given symbols. More...
 
bool changesAnyVariable () const
 True if this expression can change any variable at all. More...
 
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. More...
 
void collectPossibleWrites (std::set< symbol_t > &) const
 
void collectPossibleReads (std::set< symbol_t > &, bool collectRandom=false) const
 
bool operator< (const expression_t) const
 Less-than operator. More...
 
bool operator== (const expression_t) const
 Equality operator. More...
 
expression_t subst (symbol_t, expression_t) const
 
bool isTrue () 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. More...
 
static expression_t createDouble (double, position_t=position_t())
 
static expression_t createIdentifier (symbol_t, position_t=position_t())
 Create an IDENTIFIER expression. More...
 
static expression_t createUnary (Constants::kind_t, expression_t, position_t=position_t(), type_t=type_t())
 Create a unary expression. More...
 
static expression_t createBinary (Constants::kind_t, expression_t, expression_t, position_t=position_t(), type_t=type_t())
 Create a binary expression. More...
 
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. More...
 
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. More...
 
static expression_t createDot (expression_t, int32_t=-1, position_t=position_t(), type_t=type_t())
 Create a DOT expression. More...
 
static expression_t createSync (expression_t, Constants::synchronisation_t, position_t=position_t())
 Create a SYNC expression. More...
 
static expression_t createDeadlock (position_t=position_t())
 Create a DEADLOCK expression. More...
 
static expression_t createExit (position_t=position_t())
 

Detailed Description

A reference to an 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.

Constructor & Destructor Documentation

expression_t::expression_t ( )

Default constructor.

Creates an empty expression.

expression_t::expression_t ( const expression_t e)

Copy constructor.

expression_t::~expression_t ( )

Destructor.

Member Function Documentation

bool expression_t::changesAnyVariable ( ) const
bool expression_t::changesVariable ( const std::set< symbol_t > &  symbols) const

True if this expression can change any of the variables identified by the given symbols.

expression_t expression_t::clone ( ) const

Make a shallow clone of the expression.

Referenced by UTAP::ExpressionBuilder::exprExistsDynamicEnd(), and UTAP::ExpressionBuilder::exprForAllDynamicEnd().

void expression_t::collectPossibleReads ( std::set< symbol_t > &  ,
bool  collectRandom = false 
) const
void expression_t::collectPossibleWrites ( std::set< symbol_t > &  ) const
expression_t expression_t::createBinary ( Constants::kind_t  kind,
expression_t  left,
expression_t  right,
position_t  pos = position_t(),
type_t  type = type_t() 
)
static
expression_t expression_t::createConstant ( int32_t  value,
position_t  pos = position_t() 
)
static
expression_t expression_t::createDeadlock ( position_t  pos = position_t())
static
expression_t expression_t::createDot ( expression_t  e,
int32_t  idx = -1,
position_t  pos = position_t(),
type_t  type = type_t() 
)
static
expression_t expression_t::createDouble ( double  value,
position_t  pos = position_t() 
)
static
expression_t expression_t::createExit ( position_t  pos = position_t())
static
expression_t expression_t::createIdentifier ( symbol_t  symbol,
position_t  pos = position_t() 
)
static
expression_t expression_t::createNary ( Constants::kind_t  ,
const std::vector< expression_t > &  ,
position_t  = position_t(),
type_t  = type_t() 
)
static
expression_t expression_t::createSync ( expression_t  e,
Constants::synchronisation_t  s,
position_t  pos = position_t() 
)
static

Create a SYNC expression.

References UTAP::Constants::SYNC.

Referenced by UTAP::SystemBuilder::procMessage(), and UTAP::SystemBuilder::procSync().

expression_t expression_t::createTernary ( Constants::kind_t  kind,
expression_t  e1,
expression_t  e2,
expression_t  e3,
position_t  pos = position_t(),
type_t  type = type_t() 
)
static
expression_t expression_t::createUnary ( Constants::kind_t  kind,
expression_t  sub,
position_t  pos = position_t(),
type_t  type = type_t() 
)
static
expression_t expression_t::deeperClone ( ) const

Makes a deep clone of the expression.

expression_t expression_t::deeperClone ( symbol_t  from,
symbol_t  to 
) const

Makes a deep clone of the expression and replaces the symbol "from" with the symbol "to".

expression_t expression_t::deeperClone ( frame_t  frame,
frame_t  select = frame_t() 
) const

Makes a deep clone of the expression and replaces each symbol with a symbol from the given frame(s), with the same name.

References UTAP::frame_t::resolve().

bool expression_t::dependsOn ( const std::set< symbol_t > &  symbols) const

True if the evaluation of this expression depends on any of the symbols in the given set.

bool expression_t::empty ( ) const
bool expression_t::equal ( const expression_t e) const

Equality operator.

Two expressions are identical iff all the sub expressions are identical and if the kind, value and symbol of the root are identical.

References getSize().

expression_t & expression_t::get ( uint32_t  i)
const expression_t & expression_t::get ( uint32_t  i) const

Returns the ith subexpression.

double expression_t::getDoubleValue ( ) const

Returns the value field of this expression.

This call is not valid for all expressions.

References UTAP::Constants::CONSTANT, and UTAP::Constants::DOUBLE.

int32_t expression_t::getIndex ( ) const

Returns the index field of this expression.

References UTAP::Constants::DOT.

kind_t expression_t::getKind ( ) const
const position_t & expression_t::getPosition ( ) const

Returns the position of this expression.

int expression_t::getPrecedence ( Constants::kind_t  kind)
static

References UTAP::Constants::A_BUCHI, UTAP::Constants::A_UNTIL, UTAP::Constants::A_WEAKUNTIL, UTAP::Constants::AF, UTAP::Constants::AG, UTAP::Constants::AG_R_Piotr, UTAP::Constants::AND, UTAP::Constants::ARRAY, UTAP::Constants::ASSAND, UTAP::Constants::ASSDIV, UTAP::Constants::ASSIGN, UTAP::Constants::ASSLSHIFT, UTAP::Constants::ASSMINUS, UTAP::Constants::ASSMOD, UTAP::Constants::ASSMULT, UTAP::Constants::ASSOR, UTAP::Constants::ASSPLUS, UTAP::Constants::ASSRSHIFT, UTAP::Constants::ASSXOR, UTAP::Constants::BIT_AND, UTAP::Constants::BIT_LSHIFT, UTAP::Constants::BIT_OR, UTAP::Constants::BIT_RSHIFT, UTAP::Constants::BIT_XOR, UTAP::Constants::CEIL_F, UTAP::Constants::COMMA, UTAP::Constants::CONSISTENCY, UTAP::Constants::CONSTANT, UTAP::Constants::CONTROL, UTAP::Constants::CONTROL_TOPT, UTAP::Constants::CONTROL_TOPT_DEF1, UTAP::Constants::CONTROL_TOPT_DEF2, UTAP::Constants::COS_F, UTAP::Constants::DEADLOCK, UTAP::Constants::DIV, UTAP::Constants::DOT, UTAP::Constants::DYNAMICEVAL, UTAP::Constants::EF, UTAP::Constants::EF_CONTROL, UTAP::Constants::EF_R_Piotr, UTAP::Constants::EG, UTAP::Constants::EQ, UTAP::Constants::EXISTS, UTAP::Constants::EXISTSDYNAMIC, UTAP::Constants::EXIT, UTAP::Constants::EXP_F, UTAP::Constants::FABS_F, UTAP::Constants::FLOOR_F, UTAP::Constants::FORALL, UTAP::Constants::FORALLDYNAMIC, UTAP::Constants::FOREACHDYNAMIC, UTAP::Constants::FRACTION, UTAP::Constants::FUNCALL, UTAP::Constants::GE, UTAP::Constants::GT, UTAP::Constants::IDENTIFIER, UTAP::Constants::IMPLEMENTATION, UTAP::Constants::INF_VAR, UTAP::Constants::INLINEIF, UTAP::Constants::LE, UTAP::Constants::LEADSTO, UTAP::Constants::LIST, UTAP::Constants::LN_F, UTAP::Constants::LOG_F, UTAP::Constants::LT, UTAP::Constants::MAX, UTAP::Constants::MIN, UTAP::Constants::MINUS, UTAP::Constants::MITLATOM, UTAP::Constants::MITLCONJ, UTAP::Constants::MITLDISJ, UTAP::Constants::MITLFORMULA, UTAP::Constants::MITLNEXT, UTAP::Constants::MITLRELEASE, UTAP::Constants::MITLUNTIL, UTAP::Constants::MOD, UTAP::Constants::MULT, UTAP::Constants::NEQ, UTAP::Constants::NOT, UTAP::Constants::NUMOF, UTAP::Constants::OR, UTAP::Constants::PLUS, UTAP::Constants::PO_CONTROL, UTAP::Constants::POSTDECREMENT, UTAP::Constants::POSTINCREMENT, UTAP::Constants::POW_F, UTAP::Constants::PREDECREMENT, UTAP::Constants::PREINCREMENT, UTAP::Constants::PROBABOX, UTAP::Constants::PROBADIAMOND, UTAP::Constants::PROBAEXP, UTAP::Constants::PROBAMINBOX, UTAP::Constants::PROBAMINDIAMOND, UTAP::Constants::PROCESSVAR, UTAP::Constants::RANDOM_F, UTAP::Constants::RATE, UTAP::Constants::REFINEMENT_GE, UTAP::Constants::REFINEMENT_LE, UTAP::Constants::RESTRICT, UTAP::Constants::SCENARIO, UTAP::Constants::SCENARIO2, UTAP::Constants::SIMULATE, UTAP::Constants::SIMULATION_GE, UTAP::Constants::SIMULATION_LE, UTAP::Constants::SIN_F, UTAP::Constants::SMC_CONTROL, UTAP::Constants::SPAWN, UTAP::Constants::SPECIFICATION, UTAP::Constants::SQRT_F, UTAP::Constants::SUM, UTAP::Constants::SUMDYNAMIC, UTAP::Constants::SUP_VAR, UTAP::Constants::SYNC, UTAP::Constants::SYNTAX_COMPOSITION, UTAP::Constants::TIOCOMPOSITION, UTAP::Constants::TIOCONJUNCTION, UTAP::Constants::TIOQUOTIENT, UTAP::Constants::UNARY_MINUS, and UTAP::Constants::XOR.

size_t expression_t::getSize ( ) const

Returns the number of subexpression.

References UTAP::Constants::A_BUCHI, UTAP::Constants::A_UNTIL, UTAP::Constants::A_WEAKUNTIL, UTAP::Constants::AF, UTAP::Constants::AG, UTAP::Constants::AG_R_Piotr, UTAP::Constants::AND, UTAP::Constants::ARRAY, UTAP::Constants::ASSAND, UTAP::Constants::ASSDIV, UTAP::Constants::ASSIGN, UTAP::Constants::ASSLSHIFT, UTAP::Constants::ASSMINUS, UTAP::Constants::ASSMOD, UTAP::Constants::ASSMULT, UTAP::Constants::ASSOR, UTAP::Constants::ASSPLUS, UTAP::Constants::ASSRSHIFT, UTAP::Constants::ASSXOR, UTAP::Constants::BIT_AND, UTAP::Constants::BIT_LSHIFT, UTAP::Constants::BIT_OR, UTAP::Constants::BIT_RSHIFT, UTAP::Constants::BIT_XOR, UTAP::Constants::CEIL_F, UTAP::Constants::COMMA, UTAP::Constants::CONSISTENCY, UTAP::Constants::CONSTANT, UTAP::Constants::CONTROL, UTAP::Constants::CONTROL_TOPT, UTAP::Constants::CONTROL_TOPT_DEF1, UTAP::Constants::CONTROL_TOPT_DEF2, UTAP::Constants::COS_F, UTAP::Constants::DEADLOCK, UTAP::Constants::DIV, UTAP::Constants::DOT, UTAP::Constants::DYNAMICEVAL, UTAP::Constants::EF, UTAP::Constants::EF_CONTROL, UTAP::Constants::EF_R_Piotr, UTAP::Constants::EG, UTAP::Constants::EQ, UTAP::Constants::EXISTS, UTAP::Constants::EXISTSDYNAMIC, UTAP::Constants::EXIT, UTAP::Constants::EXP_F, UTAP::Constants::FABS_F, UTAP::Constants::FLOOR_F, UTAP::Constants::FORALL, UTAP::Constants::FORALLDYNAMIC, UTAP::Constants::FOREACHDYNAMIC, UTAP::Constants::FRACTION, UTAP::Constants::FUNCALL, UTAP::Constants::GE, UTAP::Constants::GT, UTAP::Constants::IDENTIFIER, UTAP::Constants::IMPLEMENTATION, UTAP::Constants::INF_VAR, UTAP::Constants::INLINEIF, UTAP::Constants::LE, UTAP::Constants::LEADSTO, UTAP::Constants::LIST, UTAP::Constants::LN_F, UTAP::Constants::LOG_F, UTAP::Constants::LT, UTAP::Constants::MAX, UTAP::Constants::MIN, UTAP::Constants::MINUS, UTAP::Constants::MITLATOM, UTAP::Constants::MITLCONJ, UTAP::Constants::MITLDISJ, UTAP::Constants::MITLEXISTS, UTAP::Constants::MITLFORALL, UTAP::Constants::MITLFORMULA, UTAP::Constants::MITLNEXT, UTAP::Constants::MITLRELEASE, UTAP::Constants::MITLUNTIL, UTAP::Constants::MOD, UTAP::Constants::MULT, UTAP::Constants::NEQ, UTAP::Constants::NOT, UTAP::Constants::NUMOF, UTAP::Constants::OR, UTAP::Constants::PLUS, UTAP::Constants::PMAX, UTAP::Constants::PO_CONTROL, UTAP::Constants::POSTDECREMENT, UTAP::Constants::POSTINCREMENT, UTAP::Constants::POW_F, UTAP::Constants::PREDECREMENT, UTAP::Constants::PREINCREMENT, UTAP::Constants::PROBABOX, UTAP::Constants::PROBACMP, UTAP::Constants::PROBADIAMOND, UTAP::Constants::PROBAEXP, UTAP::Constants::PROBAMINBOX, UTAP::Constants::PROBAMINDIAMOND, UTAP::Constants::RANDOM_F, UTAP::Constants::RATE, UTAP::Constants::REFINEMENT_GE, UTAP::Constants::REFINEMENT_LE, UTAP::Constants::RESTRICT, UTAP::Constants::SCENARIO, UTAP::Constants::SCENARIO2, UTAP::Constants::SIMULATE, UTAP::Constants::SIMULATEREACH, UTAP::Constants::SIMULATION_GE, UTAP::Constants::SIMULATION_LE, UTAP::Constants::SIN_F, UTAP::Constants::SMC_CONTROL, UTAP::Constants::SPAWN, UTAP::Constants::SPECIFICATION, UTAP::Constants::SQRT_F, UTAP::Constants::SUM, UTAP::Constants::SUMDYNAMIC, UTAP::Constants::SUP_VAR, UTAP::Constants::SYNC, UTAP::Constants::SYNTAX_COMPOSITION, UTAP::Constants::TIOCOMPOSITION, UTAP::Constants::TIOCONJUNCTION, UTAP::Constants::TIOQUOTIENT, UTAP::Constants::UNARY_MINUS, and UTAP::Constants::XOR.

Referenced by UTAP::TypeChecker::checkExpression(), checkIDList(), equal(), hasMITLInQuantifiedSub(), hasSpawnOrExit(), hasStrictLowerBound(), hasStrictUpperBound(), isListOfFormulas(), UTAP::SignalFlow::visitExpression(), and UTAP::TypeChecker::visitProperty().

symbol_t 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'

The expression must be a left-hand side value. The symbol returned is the symbol of the variable the expression if resulting in a reference to. NOTE: In case of inline if, the symbol referenced by the 'true' part is returned.

Referenced by UTAP::ExpressionBuilder::exprDot(), and UTAP::SignalFlow::visitExpression().

const symbol_t expression_t::getSymbol ( ) const
void 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'

References UTAP::Constants::ARRAY, UTAP::Constants::ASSAND, UTAP::Constants::ASSDIV, UTAP::Constants::ASSIGN, UTAP::Constants::ASSLSHIFT, UTAP::Constants::ASSMINUS, UTAP::Constants::ASSMOD, UTAP::Constants::ASSMULT, UTAP::Constants::ASSOR, UTAP::Constants::ASSPLUS, UTAP::Constants::ASSRSHIFT, UTAP::Constants::ASSXOR, UTAP::Constants::COMMA, UTAP::Constants::DOT, UTAP::Constants::IDENTIFIER, UTAP::Constants::INLINEIF, UTAP::Constants::PREDECREMENT, UTAP::Constants::PREINCREMENT, and UTAP::Constants::SYNC.

synchronisation_t expression_t::getSync ( ) const

Returns the synchronisation type of SYNC operations.

References UTAP::Constants::SYNC.

Referenced by UTAP::TypeChecker::visitEdge(), and UTAP::SignalFlow::visitExpression().

type_t expression_t::getType ( ) const
int32_t expression_t::getValue ( ) const

Returns the value field of this expression.

This call is not valid for all expressions.

References UTAP::Constants::CONSTANT.

Referenced by UTAP::TypeChecker::checkExpression(), and UTAP::SignalFlow::visitExpression().

bool expression_t::hasDynamicSub ( ) const
bool expression_t::isDynamic ( ) const
bool expression_t::isReferenceTo ( const std::set< symbol_t > &  symbols) const

Returns true if this expression is a reference to a symbol in the given set.

Returns true if expr might be a reference to a symbol in the set.

bool expression_t::isTrue ( ) const
bool expression_t::operator< ( const expression_t  e) const

Less-than operator.

Makes it possible to put expression_t objects into an STL set.

expression_t & expression_t::operator= ( const expression_t e)

Assignment operator.

bool expression_t::operator== ( const expression_t  e) const

Equality operator.

Returns true if the two references point to the same expression object.

expression_t & expression_t::operator[] ( uint32_t  i)

Returns the ith subexpression.

const expression_t expression_t::operator[] ( uint32_t  i) const

Returns the ith subexpression.

void expression_t::setType ( type_t  type)
expression_t expression_t::subst ( symbol_t  symbol,
expression_t  expr 
) const

References UTAP::Constants::IDENTIFIER, and subst().

Referenced by subst().

std::string expression_t::toString ( bool  old = false) const
bool expression_t::usesClock ( ) const

References isClock().

bool expression_t::usesFP ( ) const

The documentation for this class was generated from the following files: