MicroModelicaCCompiler  4.5.3
error.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 ERROR_H_
21 #define ERROR_H_
22 
23 #include <map>
24 #include <string>
25 
26 namespace MicroModelica {
27 namespace Util {
28 
29 #define EM_MODULE 0xffff0000
30 #define EM_MESSAGE 0x0000ffff
31 #define EM_AST 0x00010000
32 #define EM_IR 0x00020000
33 #define EM_CG 0x00030000
34 #define EM_PP 0x00040000
35 #define EM_ERROR 0x00050000
36 #define EM_GRM 0x00060000
37 #define EM_VARIABLE_NOT_FOUND 0x00000001
38 #define EM_CANT_OPEN_FILE 0x00000002
39 #define EM_PARSE_FILE 0x00000003
40 #define EM_WRONG_SCANNER 0x00000004
41 #define EM_VARIABLE_NOT_DEFINED 0x00000005
42 #define EM_WRONG_TYPE 0x00000006
43 #define EM_WRONG_EXP 0x00000007
44 #define EM_UNKNOWN_OPER 0x00000008
45 #define EM_UNKNOWN_OPERATION 0x00000009
46 #define EM_UNKNOWN_EXP 0x0000000a
47 #define EM_UNKNOWN_TYPE 0x0000000b
48 #define EM_ARRAY_INIT 0x0000000c
49 #define EM_ARRAY_INIT_VAL 0x0000000d
50 #define EM_ARRAY_CTE 0x0000000e
51 #define EM_ARRAY_SIZE 0x0000000f
52 #define EM_ALG_INIT 0x00000010
53 #define EM_ALG_INDEX 0x00000020
54 #define EM_OUTPUT_INIT 0x00000030
55 #define EM_FOR_VAR 0x00000040
56 #define EM_FOR_DEF 0x00000050
57 #define EM_CALL_EXP 0x00000060
58 #define EM_RANGE_EXP 0x00000070
59 #define EM_INDEX_RANGE 0x00000080
60 #define EM_SIZE_ZERO 0x00000090
61 #define EM_GEN_DEF 0x000000a0
62 #define EM_EVENT_DEF 0x000000b0
63 #define EM_SYMBOL 0x000000c0
64 #define EM_SYM_DER 0x000000d0
65 #define EM_EQ_DEF 0x000000e0
66 #define EM_NO_EQ 0x000000f0
67 #define EM_UNKNOWN_ODE 0x00000100
68 #define EM_EVENT_FOUND 0x00000200
69 #define EM_UNKNOWN_ERROR 0x00000300
70 #define EM_SAMPLED_DEF 0x00000400
71 #define EM_OUTPUT_DEF 0x00000500
72 #define EM_ARGUMENTS 0x00000600
73 #define EM_SAMPLED_OUT 0x00000700
74 #define EM_HANDLER 0x00000800
75 #define EM_CONSTANT_FOR 0x00000900
76 #define EM_DEFINITION_NOT_ALLOWED 0x00000a00
77 #define EM_CLASS_DEFINITION 0x00000b00
78 #define EM_INIT_EXP 0x00000c00
79 #define EM_IMPLICIT_CAST 0x00000d00
80 #define EM_WRONG_VARIABLE_TYPE 0x00000e00
81 #define EM_INDEX_EXP 0x00000f00
82 #define EM_FUNCTION_NOT_FOUND 0x00001000
83 #define EM_ANNOTATION_NOT_FOUND 0x00002000
84 #define EM_ANNOTATION_TYPE 0x00003000
85 
86 typedef enum {
91 
92 class Error {
93  public:
94  static Error& instance()
95  {
96  static Error _instance;
97  return _instance;
98  }
99  ~Error() = default;
100 
101  void add(int pos, unsigned int code, ER_Type t, const std::string message, ...);
102  void show();
103  void setClassName(std::string class_name);
104  std::string className();
105  void setFile(std::string s);
106  std::string file();
107  int errors();
108 
109  private:
110  Error();
111  std::string typeString(ER_Type t);
112  std::string printCode(int code);
113  std::map<unsigned int, std::string> _errors;
114  std::map<unsigned int, std::string> _warnings;
117  std::string _std_def;
118  std::string _class_name;
119 };
120 } // namespace Util
121 } // namespace MicroModelica
122 
123 #endif /* ERROR_H_ */
MicroModelica::Util::Error::instance
static Error & instance()
Definition: error.hpp:128
MicroModelica::Util::Error::_errors
std::map< unsigned int, std::string > _errors
Definition: error.hpp:147
MicroModelica::Util::Error::setFile
void setFile(std::string s)
Definition: error.cpp:34
MicroModelica::Util::Error::file
std::string file()
Definition: error.cpp:36
MicroModelica::Util::Error::~Error
~Error()=default
MicroModelica::Util::Error::_std_def
std::string _std_def
Definition: error.hpp:151
MicroModelica::Util::Error::_warnings
std::map< unsigned int, std::string > _warnings
Definition: error.hpp:148
MicroModelica::Util::ER_Fatal
@ ER_Fatal
ER_Fatal.
Definition: error.hpp:123
MicroModelica::Util::Error::className
std::string className()
Definition: error.cpp:40
MicroModelica::Util::Error::_num_warnings
int _num_warnings
Definition: error.hpp:150
MicroModelica::Util::ER_Error
@ ER_Error
ER_Error.
Definition: error.hpp:122
MicroModelica::Util::Error::printCode
std::string printCode(int code)
Definition: error.cpp:93
MicroModelica::Util::Error::_class_name
std::string _class_name
Definition: error.hpp:152
MicroModelica::Util::Error::show
void show()
Definition: error.cpp:66
MicroModelica::Util::ER_Warning
@ ER_Warning
ER_Warning.
Definition: error.hpp:121
MicroModelica::Util::Error::setClassName
void setClassName(std::string class_name)
Definition: error.cpp:38
MicroModelica::Util::Error::add
void add(int pos, unsigned int code, ER_Type t, const std::string message,...)
Definition: error.cpp:42
MicroModelica::Util::Error::errors
int errors()
Definition: error.cpp:257
MicroModelica::Util::Error::_num_errors
int _num_errors
Definition: error.hpp:149
MicroModelica::Util::ER_Type
ER_Type
Definition: error.hpp:120
MicroModelica
Definition: files.cpp:45
MicroModelica::Util::Error::typeString
std::string typeString(ER_Type t)
Definition: error.cpp:80
MicroModelica::Util::Error::Error
Error()
Definition: error.cpp:32