libutap  0.93
Uppaal Timed Automata Parser
UTAP::TypeChecker Class Reference

A visitor which type checks the system it visits. More...

#include <typechecker.h>

Inheritance diagram for UTAP::TypeChecker:
Collaboration diagram for UTAP::TypeChecker:

Public Member Functions

 TypeChecker (TimedAutomataSystem *system, bool refinement=false)
 
 ~TypeChecker () override
 
void visitTemplateAfter (template_t &) override
 
bool visitTemplateBefore (template_t &) override
 
void visitSystemAfter (TimedAutomataSystem *) override
 
void visitVariable (variable_t &) override
 
void visitState (state_t &) override
 
void visitEdge (edge_t &) override
 
void visitInstance (instance_t &) override
 
virtual void visitProperty (expression_t)
 
void visitFunction (function_t &) override
 
void visitProgressMeasure (progress_t &) override
 
virtual void visitHybridClock (expression_t)
 
void visitIODecl (iodecl_t &) override
 
void visitGanttChart (gantt_t &) override
 
void visitProcess (instance_t &) override
 
void visitInstanceLine (instanceLine_t &) override
 
void visitMessage (message_t &) override
 
void visitCondition (condition_t &) override
 
void visitUpdate (update_t &) override
 
int32_t visitEmptyStatement (EmptyStatement *stat) override
 
int32_t visitExprStatement (ExprStatement *stat) override
 
int32_t visitAssertStatement (AssertStatement *stat) override
 
int32_t visitForStatement (ForStatement *stat) override
 
int32_t visitIterationStatement (IterationStatement *stat) override
 
int32_t visitWhileStatement (WhileStatement *stat) override
 
int32_t visitDoWhileStatement (DoWhileStatement *stat) override
 
int32_t visitBlockStatement (BlockStatement *stat) override
 
int32_t visitIfStatement (IfStatement *stat) override
 
int32_t visitReturnStatement (ReturnStatement *stat) override
 
bool checkDynamicExpressions (Statement *stat)
 
bool checkExpression (expression_t)
 Type check an expression. More...
 
bool checkSpawnParameterCompatible (type_t param, expression_t arg)
 
bool checkSpawnAndExit (expression_t)
 
- Public Member Functions inherited from UTAP::SystemVisitor
virtual ~SystemVisitor ()
 
virtual void visitSystemBefore (TimedAutomataSystem *)
 
virtual void visitTypeDef (symbol_t)
 
- Public Member Functions inherited from UTAP::AbstractStatementVisitor
int32_t visitSwitchStatement (SwitchStatement *stat) override
 
int32_t visitCaseStatement (CaseStatement *stat) override
 
int32_t visitDefaultStatement (DefaultStatement *stat) override
 
int32_t visitBreakStatement (BreakStatement *stat) override
 
int32_t visitContinueStatement (ContinueStatement *stat) override
 
- Public Member Functions inherited from UTAP::StatementVisitor
virtual ~StatementVisitor ()
 

Additional Inherited Members

- Protected Member Functions inherited from UTAP::AbstractStatementVisitor
virtual int32_t visitStatement (Statement *stat)
 

Detailed Description

A visitor which type checks the system it visits.

The type checker can only visit the system given in the constructor. The type checker must not be constructed before the system has been parsed.

Definition at line 57 of file typechecker.h.

Constructor & Destructor Documentation

◆ TypeChecker()

◆ ~TypeChecker()

Member Function Documentation

◆ checkDynamicExpressions()

◆ checkExpression()

bool TypeChecker::checkExpression ( expression_t  expr)

Type check an expression.

Type check and checkExpression the expression.

This function performs basic type checking of the given expression and assigns a type to every subexpression of the expression. It checks that only left-hand side values are updated, checks that functions are called with the correct arguments, checks that operators are used with the correct operands and checks that operands to assignment operators are assignment compatible. Errors are reported by calling handleError(). This function does not check/compute the range of integer expressions and thus does not produce out-of-range errors or warnings. Returns true if no type errors were found, false otherwise.

Definition at line 2108 of file typechecker.cpp.

