Skip to content

Commit

Permalink
Merge branch 'mortbopet:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
SteliosKaragiorgis authored Sep 28, 2023
2 parents 6f7c8c6 + c56dfb2 commit 6082d75
Show file tree
Hide file tree
Showing 19 changed files with 60 additions and 29 deletions.
2 changes: 1 addition & 1 deletion external/VSRTL
Submodule VSRTL updated 119 files
2 changes: 1 addition & 1 deletion src/assembler/assembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class Assembler : public AssemblerBase {
// Join tokens
QString joinedLine;
const auto tokens = std::get<LineTokens>(tokensVar);
for (const auto &token : qAsConst(tokens)) {
for (const auto &token : std::as_const(tokens)) {
joinedLine += token + " ";
}
joinedLine.chop(1); // remove trailing ' '
Expand Down
2 changes: 1 addition & 1 deletion src/assembler/gnudirectives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int64_t>(t.index()) < (line.tokens.size() - 1))
err += ", ";
};
err += "].";
Expand Down
4 changes: 2 additions & 2 deletions src/cachesim/cacheplotview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
10 changes: 5 additions & 5 deletions src/cachesim/cacheplotwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ CachePlotWidget::gatherData(unsigned fromCycle) const {

void resample(QLineSeries *series, unsigned target, double &step) {
QVector<QPointF> newPoints;
const auto &oldPoints = series->pointsVector();
const auto &oldPoints = series->points();
step = (oldPoints.last().x() / static_cast<double>(target)) *
2; // *2 to account for steps
newPoints.reserve(target);
Expand All @@ -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;
Expand Down Expand Up @@ -426,8 +426,8 @@ void CachePlotWidget::updateRatioPlot() {
QList<QPointF> newPoints;
QList<QPointF> 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);
}
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/cachesim/cacheview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QGraphicsSimpleTextItem *>(item)) {
const QVariant userData = textItem->data(Qt::UserRole);
if (userData.isValid()) {
Expand Down
2 changes: 1 addition & 1 deletion src/ccmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/cli/clioptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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).";
Expand Down
2 changes: 1 addition & 1 deletion src/editor/csyntaxhighlighter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
4 changes: 2 additions & 2 deletions src/editor/rvsyntaxhighlighter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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()) {
Expand Down
3 changes: 3 additions & 0 deletions src/edittab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "processorhandler.h"
#include "ripessettings.h"
#include "symbolnavigator.h"
#include "wasmSupport.h"

namespace Ripes {

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/flowlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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)
Expand Down
10 changes: 6 additions & 4 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "syscall/syscallviewer.h"
#include "syscall/systemio.h"
#include "version/version.h"
#include "wasmSupport.h"

#include "fancytabbar/fancytabbar.h"

Expand Down Expand Up @@ -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...");
Expand All @@ -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");
Expand All @@ -246,6 +245,9 @@ void MainWindow::setupMenus() {
m_ui->menuView->addAction(
static_cast<ProcessorTab *>(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; }
Expand Down Expand Up @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions src/processmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -165,7 +165,7 @@ class ProcessManager {
}
signals:

bool trySetProgram(const QString &path) { return false; }
bool trySetProgram(const QString &) { return false; }

private:
QString m_programPath;
Expand Down
2 changes: 1 addition & 1 deletion src/processorselectiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/ripessettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const std::map<QString, QVariant> 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<unsigned>(SourceType::Assembly)},
{RIPES_SETTING_AUTOCLOCK_INTERVAL, 100},
Expand Down
2 changes: 1 addition & 1 deletion src/savedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 5 additions & 1 deletion src/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "utilities/hexspinbox.h"
#include "utilities/scrolleventfilter.h"
#include "wasmSupport.h"

namespace Ripes {

Expand Down Expand Up @@ -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(
Expand Down
22 changes: 22 additions & 0 deletions src/wasmSupport.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include <QWidget>

namespace Ripes {

// Disable a widget if we are running in a wasm environment.
template <typename T>
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 <typename TList>
inline void disableIfWasm(TList widgets) {
for (auto *widget : widgets)
disableIfWasm(widget);
}

} // namespace Ripes

0 comments on commit 6082d75

Please sign in to comment.