indexFile() now saves the stream position not line number

This commit is contained in:
black
2025-07-08 13:22:43 +02:00
parent 32f70bb974
commit f896f82db8
2 changed files with 2 additions and 4 deletions

View File

@@ -37,14 +37,12 @@ void ProgramLoader::indexFile(std::ifstream &m_programFile) {
m_programFile.clear();
m_programFile.seekg(0);
std::string line;
int lineNumber = 1;
/// Parse Zeile für Zeile
while (std::getline(m_programFile, line)) {
auto lineVector = parseLine(line);
/// Sobald ein Label gefunden wurde, speichere die Zeile
if (const auto first = lineVector.begin(); first->at(first->length() - 1) == ':') {
m_labels[first->substr(0, first->length() - 1)] = lineNumber;
m_labels[first->substr(0, first->length() - 1)] = m_programFile.tellg();
}
lineNumber++;
}
}

View File

@@ -20,7 +20,7 @@ private:
*/
explicit ProgramLoader() = default;
std::map<std::string, int> m_labels;
std::map<std::string, std::streampos> m_labels;
public:
/// Singleton Logik