References UTAP::Constants::A_BUCHI, UTAP::Constants::A_UNTIL, UTAP::Constants::A_WEAKUNTIL, UTAP::Constants::ABS_F, UTAP::Constants::ACOS_F, UTAP::Constants::ACOSH_F, UTAP::Constants::AF, UTAP::Constants::AG, UTAP::Constants::AG_R_Piotr, UTAP::Constants::AND, UTAP::Constants::ARRAY, UTAP::Constants::ASIN_F, UTAP::Constants::ASINH_F, 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::ATAN2_F, UTAP::Constants::ATAN_F, UTAP::Constants::ATANH_F, UTAP::Constants::BIT_AND, UTAP::Constants::BIT_LSHIFT, UTAP::Constants::BIT_OR, UTAP::Constants::BIT_RSHIFT, UTAP::Constants::BIT_XOR, UTAP::Constants::BOOL, UTAP::Constants::CBRT_F, UTAP::Constants::CEIL_F, UTAP::Constants::CHANNEL, checkIDList(), checkSpawnParameterCompatible(), UTAP::Constants::CLOCK, UTAP::Constants::COMMA, UTAP::Constants::CONSISTENCY, UTAP::Constants::CONSTRAINT, UTAP::Constants::CONTROL, UTAP::Constants::CONTROL_TOPT, UTAP::Constants::CONTROL_TOPT_DEF1, UTAP::Constants::CONTROL_TOPT_DEF2, UTAP::Constants::COPYSIGN_F, UTAP::Constants::COS_F, UTAP::Constants::COSH_F, UTAP::type_t::createPrimitive(), UTAP::Constants::DIFF, UTAP::Constants::DIV, UTAP::Constants::DOT, UTAP::Constants::DOUBLE, UTAP::Constants::DOUBLEINVGUARD, UTAP::template_t::dynamic, UTAP::Constants::EF, UTAP::Constants::EF_CONTROL, UTAP::Constants::EF_R_Piotr, UTAP::Constants::EG, UTAP::expression_t::empty(), UTAP::Constants::EQ, UTAP::Constants::ERF_F, UTAP::Constants::ERFC_F, UTAP::Constants::EXISTS, UTAP::Constants::EXIT, UTAP::Constants::EXP2_F, UTAP::Constants::EXP_F, UTAP::Constants::EXPM1_F, UTAP::Constants::FABS_F, UTAP::Constants::FDIM_F, UTAP::Constants::FINT_F, UTAP::Constants::FLOOR_F, UTAP::Constants::FMA_F, UTAP::Constants::FMAX_F, UTAP::Constants::FMIN_F, UTAP::Constants::FMOD_F, UTAP::Constants::FORALL, UTAP::Constants::FORMULA, UTAP::Constants::FPCLASSIFY_F, UTAP::Constants::FRACTION, UTAP::Constants::FUNCALL, UTAP::Constants::GE, UTAP::type_t::getArraySize(), UTAP::TimedAutomataSystem::getDynamicTemplate(), UTAP::expression_t::getKind(), UTAP::expression_t::getSize(), UTAP::frame_t::getSize(), UTAP::type_t::getSub(), UTAP::expression_t::getType(), UTAP::Constants::GT, UTAP::Constants::GUARD, UTAP::Constants::HYPOT_F, UTAP::Constants::IDENTIFIER, UTAP::Constants::ILOGB_F, UTAP::Constants::IMPLEMENTATION, UTAP::Constants::INF_VAR, UTAP::Constants::INLINEIF, UTAP::Constants::INT, UTAP::Constants::INVARIANT, UTAP::Constants::INVARIANT_WR, UTAP::type_t::isArray(), isAssignable(), isBound(), isClock(), isConstraint(), isCost(), UTAP::template_t::isDefined, isDiff(), isDoubleValue(), UTAP::Constants::ISFINITE_F, isFormula(), isGuard(), UTAP::Constants::ISINF_F, isInteger(), UTAP::type_t::isInteger(), isIntegral(), UTAP::type_t::isIntegral(), isInvariant(), isInvariantWR(), isListOfFormulas(), UTAP::Constants::ISNAN_F, UTAP::type_t::isNonConstant(), UTAP::Constants::ISNORMAL_F, isNumber(), isProcessID(), isSameScalarType(), UTAP::type_t::isScalar(), UTAP::Constants::ISUNORDERED_F, isVoid(), UTAP::Constants::LDEXP_F, UTAP::Constants::LE, UTAP::Constants::LEADSTO, UTAP::Constants::LGAMMA_F, UTAP::Constants::LIST, UTAP::Constants::LN_F, UTAP::Constants::LOG10_F, UTAP::Constants::LOG1P_F, UTAP::Constants::LOG2_F, UTAP::Constants::LOG_F, UTAP::Constants::LOGB_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::NEXTAFTER_F, UTAP::Constants::NOT, UTAP::Constants::NUMOF, UTAP::Constants::OR, UTAP::instance_t::parameters, 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::PROCESS, UTAP::Constants::RANDOM_ARCSINE_F, UTAP::Constants::RANDOM_BETA_F, UTAP::Constants::RANDOM_F, UTAP::Constants::RANDOM_GAMMA_F, UTAP::Constants::RANDOM_NORMAL_F, UTAP::Constants::RANDOM_POISSON_F, UTAP::Constants::RANDOM_TRI_F, UTAP::Constants::RANDOM_WEIBULL_F, UTAP::Constants::RATE, UTAP::Constants::REFINEMENT_GE, UTAP::Constants::REFINEMENT_LE, UTAP::Constants::RESTRICT, UTAP::Constants::ROUND_F, UTAP::Constants::SCENARIO, UTAP::Constants::SCENARIO2, UTAP::expression_t::setType(), UTAP::Constants::SIGNBIT_F, UTAP::Constants::SIMULATE, UTAP::Constants::SIMULATEREACH, UTAP::Constants::SIMULATION_GE, UTAP::Constants::SIMULATION_LE, UTAP::Constants::SIN_F, UTAP::Constants::SINH_F, UTAP::type_t::size(), 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::SYNTAX_COMPOSITION, UTAP::Constants::TAN_F, UTAP::Constants::TANH_F, UTAP::Constants::TGAMMA_F, UTAP::Constants::TIOCOMPOSITION, UTAP::Constants::TIOCONJUNCTION, UTAP::Constants::TIOGRAPH, UTAP::Constants::TIOQUOTIENT, UTAP::Constants::TRUNC_F, UTAP::Constants::UNARY_MINUS, UTAP::type_t::unknown(), and UTAP::Constants::XOR.

