From a4e4942069241a308c1403318d74bd7150624351 Mon Sep 17 00:00:00 2001 From: Hazem Krimi Date: Wed, 1 Apr 2026 17:01:35 +0100 Subject: [PATCH] chore: include filename for static variables --- src/code.hpp | 2 +- src/main.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/code.hpp b/src/code.hpp index 4857a9e..45ff8cb 100644 --- a/src/code.hpp +++ b/src/code.hpp @@ -1,3 +1,3 @@ #include "types.hpp" -int translateCommand(std::string&, Command); +int translateCommand(std::string&, const std::string, Command); diff --git a/src/main.cpp b/src/main.cpp index 847428f..aeb60d9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,8 +10,8 @@ int process(std::string source) { std::ifstream ifs(source); - std::string out = source.substr(0, source.find_last_of('.')) + ".asm"; - std::ofstream ofs(out); + std::string filename = source.substr(0, source.find_last_of('.')); + std::ofstream ofs(filename + ".asm", std::ofstream::trunc); std::string line; std::string output; @@ -31,7 +31,7 @@ int process(std::string source) { for (const Command &cmd : commands) { int translateResult; - if ((translateResult = translateCommand(output, cmd)) != 0) { + if ((translateResult = translateCommand(output, filename, cmd)) != 0) { return translateResult; }