aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-08-26 00:44:43 +0200
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-08-26 00:44:43 +0200
commit679ffb09d45bc86d8fb98439f7488924070fc7e8 (patch)
tree364fd6acb41f2eef708e598695e8f051d5c43535 /qtmips_gui
parent6c09f661b83dd13a8403243c1441efa5c4900538 (diff)
downloadqtmips-679ffb09d45bc86d8fb98439f7488924070fc7e8.tar.gz
qtmips-679ffb09d45bc86d8fb98439f7488924070fc7e8.tar.bz2
qtmips-679ffb09d45bc86d8fb98439f7488924070fc7e8.zip
Add #pragma processing to integrated assembler and its usage to control windows.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_gui')
-rw-r--r--qtmips_gui/mainwindow.cpp75
-rw-r--r--qtmips_gui/mainwindow.h3
2 files changed, 75 insertions, 3 deletions
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp
index 09fe660..2b1a92b 100644
--- a/qtmips_gui/mainwindow.cpp
+++ b/qtmips_gui/mainwindow.cpp
@@ -42,6 +42,7 @@
#include <QFileInfo>
#include <QMessageBox>
#include <QTextDocument>
+#include <QMetaObject>
#include <iostream>
#include "mainwindow.h"
@@ -373,11 +374,12 @@ void MainWindow::print_action() {
#endif // QTMIPS_WITH_PRINTING
}
-#define SHOW_HANDLER(NAME, DEFAULT_AREA) void MainWindow::show_##NAME() { \
+#define SHOW_HANDLER(NAME, DEFAULT_AREA) \
+ void MainWindow::show_##NAME() { \
show_dockwidget(NAME, DEFAULT_AREA); \
} \
-SHOW_HANDLER(registers, Qt::RightDockWidgetArea)
+SHOW_HANDLER(registers, Qt::TopDockWidgetArea)
SHOW_HANDLER(program, Qt::LeftDockWidgetArea)
SHOW_HANDLER(memory, Qt::RightDockWidgetArea)
SHOW_HANDLER(cache_program, Qt::RightDockWidgetArea)
@@ -385,7 +387,7 @@ SHOW_HANDLER(cache_data, Qt::RightDockWidgetArea)
SHOW_HANDLER(peripherals, Qt::RightDockWidgetArea)
SHOW_HANDLER(terminal, Qt::RightDockWidgetArea)
SHOW_HANDLER(lcd_display, Qt::RightDockWidgetArea)
-SHOW_HANDLER(cop0dock, Qt::RightDockWidgetArea)
+SHOW_HANDLER(cop0dock, Qt::TopDockWidgetArea)
SHOW_HANDLER(messages, Qt::BottomDockWidgetArea)
#undef SHOW_HANDLER
@@ -871,6 +873,73 @@ bool SimpleAsmWithEditorCheck::process_file(QString filename, QString *error_ptr
return !error_occured;
}
+bool SimpleAsmWithEditorCheck::process_pragma(QStringList &operands, QString filename,
+ int line_number, QString *error_ptr) {
+ (void)error_ptr;
+#if 0
+ static const QMap<QString, QDockWidget *MainWindow::*> pragma_how_map = {
+ {QString("registers"), static_cast<QDockWidget *MainWindow::*>(&MainWindow::registers)},
+ };
+#endif
+ if ((operands.count() < 2) || QString::compare(operands.at(0), "qtmips", Qt::CaseInsensitive))
+ return true;
+ QString op = operands.at(1).toLower();
+ if (op == "show") {
+ if (operands.count() < 3)
+ return true;
+ QString show_method = "show_" + operands.at(2);
+ QString show_method_sig = show_method + "()";
+ if (mainwindow->metaObject()->indexOfMethod(show_method_sig.toLatin1().data()) == -1) {
+ emit report_message(messagetype::MSG_WARNING, filename, line_number, 0,
+ "#pragma qtmisp show - unknown object " + operands.at(2), "");
+ return true;
+ }
+ QMetaObject::invokeMethod(mainwindow, show_method.toLatin1().data());
+ return true;
+ }
+ if (op == "tab") {
+ if ((operands.count() < 3) || error_occured)
+ return true;
+ if (!QString::compare(operands.at(2), "core", Qt::CaseInsensitive) &&
+ (mainwindow->central_window != nullptr) && (mainwindow->coreview != nullptr)) {
+ mainwindow->central_window->setCurrentWidget(mainwindow->coreview);
+ }
+ return true;
+ }
+ if (op == "focus") {
+ bool ok;
+ if (operands.count() < 4)
+ return true;
+ fixmatheval::FmeExpression expression;
+ fixmatheval::FmeValue value;
+ QString error;
+ ok = expression.parse(operands.at(3), error);
+ if (!ok) {
+ emit report_message(messagetype::MSG_WARNING, filename, line_number, 0, "epression parse error " + error, "");
+ return true;
+ }
+ ok = expression.eval(value, symtab, error);
+ if (!ok) {
+ emit report_message(messagetype::MSG_WARNING, filename, line_number, 0, "epression evaluation error " + error, "");
+ return true;
+ }
+ if (!QString::compare(operands.at(2), "memory", Qt::CaseInsensitive) && (mainwindow->memory != nullptr)) {
+ QMetaObject::invokeMethod(mainwindow->memory, "focus_addr", Qt::AutoConnection, Q_ARG(std::uint32_t, value));
+ return true;
+ }
+ if (!QString::compare(operands.at(2), "program", Qt::CaseInsensitive) && (mainwindow->program != nullptr)) {
+ QMetaObject::invokeMethod(mainwindow->program, "focus_addr", Qt::AutoConnection, Q_ARG(std::uint32_t, value));
+ return true;
+ }
+ emit report_message(messagetype::MSG_WARNING, filename, line_number, 0,
+ "unknown #pragma qtmisp focus unknown object " + operands.at(2), "");
+ return true;
+ }
+ emit report_message(messagetype::MSG_WARNING, filename, line_number, 0,
+ "unknown #pragma qtmisp " + op, "");
+ return true;
+}
+
void MainWindow::compile_source() {
bool error_occured = false;
if (current_srceditor == nullptr)
diff --git a/qtmips_gui/mainwindow.h b/qtmips_gui/mainwindow.h
index 976c21e..712faf4 100644
--- a/qtmips_gui/mainwindow.h
+++ b/qtmips_gui/mainwindow.h
@@ -175,6 +175,9 @@ public:
SimpleAsmWithEditorCheck(MainWindow *a_mainwindow, QObject *parent = nullptr) :
Super(parent), mainwindow(a_mainwindow) {}
bool process_file(QString filename, QString *error_ptr = nullptr) override;
+protected:
+ virtual bool process_pragma(QStringList &operands, QString filename = "",
+ int line_number = 0, QString *error_ptr = nullptr) override;
private:
MainWindow *mainwindow;
};