MicroModelicaCCompiler  4.5.3
element.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 #ifndef AST_ELEMENT_H_
21 #define AST_ELEMENT_H_
22 
23 #include <string>
24 
25 #include "../util/macros.hpp"
26 #include "../util/util_types.hpp"
27 #include "ast_node.hpp"
28 #include "ast_types.hpp"
29 
30 class AST_Element_ : public AST_Node_ {
31  public:
32  DEFINE_CLASS_PRINTER(AST_Element);
33  virtual string print() const = 0;
34  virtual ElementType elementType();
35  void accept(AST_Visitor *visitor);
36  GET_AS(Element, Component);
37  GET_AS(Element, ExtendsClause);
38  GET_AS(Element, ImportClause);
39  GET_AS(Element, ClassWrapper);
40 };
41 
43  public:
45  string print() const;
46  virtual ElementType elementType();
47  AST_String name();
48 
49  private:
50  string _name;
51 };
52 
54  public:
56  virtual ElementType elementType();
57  string name() const;
58  string print() const;
59 
60  private:
61  string _name;
62 };
63 
65  public:
66  AST_Declaration_(string name, AST_ExpressionList indexes, AST_Modification);
67  string print() const;
68  string name() const;
69  AST_ExpressionList indexes() const;
70  bool hasIndexes();
71  AST_Modification modification() const;
72  bool hasModification();
73  void setComment(AST_Comment c);
74  AST_Comment comment() const;
75 
76  private:
77  string _name;
78  AST_ExpressionList _indexes;
79  AST_Modification _mod;
80  AST_Comment _comm;
81 };
82 
84  public:
85  AST_Element_Component_(AST_DeclarationList decl_list, string type, AST_TypePrefix tp, AST_ExpressionList index);
86  string print() const;
87  bool isParameter() const;
88  bool isInput() const;
89  bool isOutput() const;
90  bool isDiscrete() const;
91  bool isFlow() const;
92  bool isStream() const;
93  bool isConstant() const;
94  string type();
95  virtual ElementType elementType();
96  string name();
97  AST_DeclarationList nameList();
98  AST_Class origin();
99  void setOrigin(AST_Class c);
101  AST_ExpressionList indexes() const;
102  bool hasIndexes();
103  bool isReal();
104  bool isInteger();
105  bool isString();
106 
107  private:
108  AST_DeclarationList _decl_list;
109  string _type;
110  AST_ExpressionList _indexes;
111  AST_Class _origin;
113 };
114 
116  public:
117  AST_Element_ClassWrapper_(AST_Class c);
118  string print() const;
119  virtual ElementType elementType();
120  AST_Class getClass();
121 
122  private:
123  AST_Class _c;
124 };
125 
126 class AST_Comment_ : public AST_Node_ {
127  public:
128  AST_Comment_(AST_String st, AST_ArgumentList al);
129  AST_ArgumentList arguments() const;
130  AST_String string() const;
131  void setAnnotation(AST_ArgumentList al);
132  DEFINE_CLASS_PRINTER(AST_Comment);
133  void accept(AST_Visitor *visitor);
134 
135  private:
137  AST_ArgumentList _al;
138 };
139 
140 #endif /* AST_ELEMENT_H_ */
AST_Element_Component_::_indexes
AST_ExpressionList _indexes
Definition: element.hpp:110
AST_Declaration_::modification
AST_Modification modification() const
Definition: element.cpp:248
MicroModelica::Generator::MODEL_INSTANCE::Component
Component
Definition: model_instance.hpp:89
AST_Element_::elementType
virtual ElementType elementType()
Definition: element.cpp:50
AST_Declaration_::hasModification
bool hasModification()
Definition: element.cpp:250
AST_Element_Component_::setOrigin
void setOrigin(AST_Class c)
Definition: element.cpp:282
AST_Element_ExtendsClause_
Definition: element.hpp:42
AST_Element_Component_::origin
AST_Class origin()
Definition: element.cpp:280
AST_Element_ExtendsClause_::AST_Element_ExtendsClause_
AST_Element_ExtendsClause_(string name)
Definition: element.cpp:137
AST_Element_ClassWrapper_::print
string print() const
Definition: element.cpp:58
AST_Element_::GET_AS
GET_AS(Element, Component)
AST_Element_ImportClause_::print
string print() const
Definition: element.cpp:154
AST_Element_
Definition: element.hpp:30
AST_Declaration_::_mod
AST_Modification _mod
Definition: element.hpp:79
AST_Element_ImportClause_::_name
string _name
Definition: element.hpp:61
AST_Comment_::AST_Comment_
AST_Comment_(AST_String st, AST_ArgumentList al)
Definition: element.cpp:167
AST_Declaration_::_comm
AST_Comment _comm
Definition: element.hpp:80
AST_Comment_::_st
AST_String _st
Definition: element.hpp:136
AST_Element_Component_::isInput
bool isInput() const
Definition: element.cpp:260
AST_Element_::print
virtual string print() const =0
AST_Comment_::DEFINE_CLASS_PRINTER
DEFINE_CLASS_PRINTER(AST_Comment)
AST_Element_Component_::_type
string _type
Definition: element.hpp:109
AST_Element_Component_::nameList
AST_DeclarationList nameList()
Definition: element.cpp:278
AST_Element_ExtendsClause_::elementType
virtual ElementType elementType()
Definition: element.cpp:146
AST_Declaration_::hasIndexes
bool hasIndexes()
Definition: element.cpp:238
AST_Element_ImportClause_
Definition: element.hpp:53
AST_Comment_::setAnnotation
void setAnnotation(AST_ArgumentList al)
Definition: element.cpp:173
AST_Element_Component_::isOutput
bool isOutput() const
Definition: element.cpp:262
AST_Element_ExtendsClause_::_name
string _name
Definition: element.hpp:50
AST_Element_Component_::type
string type()
Definition: element.cpp:272
AST_Element_Component_::isParameter
bool isParameter() const
Definition: element.cpp:258
AST_Element_Component_::isDiscrete
bool isDiscrete() const
Definition: element.cpp:264
AST_String
string * AST_String
Definition: ast_types.hpp:46
AST_Element_Component_::isConstant
bool isConstant() const
Definition: element.cpp:270
AST_Element_ClassWrapper_::elementType
virtual ElementType elementType()
Definition: element.cpp:68
AST_Element_Component_::_origin
AST_Class _origin
Definition: element.hpp:111
AST_Declaration_::name
string name() const
Definition: element.cpp:234
AST_Element_ImportClause_::elementType
virtual ElementType elementType()
Definition: element.cpp:163
AST_Declaration_::_name
string _name
Definition: element.hpp:77
AST_Element_Component_::_decl_list
AST_DeclarationList _decl_list
Definition: element.hpp:108
AST_Element_ClassWrapper_::AST_Element_ClassWrapper_
AST_Element_ClassWrapper_(AST_Class c)
Definition: element.cpp:56
AST_Element_ClassWrapper_::_c
AST_Class _c
Definition: element.hpp:123
AST_Element_Component_::AST_Element_Component_
AST_Element_Component_(AST_DeclarationList decl_list, string type, AST_TypePrefix tp, AST_ExpressionList index)
Definition: element.cpp:74
AST_Element_Component_::typePrefix
AST_TypePrefix typePrefix()
Definition: element.cpp:287
AST_Node_
Definition: ast_node.hpp:29
AST_TypePrefix
int AST_TypePrefix
Definition: ast_types.hpp:50
AST_Element_Component_::isInteger
bool isInteger()
Definition: element.cpp:293
AST_Element_Component_::_tp
AST_TypePrefix _tp
Definition: element.hpp:112
AST_Element_Component_::isString
bool isString()
Definition: element.cpp:295
AST_Comment_
Definition: element.hpp:126
AST_Element_ImportClause_::name
string name() const
Definition: element.cpp:161
AST_Comment_::string
AST_String string() const
Definition: element.cpp:171
AST_Declaration_::comment
AST_Comment comment() const
Definition: element.cpp:254
AST_Declaration_::setComment
void setComment(AST_Comment c)
Definition: element.cpp:252
AST_Element_Component_::print
string print() const
Definition: element.cpp:79
AST_Element_Component_::elementType
virtual ElementType elementType()
Definition: element.cpp:274
AST_Element_Component_::isStream
bool isStream() const
Definition: element.cpp:268
ElementType
ElementType
Definition: ast_types.hpp:159
ast_node.hpp
AST_Element_Component_::name
string name()
Definition: element.cpp:276
AST_Comment_::accept
void accept(AST_Visitor *visitor)
Definition: element.cpp:194
AST_Declaration_::AST_Declaration_
AST_Declaration_(string name, AST_ExpressionList indexes, AST_Modification)
Definition: element.cpp:198
AST_Element_::DEFINE_CLASS_PRINTER
DEFINE_CLASS_PRINTER(AST_Element)
AST_Comment_::arguments
AST_ArgumentList arguments() const
Definition: element.cpp:169
ast_types.hpp
AST_Element_ExtendsClause_::print
string print() const
Definition: element.cpp:139
AST_Element_Component_
Definition: element.hpp:83
AST_Element_Component_::hasIndexes
bool hasIndexes()
Definition: element.cpp:133
AST_Element_Component_::indexes
AST_ExpressionList indexes() const
Definition: element.cpp:289
AST_Declaration_::_indexes
AST_ExpressionList _indexes
Definition: element.hpp:78
AST_Visitor
Definition: ast_util.hpp:224
AST_Declaration_::print
string print() const
Definition: element.cpp:203
AST_Element_::accept
void accept(AST_Visitor *visitor)
Definition: element.cpp:52
AST_Element_ClassWrapper_
Definition: element.hpp:115
AST_Element_Component_::isReal
bool isReal()
Definition: element.cpp:291
AST_Element_ImportClause_::AST_Element_ImportClause_
AST_Element_ImportClause_(string name)
Definition: element.cpp:152
AST_Declaration_::indexes
AST_ExpressionList indexes() const
Definition: element.cpp:236
AST_Element_ClassWrapper_::getClass
AST_Class getClass()
Definition: element.cpp:70
AST_Element_Component_::isFlow
bool isFlow() const
Definition: element.cpp:266
AST_Comment_::_al
AST_ArgumentList _al
Definition: element.hpp:137
AST_Element_ExtendsClause_::name
AST_String name()
Definition: element.cpp:148
AST_Declaration_
Definition: element.hpp:64