diff --git a/external/VSRTL b/external/VSRTL index a7f17baf2..8cb60adf6 160000 --- a/external/VSRTL +++ b/external/VSRTL @@ -1 +1 @@ -Subproject commit a7f17baf2f5cee4a9946d987a74348ab75375d25 +Subproject commit 8cb60adf6f197638fe598ba232619c68aa601a38 diff --git a/src/assembler/assembler.h b/src/assembler/assembler.h index 2f219bba0..8d8c4048e 100644 --- a/src/assembler/assembler.h +++ b/src/assembler/assembler.h @@ -176,7 +176,7 @@ class Assembler : public AssemblerBase { // Join tokens QString joinedLine; const auto tokens = std::get(tokensVar); - for (const auto &token : qAsConst(tokens)) { + for (const auto &token : std::as_const(tokens)) { joinedLine += token + " "; } joinedLine.chop(1); // remove trailing ' ' diff --git a/src/assembler/gnudirectives.cpp b/src/assembler/gnudirectives.cpp index 6d75ea483..55bd9044a 100644 --- a/src/assembler/gnudirectives.cpp +++ b/src/assembler/gnudirectives.cpp @@ -11,7 +11,7 @@ static QString numTokensError(unsigned expected, const TokenizedSrcLine &line) { std::to_string(line.tokens.size()) + "["); for (auto t : llvm::enumerate(line.tokens)) { err += t.value(); - if (t.index() < (line.tokens.size() - 1)) + if (static_cast(t.index()) < (line.tokens.size() - 1)) err += ", "; }; err += "]."; diff --git a/src/cachesim/cacheplotview.cpp b/src/cachesim/cacheplotview.cpp index c424ad91e..45a4f4cee 100644 --- a/src/cachesim/cacheplotview.cpp +++ b/src/cachesim/cacheplotview.cpp @@ -92,14 +92,14 @@ QPixmap CachePlotView::getPlotPixmap() { itemsToHide << marker->marker; } - for (const auto &i : qAsConst(itemsToHide)) { + for (const auto &i : std::as_const(itemsToHide)) { if (i) i->hide(); } QPixmap p = grab(); - for (const auto &i : qAsConst(itemsToHide)) { + for (const auto &i : std::as_const(itemsToHide)) { if (i) i->show(); } diff --git a/src/cachesim/cacheplotwidget.cpp b/src/cachesim/cacheplotwidget.cpp index 475028e74..b12c873a4 100644 --- a/src/cachesim/cacheplotwidget.cpp +++ b/src/cachesim/cacheplotwidget.cpp @@ -344,7 +344,7 @@ CachePlotWidget::gatherData(unsigned fromCycle) const { void resample(QLineSeries *series, unsigned target, double &step) { QVector newPoints; - const auto &oldPoints = series->pointsVector(); + const auto &oldPoints = series->points(); step = (oldPoints.last().x() / static_cast(target)) * 2; // *2 to account for steps newPoints.reserve(target); @@ -356,7 +356,7 @@ void resample(QLineSeries *series, unsigned target, double &step) { // sanity check QPointF plast = QPointF(0, 0); bool first = true; - for (const auto &p : qAsConst(newPoints)) { + for (const auto &p : std::as_const(newPoints)) { if (!first) { Q_ASSERT(p.x() - plast.x() < step * 1.1); first = false; @@ -426,8 +426,8 @@ void CachePlotWidget::updateRatioPlot() { QList newPoints; QList newWindowPoints; QPointF lastPoint; - if (m_series->pointsVector().size() > 0) { - lastPoint = m_series->pointsVector().constLast(); + if (m_series->points().size() > 0) { + lastPoint = m_series->points().constLast(); } else { lastPoint = QPointF(-1, 0); } @@ -489,7 +489,7 @@ void CachePlotWidget::updateRatioPlot() { // points, and we resample at a 2x ratio const int maxPoints = RipesSettings::value(RIPES_SETTING_CACHE_MAXPOINTS).toInt() * 2 * 2; - if (m_series->pointsVector().size() >= maxPoints) { + if (m_series->points().size() >= maxPoints) { resample(m_series, maxPoints / 2, m_xStep); } diff --git a/src/cachesim/cacheview.cpp b/src/cachesim/cacheview.cpp index 74d34b8f3..a2dac7196 100644 --- a/src/cachesim/cacheview.cpp +++ b/src/cachesim/cacheview.cpp @@ -21,7 +21,7 @@ void CacheView::mousePressEvent(QMouseEvent *event) { // and emit a signal indicating that the address was selected through the // cache const auto viewItems = items(event->pos()); - for (const auto &item : qAsConst(viewItems)) { + for (const auto &item : std::as_const(viewItems)) { if (auto *textItem = dynamic_cast(item)) { const QVariant userData = textItem->data(Qt::UserRole); if (userData.isValid()) { diff --git a/src/ccmanager.cpp b/src/ccmanager.cpp index c852f2cf1..84a0df879 100644 --- a/src/ccmanager.cpp +++ b/src/ccmanager.cpp @@ -20,7 +20,7 @@ const static QString s_testprogram = "int main() { return 0; }"; QString indentString(const QString &string, int indent) { auto subStrings = string.split("\n"); auto indentedStrings = QStringList(); - for (const auto &str : qAsConst(subStrings)) { + for (const auto &str : std::as_const(subStrings)) { indentedStrings << QString(" ").repeated(indent) + str; } return indentedStrings.join("\n"); diff --git a/src/cli/clioptions.cpp b/src/cli/clioptions.cpp index 4cc909962..80f506248 100644 --- a/src/cli/clioptions.cpp +++ b/src/cli/clioptions.cpp @@ -111,7 +111,7 @@ bool parseCLIOptions(QCommandLineParser &parser, QString &errorMessage, .isaInfo() .supportedExtensions; - for (auto &ext : qAsConst(options.isaExtensions)) { + for (auto &ext : std::as_const(options.isaExtensions)) { if (!exts.contains(ext)) { errorMessage = "Invalid ISA extension '" + ext + "' specified (--isaexts)."; diff --git a/src/editor/csyntaxhighlighter.cpp b/src/editor/csyntaxhighlighter.cpp index 22f562d79..d066ae376 100644 --- a/src/editor/csyntaxhighlighter.cpp +++ b/src/editor/csyntaxhighlighter.cpp @@ -76,7 +76,7 @@ CSyntaxHighlighter::CSyntaxHighlighter( } // namespace Ripes void CSyntaxHighlighter::syntaxHighlightBlock(const QString &text) { - for (const HighlightingRule &rule : qAsConst(highlightingRules)) { + for (const HighlightingRule &rule : std::as_const(highlightingRules)) { QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text); while (matchIterator.hasNext()) { diff --git a/src/editor/rvsyntaxhighlighter.cpp b/src/editor/rvsyntaxhighlighter.cpp index 0c6a769ce..0df5112f6 100644 --- a/src/editor/rvsyntaxhighlighter.cpp +++ b/src/editor/rvsyntaxhighlighter.cpp @@ -24,7 +24,7 @@ RVSyntaxHighlighter::RVSyntaxHighlighter( << "\\bgp\\b" << "\\btp\\b" << "\\bfp\\b"; - for (const auto &pattern : qAsConst(registerPatterns)) { + for (const auto &pattern : std::as_const(registerPatterns)) { rule.pattern = QRegularExpression(pattern); rule.format = registerFormat; m_highlightingRules.append(rule); @@ -70,7 +70,7 @@ RVSyntaxHighlighter::RVSyntaxHighlighter( } void RVSyntaxHighlighter::syntaxHighlightBlock(const QString &text) { - for (const HighlightingRule &rule : qAsConst(m_highlightingRules)) { + for (const HighlightingRule &rule : std::as_const(m_highlightingRules)) { QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text); while (matchIterator.hasNext()) { diff --git a/src/edittab.cpp b/src/edittab.cpp index b433cb4e4..34b4e2648 100644 --- a/src/edittab.cpp +++ b/src/edittab.cpp @@ -20,6 +20,7 @@ #include "processorhandler.h" #include "ripessettings.h" #include "symbolnavigator.h" +#include "wasmSupport.h" namespace Ripes { @@ -87,6 +88,8 @@ EditTab::EditTab(QToolBar *toolbar, QWidget *parent) &EditTab::sourceTypeChanged); connect(m_ui->setCInput, &QRadioButton::toggled, m_buildAction, &QAction::setEnabled); + // C compiler is not yet supported on WASM. + disableIfWasm(m_ui->setCInput); // Ensure that changes to the current compiler path will disable C input, if // the compiler is invalid diff --git a/src/flowlayout.cpp b/src/flowlayout.cpp index 65965cdb1..32d35d3aa 100644 --- a/src/flowlayout.cpp +++ b/src/flowlayout.cpp @@ -132,7 +132,7 @@ QSize FlowLayout::sizeHint() const { return minimumSize(); } QSize FlowLayout::minimumSize() const { QSize size; - for (const QLayoutItem *item : qAsConst(itemList)) + for (const QLayoutItem *item : std::as_const(itemList)) size = size.expandedTo(item->minimumSize()); const QMargins margins = contentsMargins(); @@ -153,7 +153,7 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const { //! [9] //! [10] - for (QLayoutItem *item : qAsConst(itemList)) { + for (QLayoutItem *item : std::as_const(itemList)) { int spaceX = horizontalSpacing(); int spaceY = verticalSpacing(); if (spaceX == -1) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 879a54de3..95120eacb 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -15,6 +15,7 @@ #include "syscall/syscallviewer.h" #include "syscall/systemio.h" #include "version/version.h" +#include "wasmSupport.h" #include "fancytabbar/fancytabbar.h" @@ -204,7 +205,6 @@ void MainWindow::setupMenus() { connect(loadAction, &QAction::triggered, this, [=] { this->loadFileTriggered(); }); m_ui->menuFile->addAction(loadAction); - m_ui->menuFile->addSeparator(); auto *examplesMenu = m_ui->menuFile->addMenu("Load Example..."); @@ -231,7 +231,6 @@ void MainWindow::setupMenus() { &EditTab::editorStateChanged, saveAction, [saveAsAction](bool enabled) { saveAsAction->setEnabled(enabled); }); m_ui->menuFile->addAction(saveAsAction); - m_ui->menuFile->addSeparator(); const QIcon exitIcon = QIcon(":/icons/cancel.svg"); @@ -246,6 +245,9 @@ void MainWindow::setupMenus() { m_ui->menuView->addAction( static_cast(m_tabWidgets.at(ProcessorTabID).tab) ->m_displayValuesAction); + + // File I/O is not yet supported on WASM due to sandboxing. + disableIfWasm(QList{loadAction, saveAction, saveAsAction, exitAction}); } MainWindow::~MainWindow() { delete m_ui; } @@ -360,8 +362,8 @@ void MainWindow::loadFileTriggered() { } void MainWindow::wiki() { - QDesktopServices::openUrl( - QUrl(QString("https://github.com/mortbopet/Ripes/blob/master/docs/README.md"))); + QDesktopServices::openUrl(QUrl(QString( + "https://github.com/mortbopet/Ripes/blob/master/docs/README.md"))); } void MainWindow::version() { diff --git a/src/processmanager.h b/src/processmanager.h index 129026443..028f7d522 100644 --- a/src/processmanager.h +++ b/src/processmanager.h @@ -154,8 +154,8 @@ class ProcessManager { static bool hasValidProgram() { return false; } static const QString &program() { return get().m_programPath; } static QString getError() { return QString(); } - static ProcessResult run(const QStringList &args, - bool showProgressDialog = false) { + static ProcessResult run(const QStringList &, + bool = false) { return ProcessResult(); } @@ -165,7 +165,7 @@ class ProcessManager { } signals: - bool trySetProgram(const QString &path) { return false; } + bool trySetProgram(const QString &) { return false; } private: QString m_programPath; diff --git a/src/processorselectiondialog.cpp b/src/processorselectiondialog.cpp index f69a66c22..cf593bb5c 100644 --- a/src/processorselectiondialog.cpp +++ b/src/processorselectiondialog.cpp @@ -160,7 +160,7 @@ void ProcessorSelectionDialog::selectionChanged(QTreeWidgetItem *current, delete item; } - for (const auto &ext : qAsConst(isaInfo.supportedExtensions)) { + for (const auto &ext : std::as_const(isaInfo.supportedExtensions)) { auto chkbox = new QCheckBox(ext); chkbox->setToolTip(isaInfo.isa->extensionDescription(ext)); m_ui->extensions->addWidget(chkbox); diff --git a/src/ripessettings.cpp b/src/ripessettings.cpp index 723728255..36ad11830 100644 --- a/src/ripessettings.cpp +++ b/src/ripessettings.cpp @@ -65,7 +65,7 @@ const std::map s_defaultSettings = { {RIPES_SETTING_PROCESSOR_LAYOUT_ID, 0}, {RIPES_SETTING_FOLLOW_EXEC, "true"}, {RIPES_SETTING_SOURCECODE, ""}, - {RIPES_SETTING_DARKMODE, false}, + {RIPES_SETTING_DARKMODE, true}, {RIPES_SETTING_SHOWSIGNALS, false}, {RIPES_SETTING_INPUT_TYPE, static_cast(SourceType::Assembly)}, {RIPES_SETTING_AUTOCLOCK_INTERVAL, 100}, diff --git a/src/savedialog.cpp b/src/savedialog.cpp index d50bbb940..47aaf9049 100644 --- a/src/savedialog.cpp +++ b/src/savedialog.cpp @@ -50,7 +50,7 @@ void SaveDialog::accept() { void SaveDialog::pathChanged() { bool okEnabled = !QFileInfo(m_ui->filePath->text()).fileName().isEmpty(); - okEnabled &= m_ui->saveSource->isChecked() | m_ui->saveBinary->isChecked(); + okEnabled &= m_ui->saveSource->isChecked() || m_ui->saveBinary->isChecked(); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(okEnabled); diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index e34faf1ff..441e2978b 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -21,6 +21,7 @@ #include "utilities/hexspinbox.h" #include "utilities/scrolleventfilter.h" +#include "wasmSupport.h" namespace Ripes { @@ -148,7 +149,10 @@ SettingsDialog::SettingsDialog(QWidget *parent) // Create settings pages addPage("Environment", createEnvironmentPage()); addPage("Simulator", createSimulatorPage()); - addPage("Compiler", createCompilerPage()); + auto *compilerPage = createCompilerPage(); + addPage("Compiler", compilerPage); + // No C compiler support (yet) for wasm. + disableIfWasm(compilerPage); addPage("Editor", createEditorPage()); m_ui->settingsList->setCurrentRow( diff --git a/src/wasmSupport.h b/src/wasmSupport.h new file mode 100644 index 000000000..2643f060b --- /dev/null +++ b/src/wasmSupport.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +namespace Ripes { + +// Disable a widget if we are running in a wasm environment. +template +inline void disableIfWasm(T *widget) { +#ifdef __EMSCRIPTEN__ + widget->setEnabled(false); +#endif +} + +// Disables a list of widgets if we are running in a wasm environment. +template +inline void disableIfWasm(TList widgets) { + for (auto *widget : widgets) + disableIfWasm(widget); +} + +} // namespace Ripes \ No newline at end of file