Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[r368]: cmajor++ / Cm / Cm.Core / Error.hpp Maximize Restore History

Download this file

Error.hpp    306 lines (280 with data), 12.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
/*========================================================================
Copyright (c) 2012-2013 Seppo Laakko
http://sourceforge.net/projects/cmajor/
Distributed under the GNU General Public License, version 3 (GPLv3).
(See accompanying LICENSE.txt or http://www.gnu.org/licenses/gpl.html)
========================================================================*/
#ifndef CM_CORE_ERROR_INCLUDED
#define CM_CORE_ERROR_INCLUDED
#include <Cm.Core/ToolError.hpp>
#include <Soul.Util/TextUtils.hpp>
#include <Soul.Parsing/Position.hpp>
#include <Soul.Parsing/Exception.hpp>
#include <memory>
namespace Cm { namespace Core {
using Soul::Parsing::Position;
using Soul::Parsing::ExpectationFailure;
const int P0 = 0;
const int T0 = 200;
const int C0 = 400;
const int A0 = 600;
const int L0 = 800;
const int G0 = 1000;
const int I0 = 1200;
std::string Category(int code);
class Exception
{
public:
Exception(): number(-1), message(), errorPos(), innerErrorPos() {}
Exception(int number_, const std::string& message_, const Position& errorPos_);
virtual ~Exception();
int Number() const { return number; }
const std::string& Message() const { return message; }
std::string& Message() { return message; }
const Position& ErrorPos() const { return errorPos; }
Position& ErrorPos() { return errorPos; }
void SetInnerErrorPos(const Position& innerErrorPos_) { innerErrorPos = innerErrorPos_; }
const Position& InnerErrorPos() const { return innerErrorPos; }
bool IsDefault() const { return number == -1; }
private:
int number;
std::string message;
Position errorPos;
Position innerErrorPos;
};
typedef std::shared_ptr<Exception> ExceptionPtr;
class TypeCheckException: public Exception
{
public:
TypeCheckException(): Exception() {}
TypeCheckException(int number_, const std::string& message_, const Position& errorPos_);
};
class ConceptCheckException: public TypeCheckException
{
public:
ConceptCheckException(): TypeCheckException() {}
ConceptCheckException(int number_, const std::string& message_, const Position& errorPos_);
};
class CodeGenException: public Exception
{
public:
CodeGenException(int number_, const std::string& message_, const Position& errorPos_);
};
class AssemblyException: public ToolError
{
public:
AssemblyException(const std::string& toolName_, const std::string& filePath_, int line_, int column_, const std::string& message_);
};
class LinkException: public std::runtime_error
{
public:
LinkException(const std::string& message_);
};
class GCCException: public std::runtime_error
{
public:
GCCException(const std::string& exePath_, const std::string& message_);
const std::string& ExePath() const { return exePath; }
private:
std::string exePath;
};
int RegisterParsedFileName(const std::string& parsedFileName);
std::string GetParsedFileName(int index);
std::string GetErrorCodeClass(int code);
void PrintError(int code, const Exception& ex);
void PrintError(int code, const Exception& ex, bool toCout);
void PrintErrorForDevEnv(const std::string& tool, int code, const std::string& description, const Position& errorPos, const Position& innerErrorPos, const std::string& project);
void PrintErrorForDevEnv(const std::string& tool, int code, const std::string& description, const std::string& file, int line, int column, const std::string& project);
// Type-check errors:
const int LEFT_NOT_BOOL_EXPR = 1;
const int RIGHT_NOT_BOOL_EXPR = 2;
const int FUNCTION_SET_NOT_FOUND = 3;
const int AMBIGUOUS_OBJECT = 4;
const int NOT_FUNCTIONSET = 5;
const int NAME_NOT_FOUND = 6;
const int NEED_EXPLICIT_CONVERSION = 7;
const int NEED_EXACT_MATCH = 8;
const int CAST_NOT_TARGETTYPE = 9;
const int CAST_NOT_SOURCETYPE = 10;
const int NO_CONVERSION = 11;
const int OVERLOAD_RESOLUTION_FAILED = 12;
const int OVERLOAD_RESOLUTION_AMBIGUOUS = 13;
const int CONVERSION_ALREADY_EXISTS = 14;
const int VOID_FUNCTION_CANNOT_RETURN = 15;
const int MUST_RETURN = 16;
const int CANNOT_RETURN = 17;
const int OVERLOAD_ALREADY_EXISTS = 18;
const int CONDITION_NOT_BOOL = 19;
const int SWITCH_EXPRESSION_NOT_INTEGRAL_TYPE = 20;
const int CASES_DO_NOT_TERMINATE = 21;
const int CASE_EXPR_NOT_CONST_EXPR = 22;
const int CASE_EXPR_NOT_INTEGRAL_TYPE = 23;
const int CASE_ALREADY_EXISTS = 24;
const int WHILE_CONDITION_NOT_BOOL_EXPE = 25;
const int DO_WHILE_CONDITION_NOT_BOOL_EXPR = 26;
const int BREAK_NOT_ENCLOSED = 27;
const int LABEL_ALREADY_DEFINED = 28;
const int GOTO_TARGET_NOT_FOUND = 29;
const int GOTO_CASE_EXPRESSION_NOT_CONST_EXPR = 30;
const int GOTO_CASE_EXPRESSION_NOT_INTEGRAL = 31;
const int CASE_NOT_ENCLOSED = 32;
const int GOTO_CASE_NOT_ENCLOSED = 33;
const int CASE_DOES_NOT_EXIST = 34;
const int NO_DEFAULT = 35;
const int GOTO_DEFAULT_NOT_ENCLOSED = 36;
const int TRIED_TO_ASSIGN_TO_CONST_EXPR = 37;
const int CANNOT_ASSIGN_TO_CONSTANT_OBJECT = 38;
const int ASSIGN_CONVERT = 39;
const int CANNOT_INIT_REFERENCE_FROM_CONST_EXPR = 40;
const int CANNOT_INIT_REFERENCE_FROM_CONST_OBJECT = 41;
const int REFERENCE_MUST_BE_INITIALIZED = 42;
const int ARGUMENT_TYPE_IS_VOID = 43;
const int FUNCTION_NOT_FOUND = 44;
const int CANNOT_INIT_REFERENCE_PARAM_FROM_CONST_EXPR = 45;
const int CANNOT_INIT_REFERENCE_PARAM_FROM_CONST_OBJECT = 46;
const int INDEX_NOT_INTEGRAL = 47;
const int OBJECT_DOES_NOT_DENOTE_TYPE = 48;
const int OBJECT_ALREADY_DEFINED_NONPTR = 49;
const int OBJECT_ALREADY_DEFINED_NONTYPE = 50;
const int NOT_ALL_CODEPATHS_RETURN = 51;
const int NEED_LVALUE_ARGUMENT = 52;
const int NOT_FUNCTION = 53;
const int CANNOT_INIT_OBJECT_FROM_TYPE = 54;
const int OBJECT_DOES_NOT_HAVE_SUBSCOPE = 55;
const int NOT_NAMESPACE = 56;
const int NAMESPACE_NOT_FOUND = 57;
const int OBJECT_ALREADY_EXISTS = 58;
const int ENUMERATION_CONSTANT_ALREADY_DEFINED = 59;
const int OBJECT_HAS_NO_MEMBER = 60;
const int OBJECT_IS_NOT_SCOPED = 61;
const int AT_LEAST_ONE_ENUM_CONSTANT = 62;
const int NOT_TYPE = 63;
const int NOT_BASE_OR_MEMBER_VARIABLE = 64;
const int MEMBER_VARIABLE_NOT_FOUND = 65;
const int CLASS_HAS_NO_MEMBER = 66;
const int FOR_LOOP_VARIABLE_CANNOT_HAVE_DESTRUCTOR = 67;
const int DIFFERENT_BASE_TYPES = 68;
const int CLASS_NOT_FOUND = 69;
const int OBJECT_IS_NOT_A_CLASS = 70;
const int NO_DEFAULT_CTOR = 71;
const int CLASS_NOT_BASECLASS = 72;
const int NO_COPY_CTOR = 73;
const int ADDR_NON_VAR = 74;
const int THISVAR_NEEDS_MEMBERSCOPE = 75;
const int ACCESS_DENIED = 76;
const int INVALID_ACCESSSPECIFIERS = 77;
const int INVALID_NAMESPACE_LEVEL_ACCESSSPECIFIERS = 78;
const int ALREADY_HAS_CLASS_INITIALIZER = 79;
const int CANNOT_INIT_NONCONSTPTR_FROM_CONSTPTR = 80;
const int CANNOT_ASSIGN_CONSTPR_TO_NONCONSTPTR = 81;
const int EXPR_DOES_NOT_HAVE_TYPE = 82;
const int CANNOT_CONSTRUCT_REFERENCE = 83;
const int PREFIX_INC_NEEDS_LVALUE_ARGUMENT = 84;
const int PREFIX_DEC_NEEDS_LVALUE_ARGUMENT = 85;
const int NO_POSTFIX_INCDEC_SUPPORT_FOR_NONTRIVIAL_DESTRUCTORS = 86;
const int CONSTANT_VALUE_MUST_BE_INTEGRAL_CONSTANT = 87;
const int COPY_CONSTRUCTOR_NEEDS_EXPLICIT_BASECLASS_INITIALIZER = 88;
const int DESTROY_EXPR_MUST_BE_POINTER = 89;
const int COPY_CONSTRUCTOR_NEEDS_EXPLICIT_MEMBER_INITIALIZERS = 90;
const int INDEXING_EXPRESSION_NOT_OF_POINTER_OR_CLASS_TYPE = 91;
const int INVALID_COMBINATION_OF_SPECIFIERS = 92;
const int CLASS_CONTAINING_ASBTRACT_MEMBER_FUNCTIONS_MUST_BE_ASBTRACT = 93;
const int CANNOT_INSTANTIATE_ABSTRACT_CLASS = 94;
const int OVERRIDING_FUNCTION_SHOULD_BE_DECLARED_WITH_OVERRIDE_SPECIFIER = 95;
const int NO_SUITABLE_FUNCTION_TO_OVERRIDE = 96;
const int STATIC_MEMBERFUNCTION_CANNOT_ACCESS_INSTANCE_VARIABLES = 97;
const int STATIC_MEMBERFUNCTION_CANNOT_CALL_NONSTATIC_MEMBER_FUNCTIONS = 98;
const int BASECLASS_HAS_NO_STATIC_CONSTRUCTOR = 99;
const int STATIC_CONSTRUCTOR_CANNOT_CONSTRUCT_INSTANCE_VARIABLES = 100;
const int STATIC_CONSTRUCTOR_CANNOT_HAVE_THISCLASS_INITIALIZER = 101;
const int STATIC_BASECLASS_INITIALIZER_CANNOT_HAVE_ARGUMENTS = 102;
const int EXCEPTION_DOES_NOT_HAVE_A_TYPE = 103;
const int CANNOT_THROW_NONCLASS_TYPES = 104;
const int NO_SUITABLE_FUNCTIONTEMPLATE_TO_INSTANTIATE = 105;
const int MORE_THAN_ONE_CANDIDATE_FOUND_TO_INSTANTIATE = 106;
const int ARGUMENT_CANNOT_BE_BOUND = 107;
const int STATIC_CLASS_CANNOT_HAVE_INSTANCE_VARIABLES = 108;
const int STATIC_CLASS_CANNOT_HAVE_NONSTATIC_MEMBER_FUNCTIONS = 109;
const int FUNCTION_TEMPLATE_NOT_DEFINED = 110;
const int CONTINUE_NOT_ENCLOSED = 111;
const int ABSTRACT_MEMBER_FUNCTION_CANNOT_HAVE_IMPLEMENTATION = 112;
const int BASE_CLASS_TYPEEXPR_IS_NOT_CLASS = 113;
const int DYNAMIC_TYPENAME_NEEDS_LVALUE_ARGUMENT = 114;
const int ASSERTION_FAILED_EXCEPTION_NOT_FOUND = 115;
const int NOT_FUNCTIONSET_LINK = 116;
const int CYCLIC_MEMBER_VARIABLES_DETECTED = 117;
const int CYCLIC_INHERITANCE_RELATIONSHIPS_DETECTED = 118;
const int DEFAULT_TEMPLATE_PARAMETERS_SHOULD_BE_LAST = 119;
const int NOT_ENOUGH_TEMPLATE_ARGUMENTS_PROVIDED = 120;
const int CANNOT_INVOKE_NON_CLASS_TYPE = 121;
const int POINTER_TO_MEMBER_EXPRESSION_MUST_RETURN_A_TYPE = 122;
const int POINTER_TO_MEMBER_FUNCTION_MUST_EVENTUALLY_RETURN_A_POINTER_TYPE = 123;
const int POINTER_TO_MEMBER_FUNCTION_MUST_EVENTUALLY_RETURN_A_POINTER_TO_CLASSTYPE = 124;
const int MEMBER_MUST_BE_A_VARIABLE_OR_A_FUNCTION = 125;
const int SUPPRESSED_MEMBER_FUNCTION_CANNOT_HAVE_IMPLEMENTATION = 126;
const int INVALID_FUNCTION_SPECIFIERS = 127;
const int CANNOT_CALL_SUPPRESSED_MEMBER_FUNCTION = 128;
const int DELEGATE_NEEDS_FUNCTIONSET_ARGUMENT = 129;
const int CLASS_DELEGATE_FIRST_ARG_MUST_BE_POINTER_TO_CLASS_OBJECT = 130;
const int CLASS_DELEGATE_SECOND_ARG_MUST_MEMBER_FUNCTION = 131;
const int ARGUMENT_HAS_NO_TYPE = 132;
const int TYPEPARAMETER_NOT_FOUND = 133;
const int TYPEPARAMETER_NOT_BOUND = 134;
const int BOUND_TEMPLATE_PARAMETER_HAS_NO_TYPE = 135;
const int IS_CONSTRAINT_OBJECT_NOT_CONCEPT_OR_TYPE = 136;
const int IS_CONSTRAINT_TYPE_NOT_EQUAL_TO_REQUIRED_TYPE = 137;
const int TYPE_DOES_NOT_SATISFY_REQUIREMENTS_OF_CONCEPT = 138;
const int NO_CONSTRUCTOR_WITH_SIGNATURE = 139;
const int NO_DESTRUCTOR = 140;
const int NO_FUNCTION_WITH_SIGNATURE = 141;
const int FUNCTION_RETURN_TYPE_DOES_NOT_MATCH = 142;
const int NO_ASSOCIATED_TYPE = 143;
const int ARCHETYPE_NOT_CLASS_TYPE = 144;
const int CONSTRAINED_TEMPLATE_DOES_NOT_TYPECHECK = 145;
const int CONCEPT_HAS_NO_OVERLOAD_TAKING_ONE_PARAMETER = 146;
const int CONCEPT_HAS_NO_OVERLOAD_TAKING_N_PARAMETERS = 147;
const int CONSTRAINT_OBJECT_NOT_CONCEPT = 148;
const int WRONG_NUMBER_OF_ARCHETYPES = 149;
const int CONCEPT_HAS_EXTRA_PARAMETERS = 150;
const int CIRCULAR_CLASS_DEPENDENCY_DETECTED = 151;
const int ENUMERATION_CONSTANT_NOT_INTEGRAL_CONSTANT = 152;
const int CANNOT_EVALUATE = 153;
const int CANNOT_MAKE_VALUE = 154;
const int NOTHROW_FUNCTION_CANNOT_CALL_FUNCTIONS_THAT_CAN_THROW = 155;
const int NOTHROW_FUNCTION_CANNOT_THROW = 156;
const int ASSERTION_EXPRESSION_IS_NOT_BOOLEAN_EXPRESSION = 157;
const int SYSTEM_EXCEPTION_HAS_NO_TYPE = 158;
const int EXCEPTIONS_MUST_BE_DERIVED_FROM_SYSTEM_EXCEPTION_CLASS = 159;
const int ARGUMENT_HAS_CANNOT_BE_A_FUNCTIONSET = 160;
const int DELEGATE_MUST_HAVE_RETURN_TYPE = 161;
const int OBJECT_HAS_NO_TYPE = 162;
const int CLASS_HAS_NO_BASECLASS = 163;
const int DEFAULT_MEMBER_FUNCTION_CANNOT_HAVE_IMPLEMENTATION = 164;
const int CANNOT_INVOKE = 165;
const int TEMPLATE_ARGUMENTS_MISSING = 166;
const int NO_CONVERSION_TO_INT_EXIST = 167;
const int MEMBERFUNCTION_NAME_DOES_NOT_MATCH = 168;
const int INVALID_MEMBERFUNCTION_INDEX = 169;
const int CLASSTEMPLATE_NOT_FOUND = 170;
const int TEMPLATE_ARGUMENT_MISMATCH = 171;
const int DESTRUCTOR_CANNOT_BE_ABSTRACT = 172;
// Code generation errors:
const int PROGRAM_DOES_NOT_CONTAIN_MAIN = 1;
const int MAIN_DOES_NOT_CONTAIN_OVERLOADS = 2;
const int MAIN_CONTAINS_MORE_THAT_ONE_OVERLOAD = 3;
const int MAIN_NUM_PARAMETERS_NOT_0_OR_2 = 4;
const int MAIN_FIRST_PARAM_SHOULD_BE_INT = 5;
const int MAIN_SECOND_PARAM_SHOULD_BE_CHARPTRPTR = 6;
const int MAIN_RETURN_TYPE_SHOULD_BE_INT = 7;
// Assembly errors:
const int ASSEMBLY_ERROR = 1;
// Link errors:
const int LINK_ERROR = 1;
// GCC errors:
const int GCC_ERROR = 1;
// Internal errors:
const int ASSERTION_FAILED = 1;
const int STD_EXCEPTION = 2;
const int ACCESS_VIOLATION = 3;
} } // namespace Cm::Core
#endif // CM_CORE_ERROR_INCLUDED