aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_gui')
-rw-r--r--qtmips_gui/mainwindow.cpp9
-rw-r--r--qtmips_gui/programdock.cpp7
-rw-r--r--qtmips_gui/programdock.h1
-rw-r--r--qtmips_gui/programmodel.cpp7
-rw-r--r--qtmips_gui/programmodel.h2
5 files changed, 20 insertions, 6 deletions
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp
index e3ad8dd..766a28c 100644
--- a/qtmips_gui/mainwindow.cpp
+++ b/qtmips_gui/mainwindow.cpp
@@ -620,6 +620,7 @@ void MainWindow::compile_source() {
int ln = 1;
for ( QTextBlock block = doc->begin(); block.isValid(); block = block.next(), ln++) {
+ QString error;
int pos;
QString label = "";
QString line = block.text();
@@ -641,7 +642,6 @@ void MainWindow::compile_source() {
QString op = line.split(" ").at(0).toUpper();
if (op == ".ORG") {
bool ok;
- QString error;
fixmatheval::FmeExpression expression;
fixmatheval::FmeValue value;
ok = expression.parse(line.mid(op.size()), error);
@@ -659,7 +659,6 @@ void MainWindow::compile_source() {
continue;
}
if (op == ".WORD") {
- QString error;
foreach (QString s, line.mid(op.size()).split(",")) {
s = s.simplified();
std::uint32_t val = 0;
@@ -677,14 +676,14 @@ void MainWindow::compile_source() {
}
std::uint32_t inst[2] = {0, 0};
- ssize_t size = machine::Instruction::code_from_string(inst, 8, line,
+ ssize_t size = machine::Instruction::code_from_string(inst, 8, line, error,
address, &reloc, ln, true);
if (size < 0) {
error_line = ln;
editor->setCursorToLine(error_line);
QMessageBox::critical(this, "QtMips Error",
- tr("line %1 instruction %2 parse error.")
- .arg(QString::number(ln), line));
+ tr("line %1 instruction %2 parse error - %3.")
+ .arg(QString::number(ln), line, error));
break;
}
std::uint32_t *p = inst;
diff --git a/qtmips_gui/programdock.cpp b/qtmips_gui/programdock.cpp
index c5f40d8..bcdbd23 100644
--- a/qtmips_gui/programdock.cpp
+++ b/qtmips_gui/programdock.cpp
@@ -39,6 +39,8 @@
#include <QTableView>
#include <QComboBox>
#include <QHeaderView>
+#include <QMessageBox>
+
#include "programdock.h"
#include "programmodel.h"
#include "programtableview.h"
@@ -103,6 +105,7 @@ ProgramDock::ProgramDock(QWidget *parent, QSettings *settings) : Super(parent) {
program_model, SLOT(toggle_hw_break(QModelIndex)));
connect(this, SIGNAL(stage_addr_changed(uint,std::uint32_t)),
program_model, SLOT(update_stage_addr(uint,std::uint32_t)));
+ connect(program_model, SIGNAL(report_error(QString)), this, SLOT(report_error(QString)));
}
void ProgramDock::setup(machine::QtMipsMachine *machine) {
@@ -166,3 +169,7 @@ void ProgramDock::update_follow_position() {
if (follow_source != FOLLOWSRC_NONE)
emit focus_addr(follow_addr[follow_source]);
}
+
+void ProgramDock::report_error(QString error) {
+ QMessageBox::critical(this, "QtMips Error", error);
+}
diff --git a/qtmips_gui/programdock.h b/qtmips_gui/programdock.h
index 0dec65d..50baa50 100644
--- a/qtmips_gui/programdock.h
+++ b/qtmips_gui/programdock.h
@@ -65,6 +65,7 @@ public slots:
void execute_inst_addr(std::uint32_t addr);
void memory_inst_addr(std::uint32_t addr);
void writeback_inst_addr(std::uint32_t addr);
+ void report_error(QString error);
private:
enum FollowSource {
FOLLOWSRC_NONE,
diff --git a/qtmips_gui/programmodel.cpp b/qtmips_gui/programmodel.cpp
index 0f3341f..b70ed34 100644
--- a/qtmips_gui/programmodel.cpp
+++ b/qtmips_gui/programmodel.cpp
@@ -256,6 +256,7 @@ bool ProgramModel::setData(const QModelIndex & index, const QVariant & value, in
if (role == Qt::EditRole)
{
bool ok;
+ QString error;
std::uint32_t address;
std::uint32_t data;
machine::MemoryAccess *mem;
@@ -274,8 +275,12 @@ bool ProgramModel::setData(const QModelIndex & index, const QVariant & value, in
mem->write_word(address, data);
break;
case 3:
- if (machine::Instruction::code_from_string(&data, 4, value.toString(), address) < 0)
+ if (machine::Instruction::code_from_string(&data, 4, value.toString(),
+ error, address) < 0) {
+ emit report_error(tr("instruction 1 parse error - %2.").arg(error));
+
return false;
+ }
mem->write_word(address, data);
break;
default:
diff --git a/qtmips_gui/programmodel.h b/qtmips_gui/programmodel.h
index a2eff4b..95d0e3f 100644
--- a/qtmips_gui/programmodel.h
+++ b/qtmips_gui/programmodel.h
@@ -93,6 +93,8 @@ public:
STAGEADDR_COUNT,
};
+signals:
+ void report_error(QString error);
public slots:
void setup(machine::QtMipsMachine *machine);
void check_for_updates();