Referenced by parseExpression(), TypeChecker(), visitAssertStatement(), visitBlockStatement(), visitCondition(), visitDoWhileStatement(), visitEdge(), visitForStatement(), visitGanttChart(), visitHybridClock(), visitIfStatement(), visitInstance(), visitIODecl(), visitMessage(), visitProgressMeasure(), visitProperty(), visitReturnStatement(), visitState(), visitSystemAfter(), visitVariable(), and visitWhileStatement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkSpawnAndExit()

bool UTAP::TypeChecker::checkSpawnAndExit ( expression_t  )

◆ checkSpawnParameterCompatible()

bool TypeChecker::checkSpawnParameterCompatible ( type_t  param,
expression_t  arg 
)

Definition at line 3405 of file typechecker.cpp.

Referenced by checkExpression().

Here is the caller graph for this function:

◆ visitAssertStatement()

int32_t TypeChecker::visitAssertStatement ( AssertStatement stat)
overridevirtual

Reimplemented from UTAP::AbstractStatementVisitor.

Definition at line 1627 of file typechecker.cpp.

References UTAP::expression_t::changesAnyVariable(), checkExpression(), and UTAP::AssertStatement::expr.

Here is the call graph for this function:

◆ visitBlockStatement()

int32_t TypeChecker::visitBlockStatement ( BlockStatement stat)
overridevirtual

◆ visitCondition()

void TypeChecker::visitCondition ( condition_t condition)
overridevirtual

◆ visitDoWhileStatement()

int32_t TypeChecker::visitDoWhileStatement ( DoWhileStatement stat)
overridevirtual

Reimplemented from UTAP::AbstractStatementVisitor.

Definition at line 1678 of file typechecker.cpp.

References UTAP::Statement::accept(), checkExpression(), UTAP::DoWhileStatement::cond, and UTAP::DoWhileStatement::stat.

Here is the call graph for this function:

◆ visitEdge()

◆ visitEmptyStatement()

int32_t TypeChecker::visitEmptyStatement ( EmptyStatement stat)
overridevirtual

Reimplemented from UTAP::AbstractStatementVisitor.

Definition at line 1616 of file typechecker.cpp.

◆ visitExprStatement()

int32_t TypeChecker::visitExprStatement ( ExprStatement stat)
overridevirtual

