MicroModelicaCCompiler
4.5.3
mmo_settings.cpp
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
#include "
mmo_settings.hpp
"
21
22
#include <
ast/class.hpp
>
23
#include <
ast/modification.hpp
>
24
#include "
class.hpp
"
25
#include <
util/error.hpp
>
26
27
namespace
MicroModelica
{
28
using namespace
Util;
29
namespace
IR {
30
31
Settings::Settings
(
string
name)
32
: _model(), _insertAnnotation(false), _processFunction(false), _processModel(false), _classModification(false)
33
{
34
}
35
36
Settings::~Settings
() {}
37
38
void
Settings::visit
(AST_Class x)
39
{
40
Error::instance
().
setClassName
(*(x->name()));
41
AST_TypePrefix
p = x->prefix();
42
if
(
_processModel
) {
43
if
((p &
CP_FUNCTION
) || (p &
CP_IMPURE
) || (p &
CP_PURE
)) {
44
_insertAnnotation
=
false
;
45
_processFunction
=
true
;
46
}
47
}
else
{
48
if
(p &
CP_MODEL
) {
49
_insertAnnotation
=
true
;
50
_model
=
Model
(*x->name());
51
}
52
}
53
}
54
55
void
Settings::leave
(AST_Class x)
56
{
57
if
(
_processFunction
) {
58
_processFunction
=
false
;
59
_insertAnnotation
=
true
;
60
}
61
}
62
63
void
Settings::visit
(AST_Composition x) {}
64
65
void
Settings::leave
(AST_Composition x) {}
66
67
void
Settings::visit
(AST_CompositionElement x) {}
68
69
void
Settings::leave
(AST_CompositionElement x) {}
70
71
void
Settings::visit
(AST_CompositionEqsAlgs x) {}
72
73
void
Settings::leave
(AST_CompositionEqsAlgs x) {}
74
75
void
Settings::visit
(AST_External_Function_Call x) {}
76
77
void
Settings::visit
(AST_Element x) {}
78
79
void
Settings::visit
(AST_Modification x)
80
{
81
if
(x->modificationType() ==
MODCLASS
) {
82
_classModification
=
false
;
83
}
84
}
85
86
void
Settings::leave
(AST_Modification x)
87
{
88
if
(x->modificationType() ==
MODCLASS
) {
89
_classModification
=
false
;
90
}
91
}
92
93
void
Settings::visit
(AST_Comment x) {}
94
95
void
Settings::visit
(AST_Equation x) {}
96
97
void
Settings::visit
(AST_ForIndex x) {}
98
99
void
Settings::visit
(AST_Equation_Else x) {}
100
101
void
Settings::visit
(AST_Expression x) {}
102
103
void
Settings::visit
(AST_Argument x)
104
{
105
if
(
_insertAnnotation
) {
106
if
(x->argumentType() ==
AR_MODIFICATION
) {
107
AST_Argument_Modification am = x->getAsModification();
108
if
(am->hasModification() &&
_classModification
==
false
) {
109
_model
.
insert
(am);
110
}
111
}
112
}
113
}
114
115
void
Settings::visit
(AST_Statement x) {}
116
117
void
Settings::leave
(AST_Statement x) {}
118
119
void
Settings::visit
(AST_Statement_Else x) {}
120
121
void
Settings::visit
(AST_StoredDefinition x) {}
122
123
void
Settings::leave
(AST_StoredDefinition x) {}
124
125
int
Settings::apply
(AST_Node x)
126
{
127
x->accept(
this
);
128
return
Error::instance
().
errors
();
129
}
130
131
ModelAnnotation
Settings::annotations
() {
return
_model
.
annotations
(); }
132
}
// namespace IR
133
}
// namespace MicroModelica
MicroModelica::IR::Settings::Settings
Settings(string name)
Definition:
mmo_settings.cpp:48
MicroModelica::Util::Error::instance
static Error & instance()
Definition:
error.hpp:128
MicroModelica::IR::Settings::leave
void leave(AST_Class x)
Definition:
mmo_settings.cpp:72
MicroModelica::IR::Settings::_classModification
bool _classModification
Definition:
mmo_settings.hpp:225
MicroModelica::IR::Settings::_processModel
bool _processModel
Definition:
mmo_settings.hpp:224
MicroModelica::IR::Settings::visit
void visit(AST_Class x)
Definition:
mmo_settings.cpp:55
MicroModelica::IR::Settings::_processFunction
bool _processFunction
Definition:
mmo_settings.hpp:223
MicroModelica::IR::Settings::annotations
ModelAnnotation annotations()
Definition:
mmo_settings.cpp:148
CP_IMPURE
@ CP_IMPURE
Definition:
ast_types.hpp:223
MicroModelica::IR::Settings::_insertAnnotation
bool _insertAnnotation
Definition:
mmo_settings.hpp:222
MicroModelica::IR::Settings::apply
int apply(AST_Node x)
Definition:
mmo_settings.cpp:142
MicroModelica::IR::Settings::_model
Model _model
Definition:
mmo_settings.hpp:221
AST_TypePrefix
int AST_TypePrefix
Definition:
ast_types.hpp:50
MicroModelica::Util::Error::setClassName
void setClassName(std::string class_name)
Definition:
error.cpp:38
MicroModelica::Util::Error::errors
int errors()
Definition:
error.cpp:257
mmo_settings.hpp
AR_MODIFICATION
@ AR_MODIFICATION
Definition:
ast_types.hpp:206
class.hpp
CP_PURE
@ CP_PURE
Definition:
ast_types.hpp:222
MicroModelica::IR::Settings::~Settings
~Settings()
Definition:
mmo_settings.cpp:53
modification.hpp
MicroModelica
Definition:
files.cpp:45
MODCLASS
@ MODCLASS
Definition:
ast_types.hpp:189
MicroModelica::IR::Model
Definition:
class.hpp:160
CP_FUNCTION
@ CP_FUNCTION
Definition:
ast_types.hpp:225
MicroModelica::IR::Model::annotations
ModelAnnotation annotations() const
Definition:
class.hpp:177
CP_MODEL
@ CP_MODEL
Definition:
ast_types.hpp:215
error.hpp
MicroModelica::IR::Model::insert
void insert(string n)
Definition:
class.cpp:436
ir
mmo_settings.cpp
Generated on Fri Feb 21 2025 11:43:43 for MicroModelicaCCompiler by
1.8.17