ProgramLoader reordering
This commit is contained in:
@@ -5,16 +5,8 @@
|
||||
#include "ProgramLoader.h"
|
||||
#include <sstream>
|
||||
|
||||
ProgramLoader::ProgramLoader(const std::string &path){
|
||||
m_programFile.open(path);
|
||||
}
|
||||
|
||||
ProgramLoader::~ProgramLoader() {
|
||||
m_programFile.close();
|
||||
}
|
||||
|
||||
ProgramLoader * ProgramLoader::getInstance(const std::string &program_path) {
|
||||
static ProgramLoader instance{program_path};
|
||||
ProgramLoader *ProgramLoader::getInstance() {
|
||||
static ProgramLoader instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
@@ -30,7 +22,7 @@ ProgramLoader * ProgramLoader::getInstance(const std::string &program_path) {
|
||||
if (out.empty()) break;
|
||||
/// Stoppe, sobald ein Kommentar im Source Code vorkommt
|
||||
if (out.at(0) != '#') {
|
||||
if (out.at(out.length() -1) == ',') {
|
||||
if (out.at(out.length() - 1) == ',') {
|
||||
out.erase(out.length() - 1);
|
||||
}
|
||||
output.push_back(out);
|
||||
@@ -41,19 +33,17 @@ ProgramLoader * ProgramLoader::getInstance(const std::string &program_path) {
|
||||
return output;
|
||||
}
|
||||
|
||||
void ProgramLoader::indexFile() {
|
||||
if (m_programFile.is_open()) {
|
||||
std::string line;
|
||||
int lineNumber = 1;
|
||||
/// Parse Zeile für Zeile
|
||||
while (std::getline(m_programFile, line)) {
|
||||
auto lineVector = parseLine(line);
|
||||
const auto first = lineVector.begin();
|
||||
/// Sobald ein Label gefunden wurde, speichere die Zeile
|
||||
if (first->at(first->length() - 1) == ':') {
|
||||
m_labels[first->substr(0, first->length() - 1)] = lineNumber;
|
||||
}
|
||||
lineNumber++;
|
||||
void ProgramLoader::indexFile(std::ifstream &m_programFile) {
|
||||
std::string line;
|
||||
int lineNumber = 1;
|
||||
/// Parse Zeile für Zeile
|
||||
while (std::getline(m_programFile, line)) {
|
||||
auto lineVector = parseLine(line);
|
||||
const auto first = lineVector.begin();
|
||||
/// Sobald ein Label gefunden wurde, speichere die Zeile
|
||||
if (first->at(first->length() - 1) == ':') {
|
||||
m_labels[first->substr(0, first->length() - 1)] = lineNumber;
|
||||
}
|
||||
lineNumber++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user