DiaDes  0.1
DIAgnosisofDiscrete-EventSystem
Public Types | Public Member Functions | Private Attributes | Friends | List of all members
Diades::Altarica::CaseExpression Class Reference

#include <Expression.hh>

Inheritance diagram for Diades::Altarica::CaseExpression:
Inheritance graph

Public Types

typedef ExprVector::size_type AlternativeIndex
 
- Public Types inherited from Diades::Altarica::Expression
enum  Category {
  IfThenElse =0, Case =1, Or =2, And =3,
  Eq =4, Neq =5, Imply =6, Lt =7,
  Gt =8, Leq =9, Geq =10, Add =11,
  Sub =12, Mul =13, Div =14, Mod =15,
  Neg =16, Not =17, Paren =18, StructMember =19,
  ArrayMember =20, Var =21, Id =22, Min =23,
  Max =24, True =25, False =26, Integer =27,
  ForAll =28, Exist =29, FunctionCall =30, Struct =31,
  Array =32
}
 
typedef reference_wrapper< Expression const > ConstReference
 
typedef reference_wrapper< ExpressionReference
 
typedef std::vector< ConstReferenceExprVector
 
typedef Utils::Exception< ExpressionException
 
typedef std::vector< VariableDecl::ConstReference >::const_iterator VariableIterator
 
typedef std::vector< VariableDecl::ConstReference >::size_type SizeType
 
typedef std::vector< VariableDecl::ConstReferenceSupport
 

Public Member Functions

 CaseExpression (const NodeDecl &owner, unsigned id, const ExprVector &choices, const ExprVector &expressions)
 
AlternativeIndex first () const
 
AlternativeIndex last () const
 
const ExpressiongetAlternative (AlternativeIndex index) const
 
const ExpressiongetAlternativeExpression (AlternativeIndex index) const
 
const ExpressiondefaultCase () const
 
virtual bool valid () const
 
Category category () const
 
virtual const TypevalueType () const
 
virtual bool isConstant () const
 
virtual ~CaseExpression ()
 
- Public Member Functions inherited from Diades::Altarica::Expression
virtual ~Expression ()
 
const AltaricaModelmodel () const
 
const NodeDeclowner () const
 
bool operator== (const Expression &e) const
 
 Expression (const NodeDecl &owner, unsigned id)
 
unsigned id () const
 
VariableIterator variableBegin () const
 
VariableIterator variableEnd () const
 
SizeType supportSize () const
 
const Supportsupport () const
 

Private Attributes

ExprVector _choices
 
ExprVector _expressions
 

Friends

ostream & operator<< (ostream &os, const Expression &expression)
 

Additional Inherited Members

- Static Public Member Functions inherited from Diades::Altarica::Expression
static string typeName ()
 
- Protected Attributes inherited from Diades::Altarica::Expression
Support _varSupport
 
const NodeDecl_owner
 VariableDecls that are supporting the Expression. More...
 
unsigned _id
 

Detailed Description

The class represents a case expression. Each alternative is implemented as an Expression in vector _choices and each alternative resulting expression is implemented as an Expression in a vector _expressions. The default case is the last Expression in _expressions which means that _choices.size() = _expressions.size()-1

Definition at line 283 of file Expression.hh.

Member Typedef Documentation

◆ AlternativeIndex

Definition at line 289 of file Expression.hh.

Constructor & Destructor Documentation

◆ CaseExpression()

Diades::Altarica::CaseExpression::CaseExpression ( const NodeDecl owner,
unsigned  id,
const ExprVector choices,
const ExprVector expressions 
)

◆ ~CaseExpression()

virtual Diades::Altarica::CaseExpression::~CaseExpression ( )
inlinevirtual

Definition at line 347 of file Expression.hh.

References Diades::Altarica::Expression::operator<<.

Member Function Documentation

◆ category()

Category Diades::Altarica::CaseExpression::category ( ) const
inlinevirtual

Expression evaluation: this operation evaluates the expression with the current value associated to the variables that support the Expression. The evaluation is failing if there is a variable of the support that is still free (that is an unassigned variable).

Parameters
valuethe Value resulting from the evaluation of the current Expression.
Returns
true if the operation succeeds, false otherwise.Category of an expression
the category o of the Expression. It is way to avoid the use of RTTI and gets a lighter implementation.

Implements Diades::Altarica::Expression.

Definition at line 326 of file Expression.hh.

References Diades::Altarica::Expression::Case.

◆ defaultCase()

const Expression& Diades::Altarica::CaseExpression::defaultCase ( ) const
inline

Definition at line 310 of file Expression.hh.

◆ first()

AlternativeIndex Diades::Altarica::CaseExpression::first ( ) const
inline

Definition at line 293 of file Expression.hh.

◆ getAlternative()

const Expression& Diades::Altarica::CaseExpression::getAlternative ( AlternativeIndex  index) const
inline

Definition at line 301 of file Expression.hh.

◆ getAlternativeExpression()

const Expression& Diades::Altarica::CaseExpression::getAlternativeExpression ( AlternativeIndex  index) const
inline

Definition at line 305 of file Expression.hh.

◆ isConstant()

virtual bool Diades::Altarica::CaseExpression::isConstant ( ) const
inlinevirtual
Returns
true if the Expression is constant

Implements Diades::Altarica::Expression.

Definition at line 335 of file Expression.hh.

◆ last()

AlternativeIndex Diades::Altarica::CaseExpression::last ( ) const
inline

Definition at line 297 of file Expression.hh.

◆ valid()

virtual bool Diades::Altarica::CaseExpression::valid ( ) const
inlinevirtual

Validity of an Expression

Returns
true if the current Expression is valid.

Implements Diades::Altarica::Expression.

Definition at line 311 of file Expression.hh.

◆ valueType()

virtual const Type& Diades::Altarica::CaseExpression::valueType ( ) const
inlinevirtual

Type of the Value returned by the Expression (lazy computation)

Returns
the Type of the Value.

Implements Diades::Altarica::Expression.

Definition at line 328 of file Expression.hh.

Friends And Related Function Documentation

◆ operator<<

ostream& operator<< ( ostream &  os,
const Expression expression 
)
friend

Member Data Documentation

◆ _choices

ExprVector Diades::Altarica::CaseExpression::_choices
private

Definition at line 286 of file Expression.hh.

◆ _expressions

ExprVector Diades::Altarica::CaseExpression::_expressions
private

Definition at line 287 of file Expression.hh.


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