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
|
#pragma once
#include "Utils/Exception.h"
#include "Core/Exception.h"
#include "Core/SrcPos.h"
#include "Value.h"
#include "ExprResult.h"
namespace storm {
STORM_PKG(core.lang);
class Named;
/**
* An error originating from the compiler itself.
*/
class EXCEPTION_EXPORT CompilerError : public Exception {
STORM_EXCEPTION;
public:
STORM_CTOR CompilerError() {}
};
/**
* Defines exceptions used by the compiler that originate from some location.
*/
class EXCEPTION_EXPORT CodeError : public CompilerError {
STORM_EXCEPTION;
public:
// Create.
STORM_CTOR CodeError(SrcPos where);
// Where is the error located?
SrcPos pos;
// Message.
virtual void STORM_FN message(StrBuf *to) const;
// Get only the text of the error, no position information.
virtual void STORM_FN messageText(StrBuf *to) const ABSTRACT;
// Get the error as a string.
Str *STORM_FN messageText() const;
};
/**
* Language definition error.
*/
class EXCEPTION_EXPORT LangDefError : public CompilerError {
STORM_EXCEPTION;
public:
LangDefError(const wchar *msg);
STORM_CTOR LangDefError(Str *msg);
virtual void STORM_FN message(StrBuf *to) const;
private:
Str *w;
};
/**
* Specific subclass when calling core:debug:throwError.
*/
class EXCEPTION_EXPORT DebugError : public Exception {
STORM_EXCEPTION;
public:
STORM_CTOR DebugError();
virtual void STORM_FN message(StrBuf *to) const;
};
/**
* Internal type error (something in C++ went wrong).
*/
class EXCEPTION_EXPORT InternalTypeError : public InternalError {
STORM_EXCEPTION;
public:
InternalTypeError(const wchar *context, Type *expected, Type *got);
STORM_CTOR InternalTypeError(Str *context, Type *expected, Type *got);
};
/**
* Name lookup error.
*/
class EXCEPTION_EXPORT LookupError : public CodeError {
STORM_EXCEPTION;
public:
STORM_CTOR LookupError(Str *msg);
STORM_CTOR LookupError(SrcPos pos, Str *msg);
virtual void STORM_FN messageText(StrBuf *to) const;
private:
Str *msg;
};
/**
* Some syntax error.
*/
class EXCEPTION_EXPORT SyntaxError : public CodeError {
STORM_EXCEPTION;
public:
SyntaxError(SrcPos where, const wchar *msg);
STORM_CTOR SyntaxError(SrcPos where, Str *msg);
virtual void STORM_FN messageText(StrBuf *to) const;
Str *text;
};
/**
* Type checking error.
*/
class EXCEPTION_EXPORT TypeError : public CodeError {
STORM_EXCEPTION;
public:
TypeError(SrcPos where, const wchar *msg);
STORM_CTOR TypeError(SrcPos where, Str *msg);
STORM_CTOR TypeError(SrcPos where, Value expected, ExprResult got);
STORM_CTOR TypeError(SrcPos where, Value expected, Value got);
virtual void STORM_FN messageText(StrBuf *to) const;
private:
Str *msg;
};
/**
* Error in type definitions.
*/
class EXCEPTION_EXPORT TypedefError : public CodeError {
STORM_EXCEPTION;
public:
TypedefError(SrcPos pos, const wchar *msg);
STORM_CTOR TypedefError(SrcPos pos, Str *msg);
virtual void STORM_FN messageText(StrBuf *to) const;
private:
Str *msg;
};
/**
* Error while handling built-in functions.
*/
class EXCEPTION_EXPORT BuiltInError : public CompilerError {
STORM_EXCEPTION;
public:
BuiltInError(const wchar *msg);
STORM_CTOR BuiltInError(Str *msg);
virtual void STORM_FN message(StrBuf *to) const;
private:
Str *msg;
};
/**
* Trying to instantiate an abstract class.
*/
class EXCEPTION_EXPORT InstantiationError : public CodeError {
STORM_EXCEPTION;
public:
InstantiationError(SrcPos pos, const wchar *msg);
InstantiationError(SrcPos pos, Str *msg);
virtual void STORM_FN messageText(StrBuf *to) const;
private:
Str *msg;
};
/**
* Error reloading/replacing an entity.
*/
class EXCEPTION_EXPORT ReplaceError : public CodeError {
STORM_EXCEPTION;
public:
ReplaceError(SrcPos pos, const wchar *msg);
STORM_CTOR ReplaceError(SrcPos pos, Str *msg);
virtual void STORM_FN messageText(StrBuf *to) const;
private:
Str *msg;
};
/**
* Exception during replacement of an active function.
*/
class EXCEPTION_EXPORT ActiveReplaceError : public ReplaceError {
STORM_EXCEPTION;
public:
// Create.
STORM_CTOR ActiveReplaceError(CodeError *src, Named *entity);
// Original exception.
CodeError *original;
// Identity we were updating.
Named *entity;
// Output.
virtual void STORM_FN messageText(StrBuf *to) const;
};
}
|