MicroModelicaCCompiler
4.5.3
macros.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
using namespace
std;
23
24
/* Types */
25
#define DEFINE_TYPE(X) \
26
class X##_; \
27
typedef X##_ *X;
28
#define DEFINE_LIST(X) \
29
typedef std::list<X> *X##List; \
30
typedef std::list<X>::iterator X##ListIterator; \
31
typedef std::list<X>::reverse_iterator X##ListReverseIterator;
32
#define _MMOC_S(s) newAST_String(s)
33
#define GET_AS(X, Y) AST_##X##_##Y getAs##Y();
34
#define GET_AS_IMP(X, Y) \
35
AST_##X##_##Y AST_##X##_::getAs##Y() { return dynamic_cast<AST_##X##_##Y>(this); }
36
37
/* Printers */
38
#define DEFINE_PRINTER(X) ostream &operator<<(ostream &os, const X &x);
39
#define DEFINE_CLASS_PRINTER(X) friend ostream &operator<<(ostream &os, const X##_ &x);
40
#define CLASSP_PRINTER_IMP(X) \
41
ostream &operator<<(ostream &os, const X &e) \
42
{ \
43
os << *e; \
44
return os; \
45
}
46
#define CLASS_PRINTER_IMP(X) \
47
ostream &operator<<(ostream &os, const X##_ &e) \
48
{ \
49
os << e.print(); \
50
return os; \
51
} \
52
CLASSP_PRINTER_IMP(X)
53
54
/* Define order relation */
55
#define DEFINE_ORDER_REL(X) bool operator<(const X##_ &other) const;
56
#define ORDER_REL_IMP(X) \
57
bool X##_::operator<(const X##_ &other) const \
58
{ \
59
std::stringstream cmp_this; \
60
std::stringstream cmp_other; \
61
cmp_this << *this; \
62
cmp_other << other; \
63
return cmp_this.str() < cmp_other.str(); \
64
}
65
util
macros.hpp
Generated on Fri Feb 21 2025 11:43:43 for MicroModelicaCCompiler by
1.8.17