Disable editor when bin- or ELF file is loaded
MODIFY
main.cpp
main.cpp
@@ -22,8 +22,6 @@ int main(int argc, char** argv) {
QString ext = QFileInfo(argv[1]).suffix();
if (ext == QString("bin")) {
m.loadBinaryFile(argv[1]);
- } else if (ext == "asm" || ext == "s") {
- m.loadAssemblyFile(argv[1]);
} else {
QMessageBox msg;
msg.setText(

MODIFY
resources/icons/icons.qrc
resources/icons/icons.qrc
<file>run.svg</file>
<file>cancel.svg</file>
<file>saveas.svg</file>
+ <file>notepad.svg</file>
</qresource>
</RCC>

ADD
resources/icons/notepad.svg
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!-- Generator: Adobe Illustrator 21.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve" width="512" height="512">
+<g>
+ <g>
+ <g>
+ <path style="fill:#DFEEFA;" d="M345.168,512H58.737c-24.813,0-45-20.187-45-45v-400c0-8.284,6.716-15,15-15h346.432 c8.284,0,15,6.716,15,15v400C390.168,491.813,369.981,512,345.168,512z"/>
+ </g>
+ <path style="fill:#C9DFF7;" d="M375.168,52H201.953v460h143.216c24.813,0,45-20.187,45-45v-400 C390.168,58.716,383.453,52,375.168,52z"/>
+ <g>
+ <g>
+ <path style="fill:#606A70;" d="M79.273,112.714c-8.284,0-15-6.716-15-15V15c0-8.284,6.716-15,15-15s15,6.716,15,15v82.714 C94.273,105.998,87.557,112.714,79.273,112.714z"/>
+ </g>
+ <g>
+ <path style="fill:#606A70;" d="M140.702,112.714c-8.284,0-15-6.716-15-15V15c0-8.284,6.716-15,15-15s15,6.716,15,15v82.714 C155.702,105.998,148.986,112.714,140.702,112.714z"/>
+ </g>
+ <g>
+ <path style="fill:#606A70;" d="M201.953,112.714c-8.284,0-15-6.716-15-15V15c0-8.284,6.716-15,15-15c8.284,0,15,6.716,15,15 v82.714C216.953,105.998,210.237,112.714,201.953,112.714z"/>
+ </g>
+ <g>
+ <path style="fill:#414952;" d="M263.56,112.714c-8.284,0-15-6.716-15-15V15c0-8.284,6.716-15,15-15c8.284,0,15,6.716,15,15 v82.714C278.56,105.998,271.845,112.714,263.56,112.714z"/>
+ </g>
+ <g>
+ <path style="fill:#414952;" d="M324.99,112.714c-8.284,0-15-6.716-15-15V15c0-8.284,6.716-15,15-15s15,6.716,15,15v82.714 C339.99,105.998,333.274,112.714,324.99,112.714z"/>
+ </g>
+ </g>
+ <path style="fill:#414952;" d="M216.953,97.714V15c0-8.284-6.716-15-15-15v112.714 C210.237,112.714,216.953,105.998,216.953,97.714z"/>
+ </g>
+ <g>
+ <g>
+ <path style="fill:#82A0D2;" d="M202.131,195.897H88.558c-8.284,0-15-6.716-15-15c0-8.284,6.716-15,15-15h113.573 c8.284,0,15,6.716,15,15C217.131,189.182,210.415,195.897,202.131,195.897z"/>
+ </g>
+ <g>
+ <path style="fill:#82A0D2;" d="M314.99,255.897H88.558c-8.284,0-15-6.716-15-15c0-8.284,6.716-15,15-15H314.99 c8.284,0,15,6.716,15,15C329.99,249.181,323.274,255.897,314.99,255.897z"/>
+ </g>
+ <g>
+ <path style="fill:#82A0D2;" d="M279.348,315.896H88.558c-8.284,0-15-6.716-15-15s6.716-15,15-15h190.79c8.284,0,15,6.716,15,15 S287.632,315.896,279.348,315.896z"/>
+ </g>
+ <g>
+ <path style="fill:#82A0D2;" d="M229.047,375.896H88.558c-8.284,0-15-6.716-15-15c0-8.284,6.716-15,15-15h140.489 c8.284,0,15,6.716,15,15C244.047,369.18,237.331,375.896,229.047,375.896z"/>
+ </g>
+ <g>
+ <path style="fill:#82A0D2;" d="M201.774,435.895H88.558c-8.284,0-15-6.716-15-15c0-8.284,6.716-15,15-15h113.216 c8.284,0,15,6.716,15,15C216.774,429.179,210.058,435.895,201.774,435.895z"/>
+ </g>
+ <g>
+ <path style="fill:#9EBBDB;" d="M216.774,420.895c0-8.284-6.716-15-15-15v30C210.058,435.895,216.774,429.179,216.774,420.895z"/>
+ <path style="fill:#5877A6;" d="M229.047,345.896h-27.273v30h27.273c8.284,0,15-6.716,15-15 C244.047,352.611,237.331,345.896,229.047,345.896z"/>
+ <path style="fill:#5877A6;" d="M279.348,285.896h-77.574v30h77.574c8.284,0,15-6.716,15-15S287.632,285.896,279.348,285.896z"/>
+ <path style="fill:#5877A6;" d="M314.99,225.897H201.774v30H314.99c8.284,0,15-6.716,15-15 C329.99,232.613,323.274,225.897,314.99,225.897z"/>
+ <path style="fill:#5877A6;" d="M202.131,165.897h-0.357v30h0.357c8.284,0,15-6.716,15-15 C217.131,172.613,210.415,165.897,202.131,165.897z"/>
+ </g>
+ </g>
+ <g>
+ <g>
+ <path style="fill:#FFEDD6;" d="M201.778,435.896c-3.898,0-7.736-1.519-10.61-4.394c-4.421-4.421-5.636-11.121-3.049-16.814 l35.355-77.781c0.762-1.677,1.814-3.174,3.087-4.438c2.125-2.11,12.493-12.493,12.493-12.493l63.6,63.679 c0,0-10.362,10.362-12.493,12.493c-1.255,1.255-2.738,2.293-4.398,3.048l-77.782,35.355 C205.99,435.456,203.875,435.896,201.778,435.896z"/>
+ </g>
+ <path style="fill:#FFDAAB;" d="M201.778,435.896c2.097,0,4.212-0.44,6.203-1.345l77.782-35.355 c1.66-0.754,3.144-1.793,4.398-3.048c2.131-2.131,12.493-12.493,12.493-12.493l-31.799-31.838l-79.686,79.686 C194.044,434.377,197.881,435.896,201.778,435.896z"/>
+ <g>
+ <path style="fill:#FFE645;" d="M226.523,332.507l194.942-194.939c8.5-8.5,19.8-13.181,31.82-13.181 c12.02,0,23.321,4.681,31.82,13.181c17.545,17.545,17.545,46.093,0.001,63.639l-194.943,194.94L226.523,332.507z"/>
+ </g>
+ <path style="fill:#FFB500;" d="M290.162,396.147l194.943-194.94c17.545-17.545,17.544-46.094-0.001-63.639l-226.76,226.76 L290.162,396.147z"/>
+
+ <rect x="372.323" y="170.349" transform="matrix(0.7071 -0.7071 0.7071 0.7071 -32.9739 351.09)" style="fill:#606A70;" width="69.999" height="90"/>
+
+ <rect x="388.233" y="208.759" transform="matrix(0.7071 -0.7071 0.7071 0.7071 -39.5638 367.0003)" style="fill:#414952;" width="70" height="44.999"/>
+ <g>
+ <path style="fill:#FF826E;" d="M485.104,137.568c-8.499-8.5-19.8-13.181-31.82-13.181c-12.02,0-23.32,4.681-31.82,13.181 l-21.213,21.213l63.64,63.639l21.214-21.213C502.65,183.661,502.649,155.113,485.104,137.568z"/>
+ <path style="fill:#FE5857;" d="M463.891,222.42l21.214-21.213c17.545-17.545,17.544-46.094-0.001-63.639L432.072,190.6 L463.891,222.42z"/>
+ </g>
+ <g>
+ <path style="fill:#416191;" d="M197.136,394.851l-9.017,19.837c-2.587,5.692-1.373,12.392,3.049,16.814 c2.874,2.875,6.712,4.394,10.61,4.394c2.097,0,4.212-0.44,6.203-1.345l19.838-9.017L197.136,394.851z"/>
+ <path style="fill:#28415E;" d="M201.778,435.896c2.097,0,4.212-0.44,6.203-1.345l19.838-9.017l-15.34-15.34l-21.309,21.31 C194.044,434.377,197.881,435.896,201.778,435.896z"/>
+ </g>
+ </g>
+</g>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+</svg>

MODIFY
src/edittab.cpp
src/edittab.cpp
#include "edittab.h"
#include "ui_edittab.h"
+#include <QCheckBox>
+#include <QLabel>
+#include <QLineEdit>
#include <QMessageBox>
+#include <QPushButton>
#include "parser.h"
#include "processorhandler.h"
+#include "program.h"
namespace Ripes {
EditTab::EditTab(QToolBar* toolbar, QWidget* parent) : RipesTab(toolbar, parent), m_ui(new Ui::EditTab) {
m_ui->setupUi(this);
+ connect(m_ui->enableEditor, &QPushButton::clicked, this, &EditTab::enableEditor);
+
// Only add syntax highlighter for code edit view - not for translated code. This is assumed to be correct after a
// translation is complete
m_ui->assemblyedit->setupSyntaxHighlighter();
@@ -30,6 +37,20 @@ EditTab::EditTab(QToolBar* toolbar, QWidget* parent) : RipesTab(toolbar, parent)
connect(m_ui->assemblyedit, &CodeEditor::textChanged, this, &EditTab::assemble);
}
+void EditTab::loadFile(const LoadFileParams& fileParams) {
+ switch (fileParams.type) {
+ case FileType::Assembly:
+ loadAssemblyFile(fileParams);
+ break;
+ case FileType::FlatBinary:
+ loadFlatBinaryFile(fileParams);
+ break;
+ case FileType::Executable:
+ loadElfFile(fileParams);
+ break;
+ }
+}
+
QString EditTab::getAssemblyText() {
return m_ui->assemblyedit->toPlainText();
}
@@ -91,17 +112,41 @@ void EditTab::on_assemblyfile_toggled(bool checked) {
m_ui->binaryedit->clear();
}
-void EditTab::setInputMode(bool isAssembly) {
- /*
- if (isAssembly) {
- m_ui->assemblyfile->setChecked(true);
- } else {
- m_ui->binaryfile->setChecked(true);
+void EditTab::enableEditor() {
+ m_ui->editorStackedWidget->setCurrentIndex(0);
}
- */
+
+void EditTab::disableEditor() {
+ m_ui->editorStackedWidget->setCurrentIndex(1);
}
void EditTab::on_disassembledViewButton_toggled(bool checked) {
Q_UNUSED(checked)
}
+
+void EditTab::loadFlatBinaryFile(const LoadFileParams& params) {
+ m_ui->curInputSrcLabel->setText("Flat binary");
+ disableEditor();
+}
+
+void EditTab::loadAssemblyFile(const LoadFileParams& params) {
+ // ... load file
+ QFile file(params.filepath);
+ Parser::getParser()->clear();
+ clear();
+ if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ setAssemblyText(file.readAll());
+ file.close();
+ }
+
+ setDisassemblerText();
+ enableEditor();
+ emit programChanged(m_assembler->getProgram());
+}
+
+void EditTab::loadElfFile(const LoadFileParams& params) {
+ m_ui->curInputSrcLabel->setText("Executable (ELF)");
+ disableEditor();
+}
+
} // namespace Ripes

MODIFY
src/edittab.h
src/edittab.h
@@ -16,6 +16,7 @@ class EditTab;
}
class Assembler;
+class LoadFileParams;
class EditTab : public RipesTab {
Q_OBJECT
@@ -26,13 +27,14 @@ public:
void setAssemblyText(const QString& text);
void setDisassemblerText();
- void setInputMode(bool isAssembly);
QString getAssemblyText();
void newProgram();
void clear();
const QByteArray& getBinaryData();
+ void loadFile(const LoadFileParams&);
+
signals:
void programChanged(const Program& program);
@@ -45,6 +47,14 @@ private slots:
void on_disassembledViewButton_toggled(bool checked);
private:
+ void loadFlatBinaryFile(const LoadFileParams&);
+ void loadAssemblyFile(const LoadFileParams&);
+ void loadElfFile(const LoadFileParams&);
+
+ void setupActions();
+ void enableEditor();
+ void disableEditor();
+
Ui::EditTab* m_ui;
Assembler* m_assembler = nullptr;
};

MODIFY
src/edittab.ui
src/edittab.ui
<rect>
<x>0</x>
<y>0</y>
- <width>588</width>
- <height>439</height>
+ <width>1185</width>
+ <height>610</height>
</rect>
</property>
<property name="windowTitle">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
- <layout class="QHBoxLayout" name="horizontalLayout">
+ <widget class="QStackedWidget" name="stackedWidget_2">
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="page_3">
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <widget class="QSplitter" name="splitter">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="childrenCollapsible">
+ <bool>false</bool>
+ </property>
+ <widget class="QWidget" name="verticalLayoutWidget">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="text">
</property>
</spacer>
</item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QStackedWidget" name="editorStackedWidget">
+ <property name="currentIndex">
+ <number>1</number>
+ </property>
+ <widget class="QWidget" name="editorPage">
+ <layout class="QGridLayout" name="gridLayout_3">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="CodeEditor" name="assemblyedit"/>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="editorDisabledPage">
+ <layout class="QGridLayout" name="gridLayout_5">
+ <item row="0" column="0">
+ <widget class="QFrame" name="gridFrame">
+ <property name="frameShape">
+ <enum>QFrame::Box</enum>
+ </property>
+ <property name="lineWidth">
+ <number>1</number>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_4">
+ <item row="5" column="1">
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="2">
+ <spacer name="horizontalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="0" column="1">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="3">
+ <layout class="QGridLayout" name="gridLayout_6"/>
+ </item>
+ <item row="1" column="0">
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="1">
+ <layout class="QGridLayout" name="gridLayout_7">
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_7">
+ <property name="text">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Note:&lt;/span&gt; Enabling the editor will clear any currently loaded program from the simulator&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>&lt;b&gt;Current input source:&lt;/b&gt;</string>
+ </property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="curInputSrcLabel">
+ <property name="text">
+ <string>Foo</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QPushButton" name="enableEditor">
+ <property name="text">
+ <string>Enable editor</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="verticalLayoutWidget_2">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
</widget>
</item>
<item>
- <widget class="QRadioButton" name="disassembledViewButton">
+ <widget class="QRadioButton" name="binaryViewButton">
<property name="text">
- <string>Disassembled</string>
- </property>
- <property name="checked">
- <bool>true</bool>
+ <string>Binary</string>
</property>
<attribute name="buttonGroup">
<string notr="true">binaryViewButtons</string>
</widget>
</item>
<item>
- <widget class="QRadioButton" name="binaryViewButton">
+ <widget class="QRadioButton" name="disassembledViewButton">
<property name="text">
- <string>Binary</string>
+ <string>Disassembled</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">binaryViewButtons</string>
</item>
</layout>
</item>
- </layout>
- </item>
<item>
- <widget class="QStackedWidget" name="stackedWidget_2">
- <property name="currentIndex">
- <number>0</number>
- </property>
- <widget class="QWidget" name="page_3">
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0">
- <widget class="QSplitter" name="splitter">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <widget class="CodeEditor" name="assemblyedit">
- <property name="tabStopWidth">
- <number>20</number>
- </property>
- </widget>
- <widget class="CodeEditor" name="binaryedit">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="readOnly">
- <bool>true</bool>
- </property>
- <property name="tabStopWidth">
- <number>20</number>
- </property>
+ <widget class="CodeEditor" name="binaryedit"/>
+ </item>
+ </layout>
</widget>
</widget>
</item>

MODIFY
src/loaddialog.cpp
src/loaddialog.cpp
@@ -77,12 +77,12 @@ void LoadDialog::openFileButtonTriggered() {
}
case FileType::FlatBinary: {
title = "Open binary file";
- filter = "All files (*.*)";
+ filter = "All files (*)";
break;
}
case FileType::Executable: {
title = "Open executable (ELF) file";
- filter = "All files (*.*)";
+ filter = "All files (*)";
break;
}
}

MODIFY
src/loaddialog.h
src/loaddialog.h
@@ -12,13 +12,6 @@ namespace Ui {
class LoadDialog;
}
-struct LoadFileParams {
- QString filepath;
- FileType type;
- uint32_t binaryEntryPoint;
- uint32_t binaryLoadAt;
-};
-
class LoadDialog : public QDialog {
Q_OBJECT

MODIFY
src/mainwindow.cpp
src/mainwindow.cpp
@@ -93,13 +93,11 @@ void MainWindow::setupMenus() {
newAction->setShortcut(QKeySequence::New);
connect(newAction, &QAction::triggered, this, &MainWindow::newProgramTriggered);
m_ui->menuFile->addAction(newAction);
- m_editTab->getToolbar()->addAction(newAction);
const QIcon loadIcon = QIcon(":/icons/loadfile.svg");
auto* loadAction = new QAction(loadIcon, "Load program", this);
loadAction->setShortcut(QKeySequence::Open);
connect(loadAction, &QAction::triggered, [=] { this->loadFileTriggered(); });
- m_editTab->getToolbar()->addAction(loadAction);
m_ui->menuFile->addAction(loadAction);
m_ui->menuFile->addSeparator();
@@ -113,14 +111,12 @@ void MainWindow::setupMenus() {
auto* saveAction = new QAction(saveIcon, "Save File", this);
saveAction->setShortcut(QKeySequence::Save);
connect(saveAction, &QAction::triggered, this, &MainWindow::saveFilesTriggered);
- m_editTab->getToolbar()->addAction(saveAction);
m_ui->menuFile->addAction(saveAction);
const QIcon saveAsIcon = QIcon(":/icons/saveas.svg");
auto* saveAsAction = new QAction(saveAsIcon, "Save File As...", this);
saveAsAction->setShortcut(QKeySequence::SaveAs);
connect(saveAsAction, &QAction::triggered, this, &MainWindow::saveFilesAsTriggered);
- m_editTab->getToolbar()->addAction(saveAsAction);
m_ui->menuFile->addAction(saveAsAction);
m_ui->menuFile->addSeparator();
@@ -146,8 +142,10 @@ void MainWindow::setupExamplesMenu(QMenu* parent) {
if (!assemblyExamples.isEmpty()) {
for (const auto& fileName : assemblyExamples) {
parent->addAction(fileName, [=] {
- this->loadAssemblyFile(QString(":/examples/assembly/") + fileName);
- m_currentFile = QString();
+ LoadFileParams parms;
+ parms.filepath = QString(":/examples/assembly/") + fileName;
+ parms.type = FileType::Assembly;
+ m_editTab->loadFile(parms);
});
}
}
@@ -162,68 +160,16 @@ void MainWindow::loadFileTriggered() {
if (!diag.exec())
return;
- const auto& fileParams = diag.getParams();
-
- switch (fileParams.type) {
- case FileType::Assembly:
- loadAssemblyFile(fileParams);
- break;
- case FileType::FlatBinary:
- loadFlatBinaryFile(fileParams);
- break;
- case FileType::Executable:
- loadElfFile(fileParams);
- break;
- }
+ m_editTab->loadFile(diag.getParams());
}
-void MainWindow::loadFlatBinaryFile(const LoadFileParams& params) {}
-
-void MainWindow::loadAssemblyFile(const LoadFileParams& params) {
- // ... load file
- QFile file(params.filepath);
- m_editTab->setInputMode(true);
- Parser::getParser()->clear();
- m_editTab->clear();
- m_processorTab->restart();
- if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- m_editTab->setAssemblyText(file.readAll());
- file.close();
- }
- m_currentFile = params.filepath;
- m_editTab->setDisassemblerText();
-}
-
-void MainWindow::loadElfFile(const LoadFileParams& params) {}
-
void MainWindow::loadBinaryFile(QString filename) {
- m_editTab->setInputMode(false);
m_processorTab->restart();
Parser::getParser()->loadBinaryFile(filename);
m_editTab->setDisassemblerText();
emit update();
}
-void MainWindow::loadAssemblyFile(QString filename) {
- if (filename == QString()) {
- filename = QFileDialog::getOpenFileName(this, "Open assembly file", "", "Assembly file (*.s *.as *.asm)");
- }
- if (!filename.isNull()) {
- // ... load file
- QFile file(filename);
- m_editTab->setInputMode(true);
- Parser::getParser()->clear();
- m_editTab->clear();
- m_processorTab->restart();
- if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- m_editTab->setAssemblyText(file.readAll());
- file.close();
- }
- m_currentFile = filename;
- m_editTab->setDisassemblerText();
- }
-}
-
void MainWindow::about() {
AboutWidget about;
about.exec();

MODIFY
src/mainwindow.h
src/mainwindow.h
@@ -28,7 +28,6 @@ public:
~MainWindow() override;
void loadBinaryFile(QString fileName = QString());
- void loadAssemblyFile(QString fileName = QString());
void run();
@@ -52,10 +51,6 @@ signals:
void updateMemoryTab();
private:
- void loadFlatBinaryFile(const LoadFileParams&);
- void loadAssemblyFile(const LoadFileParams&);
- void loadElfFile(const LoadFileParams&);
-
void loadFile(const QString& filename, FileType type);
void setupMenus();

MODIFY
src/program.h
src/program.h
#pragma once
#include <QByteArray>
+#include <QString>
#include <vector>
namespace Ripes {
enum class FileType { Assembly, FlatBinary, Executable };
+struct LoadFileParams {
+ QString filepath;
+ FileType type;
+ uint32_t binaryEntryPoint;
+ uint32_t binaryLoadAt;
+};
+
/**
* @brief The Program struct
* Wrapper around a program to be loaded into simulator memory. Text section shall contain the instructions of the

Disable editor when bin- or ELF file is loaded