aboutsummaryrefslogtreecommitdiff
path: root/qtmips_machine/qtmipsexception.cpp
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2018-01-01 21:29:37 +0100
committerKarel Kočí <cynerd@email.cz>2018-01-01 21:29:37 +0100
commit7cc95c3a57a79864fa60de4827193fa7aadac92c (patch)
treec640ac942c2f395e6f4cef06b6d22b5cdfc878f3 /qtmips_machine/qtmipsexception.cpp
parent7e942e26074107153d4a553df22b83b96ee3deaa (diff)
downloadqtmips-7cc95c3a57a79864fa60de4827193fa7aadac92c.tar.gz
qtmips-7cc95c3a57a79864fa60de4827193fa7aadac92c.tar.bz2
qtmips-7cc95c3a57a79864fa60de4827193fa7aadac92c.zip
Simplify how we define exceptions
Exceptions definition was pretty much just copy and past. That can do preprocessor for us too so use it for it.
Diffstat (limited to 'qtmips_machine/qtmipsexception.cpp')
-rw-r--r--qtmips_machine/qtmipsexception.cpp42
1 files changed, 12 insertions, 30 deletions
diff --git a/qtmips_machine/qtmipsexception.cpp b/qtmips_machine/qtmipsexception.cpp
index d2b0622..278fbc8 100644
--- a/qtmips_machine/qtmipsexception.cpp
+++ b/qtmips_machine/qtmipsexception.cpp
@@ -4,7 +4,8 @@
using namespace machine;
-QtMipsException::QtMipsException(QTMIPS_ARGS_COMMON) {
+QtMipsException::QtMipsException(QString reason, QString ext, QString file, int line) {
+ this->name = "Exception";
this->reason = reason;
this->ext = ext;
this->file = file;
@@ -20,9 +21,10 @@ const char *QtMipsException::what() const throw() {
QString QtMipsException::msg(bool pos) const {
QString message;
+ message += name;
if (pos)
- message += QString("(") + QString(this->file) + QString(":") + QString::number(this->line) + QString(") ");
- message += this->reason;
+ message += QString(" (") + QString(this->file) + QString(":") + QString::number(this->line) + QString(")");
+ message += ": " + this->reason;
if (!this->ext.isEmpty()) {
message += QString(": ");
message += this->ext;
@@ -30,30 +32,10 @@ QString QtMipsException::msg(bool pos) const {
return message;
}
-
-QtMipsExceptionInput::QtMipsExceptionInput(QTMIPS_ARGS_COMMON)
- : QtMipsException(reason, ext, file, line) { }
-
-QtMipsExceptionRuntime::QtMipsExceptionRuntime(QTMIPS_ARGS_COMMON)
- : QtMipsException(reason, ext, file, line) { }
-
-QtMipsExceptionUnsupportedInstruction::QtMipsExceptionUnsupportedInstruction(QTMIPS_ARGS_COMMON)
- : QtMipsExceptionRuntime(reason, ext, file, line) { }
-
-QtMipsExceptionUnsupportedAluOperation::QtMipsExceptionUnsupportedAluOperation(QTMIPS_ARGS_COMMON)
- : QtMipsExceptionRuntime(reason, ext, file, line) { }
-
-QtMipsExceptionOverflow::QtMipsExceptionOverflow(QTMIPS_ARGS_COMMON)
- : QtMipsExceptionRuntime(reason, ext, file, line) { }
-
-QtMipsExceptionUnalignedJump::QtMipsExceptionUnalignedJump(QTMIPS_ARGS_COMMON)
- : QtMipsExceptionRuntime(reason, ext, file, line) { }
-
-QtMipsExceptionUnknownMemoryControl::QtMipsExceptionUnknownMemoryControl(QTMIPS_ARGS_COMMON)
- : QtMipsExceptionRuntime(reason, ext, file, line) { }
-
-QtMipsExceptionOutOfMemoryAccess::QtMipsExceptionOutOfMemoryAccess(QTMIPS_ARGS_COMMON)
- : QtMipsExceptionRuntime(reason, ext, file, line) { }
-
-QtMipsExceptionSanity::QtMipsExceptionSanity(QTMIPS_ARGS_COMMON)
- : QtMipsException(reason, ext, file, line) { }
+#define EXCEPTION(NAME, PARENT) \
+ QtMipsException##NAME::QtMipsException##NAME(QString reason, QString ext, QString file, int line) \
+ : QtMipsException##PARENT(reason, ext, file, line) { \
+ name = #NAME; \
+ }
+QTMIPS_EXCEPTIONS
+#undef EXCEPTION