aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_gui')
-rw-r--r--qtmips_gui/mainwindow.cpp15
-rw-r--r--qtmips_gui/mainwindow.h14
2 files changed, 28 insertions, 1 deletions
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp
index cbee3e5..09fe660 100644
--- a/qtmips_gui/mainwindow.cpp
+++ b/qtmips_gui/mainwindow.cpp
@@ -858,6 +858,19 @@ void MainWindow::message_selected(messagetype::Type type, QString file, int line
central_window->setCurrentWidget(editor);
}
+bool SimpleAsmWithEditorCheck::process_file(QString filename, QString *error_ptr) {
+ SrcEditor *editor = mainwindow->source_editor_for_file(filename, false);
+ if (editor == nullptr)
+ return Super::process_file(filename, error_ptr);
+ QTextDocument *doc = editor->document();
+ int ln = 1;
+ for ( QTextBlock block = doc->begin(); block.isValid(); block = block.next(), ln++) {
+ QString line = block.text();
+ process_line(line, filename, ln);
+ }
+ return !error_occured;
+}
+
void MainWindow::compile_source() {
bool error_occured = false;
if (current_srceditor == nullptr)
@@ -883,7 +896,7 @@ void MainWindow::compile_source() {
QTextDocument *doc = editor->document();
emit clear_messages();
- SimpleAsm sasm;
+ SimpleAsmWithEditorCheck sasm(this);
connect(&sasm, SIGNAL(report_message(messagetype::Type,QString,int,int,QString,QString)),
this, SIGNAL(report_message(messagetype::Type,QString,int,int,QString,QString)));
diff --git a/qtmips_gui/mainwindow.h b/qtmips_gui/mainwindow.h
index 13c8295..976c21e 100644
--- a/qtmips_gui/mainwindow.h
+++ b/qtmips_gui/mainwindow.h
@@ -58,10 +58,12 @@
#include "qtmipsmachine.h"
#include "machineconfig.h"
#include "srceditor.h"
+#include "simpleasm.h"
class MainWindow : public QMainWindow {
Q_OBJECT
+ friend class SimpleAsmWithEditorCheck;
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
@@ -165,4 +167,16 @@ private:
bool ignore_unsaved;
};
+class SimpleAsmWithEditorCheck : public SimpleAsm {
+ Q_OBJECT
+ using Super = SimpleAsm;
+
+public:
+ SimpleAsmWithEditorCheck(MainWindow *a_mainwindow, QObject *parent = nullptr) :
+ Super(parent), mainwindow(a_mainwindow) {}
+ bool process_file(QString filename, QString *error_ptr = nullptr) override;
+private:
+ MainWindow *mainwindow;
+};
+
#endif // MAINWINDOW_H