A bit of non-functional change cleanup
MODIFY
src/assembler/assembler.h
src/assembler/assembler.h
#include <set>
#include <variant>
+#include "STLExtras.h"
#include "assemblerbase.h"
namespace Ripes {
@@ -229,25 +230,24 @@ protected:
* information if it is a blank symbol (no other information on line).
*/
Symbols carry;
- for (int i = 0; i < program.size(); ++i) {
- const auto& line = program.at(i);
- if (line.isEmpty())
+ for (auto line : llvm::enumerate(program)) {
+ if (line.value().isEmpty())
continue;
TokenizedSrcLine tsl;
- tsl.sourceLine = i;
- runOperation(tokens, LineTokens, tokenize, program[i], i);
+ tsl.sourceLine = line.index();
+ runOperation(tokens, LineTokens, tokenize, line.value(), tsl.sourceLine);
runOperation(remainingTokens, LineTokens, splitCommentFromLine, tokens);
// Symbols precede directives
- runOperation(symbolsAndRest, SymbolLinePair, splitSymbolsFromLine, remainingTokens, i);
+ runOperation(symbolsAndRest, SymbolLinePair, splitSymbolsFromLine, remainingTokens, tsl.sourceLine);
tsl.symbols = symbolsAndRest.first;
bool uniqueSymbols = true;
for (const auto& s : symbolsAndRest.first) {
if (symbols.count(s) != 0) {
- errors.push_back(Error(i, "Multiple definitions of symbol '" + s.v + "'"));
+ errors.push_back(Error(tsl.sourceLine, "Multiple definitions of symbol '" + s.v + "'"));
uniqueSymbols = false;
break;
}
@@ -257,7 +257,8 @@ protected:
}
symbols.insert(symbolsAndRest.first.begin(), symbolsAndRest.first.end());
- runOperation(directiveAndRest, DirectiveLinePair, splitDirectivesFromLine, symbolsAndRest.second, i);
+ runOperation(directiveAndRest, DirectiveLinePair, splitDirectivesFromLine, symbolsAndRest.second,
+ tsl.sourceLine);
tsl.directive = directiveAndRest.first;
// Parse (and remove) relocation hints from the tokens.
@@ -280,7 +281,8 @@ protected:
wasDirective, false);
}
}
- if (errors.size() != 0) {
+
+ if (!errors.empty()) {
return {errors};
} else {
return {tokenizedLines};
@@ -296,27 +298,26 @@ protected:
SourceProgram expandedLines;
expandedLines.reserve(tokenizedLines.size());
- for (unsigned i = 0; i < tokenizedLines.size(); ++i) {
- const auto& tokenizedLine = tokenizedLines.at(i);
- runOperation(expandedOps, std::optional<std::vector<LineTokens>>, expandPseudoOp, tokenizedLine);
+ for (auto tokenizedLine : llvm::enumerate(tokenizedLines)) {
+ runOperation(expandedOps, std::optional<std::vector<LineTokens>>, expandPseudoOp, tokenizedLine.value());
if (expandedOps) {
/** @note: Original source line is kept for all resulting lines after pseudo-op expantion.
* Labels and directives are only kept for the first expanded op.
*/
const auto& eops = expandedOps.value();
- for (size_t j = 0; j < eops.size(); j++) {
+ for (auto eop : llvm::enumerate(eops)) {
TokenizedSrcLine tsl;
- tsl.tokens = eops.at(j);
- tsl.sourceLine = tokenizedLine.sourceLine;
- if (j == 0) {
- tsl.directive = tokenizedLine.directive;
- tsl.symbols = tokenizedLine.symbols;
+ tsl.tokens = eop.value();
+ tsl.sourceLine = tokenizedLine.value().sourceLine;
+ if (eop.index() == 0) {
+ tsl.directive = tokenizedLine.value().directive;
+ tsl.symbols = tokenizedLine.value().symbols;
}
expandedLines.push_back(tsl);
}
} else {
// This was not a pseudoinstruction; just add line to the set of expanded lines
- expandedLines.push_back(tokenizedLine);
+ expandedLines.push_back(tokenizedLine.value());
}
}

MODIFY
src/io/ioledmatrix.cpp
src/io/ioledmatrix.cpp
#include "ioledmatrix.h"
-#include "ioregistry.h"
-
#include <QPainter>
#include <QPen>
+#include "STLExtras.h"
+#include "ioregistry.h"
+
namespace Ripes {
IOLedMatrix::IOLedMatrix(QWidget* parent) : IOBase(IOType::LED_MATRIX, parent) {
@@ -68,14 +69,14 @@ void IOLedMatrix::updateLEDRegs() {
m_regDescs.clear();
m_regDescs.resize(nLEDs);
- for (unsigned i = 0; i < m_regDescs.size(); ++i) {
+ for (auto mRegDesc : llvm::enumerate(m_regDescs)) {
RegDesc regdesc;
- regdesc.name = "LED_" + QString::number(i);
+ regdesc.name = "LED_" + QString::number(mRegDesc.index());
regdesc.rw = RegDesc::RW::RW;
regdesc.bitWidth = 24;
- regdesc.address = i * 4;
+ regdesc.address = mRegDesc.index() * 4;
regdesc.exported = false;
- m_regDescs.at(i) = regdesc;
+ mRegDesc.value() = regdesc;
}
updateGeometry();

MODIFY
src/pipelinediagrammodel.cpp
src/pipelinediagrammodel.cpp
@@ -65,12 +65,12 @@ void PipelineDiagramModel::prepareForView() {
void PipelineDiagramModel::gatherStageInfo() {
long long cycleCount = ProcessorHandler::getProcessor()->getCycleCount();
- if (m_cycleStageInfos.count(cycleCount)) {
+ auto stageInfoForCycle = m_cycleStageInfos.find(cycleCount);
+ if (stageInfoForCycle == m_cycleStageInfos.end()) {
return;
}
for (unsigned i = 0; i < ProcessorHandler::getProcessor()->stageCount(); ++i) {
- m_cycleStageInfos[ProcessorHandler::getProcessor()->getCycleCount()][i] =
- ProcessorHandler::getProcessor()->stageInfo(i);
+ stageInfoForCycle->second[i] = ProcessorHandler::getProcessor()->stageInfo(i);
}
}

A bit of non-functional change cleanup