MicroModelicaCCompiler  4.5.3
statement.hpp
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  This file is part of QSS Solver.
4 
5  QSS Solver is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  QSS Solver is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QSS Solver. If not, see <http://www.gnu.org/licenses/>.
17 
18  ******************************************************************************/
19 
20 #pragma once
21 
22 #include <ast/ast_types.hpp>
23 #include <ir/index.hpp>
24 #include <util/table.hpp>
25 
26 namespace MicroModelica {
27 
28 namespace Util {
30 }
31 namespace IR {
32 
33 namespace STATEMENT {
34 typedef enum { LHS, RHS, LHS_DISCRETES, LHS_STATES } AssignTerm;
35 }
36 
37 class Statement {
38  public:
39  Statement(AST_Statement stm, bool initial = false, const std::string& block = "");
40  Statement(AST_Statement stm, Option<Range> range, bool initial = false, const std::string& block = "");
42  ~Statement() = default;
43 
44  inline bool hasRange() { return _range.is_initialized(); };
46  friend std::ostream& operator<<(std::ostream& out, const Statement& s);
47  string print() const;
55  ExpressionList lhsDiscretes() const { return _lhs_discretes; };
56  ExpressionList lhsStates() const { return _lhs_states; };
57  bool isAssignment() const;
58  bool isForStatement() const;
59  inline Option<Range> range() { return _range; };
60  bool autonomous() const;
61 
62  protected:
63  void initialize();
66  bool checkStateAssignment(Expression exp) const;
67  std::string printAssignment(AST_Statement_Assign asg) const;
68  void setRange();
69 
70  private:
71  AST_Statement _stm;
74  std::string _block;
79 };
80 
82 } // namespace IR
83 } // namespace MicroModelica
MicroModelica::IR::Statement::setRange
void setRange()
Definition: statement.cpp:74
ModelTable< std::string, std::string >
MicroModelica::IR::STATEMENT::LHS
@ LHS
Definition: statement.hpp:51
index.hpp
MicroModelica::IR::Statement::range
Option< Range > range()
Definition: statement.hpp:76
MicroModelica::IR::Statement::_lhs_discretes
ExpressionList _lhs_discretes
Definition: statement.hpp:94
MicroModelica::IR::Statement::_range
Option< Range > _range
Definition: statement.hpp:89
MicroModelica::IR::Statement::initialize
void initialize()
Definition: statement.cpp:63
MicroModelica::IR::Statement::~Statement
~Statement()=default
MicroModelica::IR::Statement::_block
std::string _block
Definition: statement.hpp:91
Option
Definition: util_types.hpp:32
MicroModelica::IR::Statement::checkStateAssignment
bool checkStateAssignment(Expression exp) const
Definition: statement.cpp:163
MicroModelica::IR::Statement::lhsDiscretes
ExpressionList lhsDiscretes() const
Definition: statement.hpp:72
MicroModelica::IR::Statement::_lhs_assignments
ExpressionList _lhs_assignments
Definition: statement.hpp:92
MicroModelica::IR::Statement::Statement
Statement()
Definition: statement.hpp:58
MicroModelica::Util::SymbolTable
ModelTable< std::string, std::string > SymbolTable
Definition: equation.hpp:62
MicroModelica::IR::Statement::autonomous
bool autonomous() const
Definition: statement.cpp:288
MicroModelica::IR::Statement::_calledFunctions
Util::SymbolTable _calledFunctions
Definition: statement.hpp:90
MicroModelica::IR::Expression
Definition: expression.hpp:64
MicroModelica::IR::ExpressionList
list< Expression > ExpressionList
Definition: expression.hpp:95
MicroModelica::IR::Statement::lhsStates
ExpressionList lhsStates() const
Definition: statement.hpp:73
MicroModelica::IR::STATEMENT::RHS
@ RHS
Definition: statement.hpp:51
MicroModelica::IR::Statement::_lhs_states
ExpressionList _lhs_states
Definition: statement.hpp:95
MicroModelica::IR::Statement::calledFunctions
Util::SymbolTable calledFunctions()
Definition: statement.hpp:62
MicroModelica::IR::Statement::_stm
AST_Statement _stm
Definition: statement.hpp:88
MicroModelica::IR::Statement::_rhs_assignments
ExpressionList _rhs_assignments
Definition: statement.hpp:93
MicroModelica::IR::STATEMENT::AssignTerm
AssignTerm
Definition: statement.hpp:51
MicroModelica::IR::Statement::emptyRef
Expression emptyRef()
Definition: statement.cpp:268
MicroModelica::IR::Statement::printAssignment
std::string printAssignment(AST_Statement_Assign asg) const
Definition: statement.cpp:173
block
int block
Definition: ast_builder.cpp:41
MicroModelica
Definition: files.cpp:45
MicroModelica::IR::STATEMENT::LHS_STATES
@ LHS_STATES
Definition: statement.hpp:51
MicroModelica::IR::Statement::isForStatement
bool isForStatement() const
Definition: statement.cpp:171
MicroModelica::IR::Statement::operator<<
friend std::ostream & operator<<(std::ostream &out, const Statement &s)
Definition: statement.cpp:297
MicroModelica::IR::StatementTable
ModelTable< int, Statement > StatementTable
Definition: statement.hpp:98
table.hpp
ast_types.hpp
MicroModelica::IR::STATEMENT::LHS_DISCRETES
@ LHS_DISCRETES
Definition: statement.hpp:51
MicroModelica::IR::Statement::generateExps
ExpressionList generateExps(STATEMENT::AssignTerm asg)
Definition: statement.cpp:84
MicroModelica::IR::Statement::hasRange
bool hasRange()
Definition: statement.hpp:61
MicroModelica::IR::Statement::print
string print() const
Definition: statement.cpp:197
MicroModelica::IR::Statement::assignments
ExpressionList assignments(STATEMENT::AssignTerm asg) const
Returns a expression list containing all the expressions needed by the graph builders....
Definition: statement.cpp:274
MicroModelica::IR::Statement::isAssignment
bool isAssignment() const
Definition: statement.cpp:266