Reimplemented from UTAP::AbstractStatementVisitor.

Definition at line 1621 of file typechecker.cpp.

References UTAP::ExprStatement::expr.

◆ visitForStatement()

int32_t TypeChecker::visitForStatement ( ForStatement stat)
overridevirtual

◆ visitFunction()

◆ visitGanttChart()

void TypeChecker::visitGanttChart ( gantt_t gc)
overridevirtual

Reimplemented from UTAP::SystemVisitor.

Definition at line 1225 of file typechecker.cpp.

References checkExpression(), UTAP::frame_t::getSize(), isConstraint(), isIntegral(), UTAP::gantt_t::mapping, and UTAP::gantt_t::parameters.

Here is the call graph for this function:

◆ visitHybridClock()

void TypeChecker::visitHybridClock ( expression_t  e)
virtual

Definition at line 697 of file typechecker.cpp.

References UTAP::expression_t::changesAnyVariable(), checkExpression(), and isClock().

Here is the call graph for this function:

◆ visitIfStatement()

int32_t TypeChecker::visitIfStatement ( IfStatement stat)
overridevirtual

Reimplemented from UTAP::AbstractStatementVisitor.

Definition at line 1726 of file typechecker.cpp.

References UTAP::Statement::accept(), checkExpression(), UTAP::IfStatement::cond, UTAP::IfStatement::falseCase, and UTAP::IfStatement::trueCase.

Here is the call graph for this function:

◆ visitInstance()

◆ visitInstanceLine()

void TypeChecker::visitInstanceLine ( instanceLine_t instance)
overridevirtual

Reimplemented from UTAP::SystemVisitor.

Definition at line 1155 of file typechecker.cpp.

References UTAP::SystemVisitor::visitInstanceLine().

Here is the call graph for this function:

◆ visitIODecl()

◆ visitIterationStatement()

int32_t TypeChecker::visitIterationStatement ( IterationStatement stat)
overridevirtual

◆ visitMessage()

void TypeChecker::visitMessage ( message_t message)
overridevirtual

◆ visitProcess()

void TypeChecker::visitProcess ( instance_t process)
overridevirtual

◆ visitProgressMeasure()

void TypeChecker::visitProgressMeasure ( progress_t progress)
overridevirtual

Reimplemented from UTAP::SystemVisitor.

Definition at line 1207 of file typechecker.cpp.

References checkExpression(), UTAP::expression_t::empty(), UTAP::progress_t::guard, isIntegral(), and UTAP::progress_t::measure.

Here is the call graph for this function:

◆ visitProperty()

◆ visitReturnStatement()

int32_t TypeChecker::visitReturnStatement ( ReturnStatement stat)
overridevirtual

Reimplemented from UTAP::AbstractStatementVisitor.

Definition at line 1740 of file typechecker.cpp.

References checkExpression(), UTAP::expression_t::empty(), and UTAP::ReturnStatement::value.

Here is the call graph for this function:

◆ visitState()

◆ visitSystemAfter()

void TypeChecker::visitSystemAfter ( TimedAutomataSystem sys)
overridevirtual

◆ visitTemplateAfter()

void TypeChecker::visitTemplateAfter ( template_t t)
overridevirtual

Reimplemented from UTAP::SystemVisitor.

Definition at line 3391 of file typechecker.cpp.

◆ visitTemplateBefore()

bool TypeChecker::visitTemplateBefore ( template_t t)
overridevirtual

Reimplemented from UTAP::SystemVisitor.

Definition at line 3397 of file typechecker.cpp.

◆ visitUpdate()

void TypeChecker::visitUpdate ( update_t update)
overridevirtual

Reimplemented from UTAP::SystemVisitor.

Definition at line 1199 of file typechecker.cpp.

References UTAP::expression_t::empty(), UTAP::update_t::label, and UTAP::SystemVisitor::visitUpdate().

Here is the call graph for this function:

◆ visitVariable()

◆ visitWhileStatement()

int32_t TypeChecker::visitWhileStatement ( WhileStatement stat)
overridevirtual

Reimplemented from UTAP::AbstractStatementVisitor.

Definition at line 1669 of file typechecker.cpp.

References UTAP::Statement::accept(), checkExpression(), UTAP::WhileStatement::cond, and UTAP::WhileStatement::stat.

Here is the call graph for this function:

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