1
2
3
4
5
6 #ifndef CMAJOR_SYMBOLS_EXCEPTION_INCLUDED
7 #define CMAJOR_SYMBOLS_EXCEPTION_INCLUDED
8 #include <cmajor/symbols/SymbolsApi.hpp>
9 #include <sngxml/dom/Element.hpp>
10 #include <soulng/util/Json.hpp>
11 #include <soulng/lexer/Span.hpp>
12 #include <boost/uuid/uuid.hpp>
13
14 namespace cmajor { namespace symbols {
15
16 using namespace soulng::util;
17 using soulng::lexer::Span;
18
19 class Module;
20
21 std::string Expand(const std::string& errorMessage, const Span& span, const boost::uuids::uuid& moduleId);
22 std::string Expand(const std::string& errorMessage, const Span& primarySpan, const boost::uuids::uuid& primaryModuleId, const Span& referenceSpan, const boost::uuids::uuid& referenceModuleId);
23 std::string Expand(const std::string& errorMessage, const Span& primarySpan, const boost::uuids::uuid& primaryModuleId, const Span& referenceSpan, const boost::uuids::uuid& referenceModuleId,
24 const std::string& title);
25 std::string Expand(const std::string& errorMessage, const Span& span, const boost::uuids::uuid& moduleId, const std::std::vector<std::std::pair<Span, boost::uuids::uuid>>&references);
26 std::string Expand(const std::string& errorMessage, const Span& span, const boost::uuids::uuid& moduleId, const std::std::vector<std::std::pair<Span, boost::uuids::uuid>>&references,
27 const std::string& title);
28
29 std::unique_ptr<JsonObject> SpanToJson(Module* module, const Span& span);
30 std::unique_ptr<sngxml::dom::Element> SpanToDomElement(Module* module, const Span& span);
31
32 class Exception
33 {
34 public:
35 Exception(const std::string& message_, const Span& defined_, const boost::uuids::uuid& definedModuleId_);
36 Exception(const std::string& message_, const Span& defined_, const boost::uuids::uuid& definedModuleId_, const Span& referenced_, const boost::uuids::uuid& referencedModuleId_);
37 Exception(const std::string& message_, const Span& defined_, const boost::uuids::uuid& definedModuleId_, const std::std::vector<std::std::pair<Span, boost::uuids::uuid>>&references_);
38 virtual ~Exception();
39 const std::string& What() const { return what; }
40 const std::string& Message() const { return message; }
41 const Span& Defined() const { return defined; }
42 const boost::uuids::uuid& DefinedModuleId() const { return definedModuleId; }
43 const std::std::vector<std::std::pair<Span, boost::uuids::uuid>>&References() const{returnreferences;}
44 std::unique_ptr<JsonValue> ToJson() const;
45 void AddToDiagnosticsElement(sngxml::dom::Element* diagnosticsElement) const;
46 private:
47 std::string what;
48 std::string message;
49 Span defined;
50 boost::uuids::uuid definedModuleId;
51 std::vector<std::std::pair<Span, boost::uuids::uuid>>references;
52 };
53
54 class ModuleImmutableException : public Exception
55 {
56 public:
57 ModuleImmutableException(Module* module_, Module* immutableModule, const Span& defined_, const Span& referenced_);
58 };
59
60 class SymbolCheckException : public Exception
61 {
62 public:
63 SymbolCheckException(const std::string& message_, const Span& defined_, const boost::uuids::uuid& moduleId_);
64 };
65
66 class CastOverloadException : public Exception
67 {
68 public:
69 CastOverloadException(const std::string& message_, const Span& defined_, const boost::uuids::uuid& definedModuleId_);
70 CastOverloadException(const std::string& message_, const Span& defined_, const boost::uuids::uuid& definedModuleId_, const Span& referenced_, const boost::uuids::uuid& referencedModuleId_);
71 CastOverloadException(const std::string& message_, const Span& defined_, const boost::uuids::uuid& definedModuleId_, const std::std::vector<std::std::pair<Span, boost::uuids::uuid>>&references_);
72 };
73
74 class CannotBindConstToNonconstOverloadException : public Exception
75 {
76 public:
77 CannotBindConstToNonconstOverloadException(const std::string& message_, const Span& defined_, const boost::uuids::uuid& definedModuleId_);
78 CannotBindConstToNonconstOverloadException(const std::string& message_, const Span& defined_, const boost::uuids::uuid& definedModuleId_,
79 const Span& referenced_, const boost::uuids::uuid& referencedModuleId_);
80 CannotBindConstToNonconstOverloadException(const std::string& message_, const Span& defined_, const boost::uuids::uuid& definedModuleId_,
81 const std::std::vector<std::std::pair<Span, boost::uuids::uuid>>&references_);
82 };
83
84 class CannotAssignToConstOverloadException : public Exception
85 {
86 public:
87 CannotAssignToConstOverloadException(const std::string& message_, const Span& defined_, const boost::uuids::uuid& definedModuleId_);
88 CannotAssignToConstOverloadException(const std::string& message_, const Span& defined_, const boost::uuids::uuid& definedModuleId_,
89 const Span& referenced_, const boost::uuids::uuid& referencedModuleId_);
90 CannotAssignToConstOverloadException(const std::string& message_, const Span& defined_, const boost::uuids::uuid& definedModuleId_,
91 const std::std::vector<std::std::pair<Span, boost::uuids::uuid>>&references_);
92 };
93
94 class NoViableFunctionException : public Exception
95 {
96 public:
97 NoViableFunctionException(const std::string& message_, const Span& defined_, const boost::uuids::uuid& definedModuleId_);
98 NoViableFunctionException(const std::string& message_, const Span& defined_, const boost::uuids::uuid& definedModuleId_, const Span& referenced_, const boost::uuids::uuid& referencedModuleId_);
99 NoViableFunctionException(const std::string& message_, const Span& defined_, const boost::uuids::uuid& definedModuleId_, const std::std::vector<std::std::pair<Span, boost::uuids::uuid>>&references_);
100 };
101
102 } }
103
104 #endif // CMAJOR_SYMBOLS_EXCEPTION_INCLUDED