diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-15 22:35:55 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-15 22:35:55 +0100 |
| commit | 730b76e1aae96f9a5cafc13634d6f014e598abaf (patch) | |
| tree | b9c6542602d4fd0138eb7a88e8a9a9d13971e88e /dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc | |
| parent | 49064df5303b9a96f6b11dd0aed27dc1e269aa9e (diff) | |
feat: API and codebase tweaks.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc')
| -rw-r--r-- | dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc b/dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc index 2539f1f..7ef3dba 100644 --- a/dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc +++ b/dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc @@ -9,12 +9,28 @@ /// BUGS: 0 +/////////////////////// + +// ANSI ESCAPE CODES // + +/////////////////////// + +/////////////////////// + +// MACROS // + +/////////////////////// + #define kPrintF printf #define kPrintErr std::cerr #define kExitOK (EXIT_SUCCESS) #define kExitNO (EXIT_FAILURE) +#define kBlank "\e[0;30m" +#define kRed "\e[0;31m" +#define kWhite "\e[0;97m" + #include <CompilerKit/Frontend.h> #include <CompilerKit/PEF.h> #include <CompilerKit/UUID.h> @@ -27,20 +43,10 @@ /* This is part of the CompilerKit. */ /* (c) Amlal El Mahrouss 2024-2025 */ -/// @author EL Mahrouss Amlal (amlal@nekernel.org) +/// @author El Mahrouss Amlal (amlal@nekernel.org) /// @file CPlusPlusCompilerAMD64.cxx /// @brief Optimized C++ Compiler Driver. -/////////////////////// - -// ANSI ESCAPE CODES // - -/////////////////////// - -#define kBlank "\e[0;30m" -#define kRed "\e[0;31m" -#define kWhite "\e[0;97m" - ///////////////////////////////////// // INTERNALS OF THE C++ COMPILER @@ -49,7 +55,7 @@ /// @internal // Avoids relative_path which could discard parts of the original. -std::filesystem::path expand_home(const std::filesystem::path& input) { +std::filesystem::path necti_expand_home(const std::filesystem::path& input) { const std::string& raw = input.string(); if (!raw.empty() && raw[0] == '~') { @@ -115,7 +121,7 @@ static std::vector<CompilerKit::CompilerKeyword> kKeywords; ///////////////////////////////////////// -static CompilerKit::AssemblyFactory kFactory; +static CompilerKit::AssemblyFactory kAssembler; static Boolean kInStruct = false; static Boolean kOnWhileLoop = false; static Boolean kOnForLoop = false; @@ -138,7 +144,7 @@ class CompilerFrontendCPlusPlusAMD64 final CK_COMPILER_FRONTEND { /// @internal compiler variables -static CompilerFrontendCPlusPlusAMD64* kCompilerFrontend = nullptr; +static CompilerFrontendCPlusPlusAMD64* kFrontend = nullptr; static std::vector<CompilerKit::STLString> kRegisterMap; @@ -739,7 +745,7 @@ class AssemblyCPlusPlusInterfaceAMD64 final CK_ASSEMBLY_INTERFACE { UInt32 Arch() noexcept override { return CompilerKit::AssemblyFactory::kArchAMD64; } Int32 CompileToFormat(CompilerKit::STLString src, Int32 arch) override { - if (kCompilerFrontend == nullptr) return kExitNO; + if (kFrontend == nullptr) return kExitNO; CompilerKit::STLString dest = src; dest += ".pp.masm"; @@ -753,7 +759,7 @@ class AssemblyCPlusPlusInterfaceAMD64 final CK_ASSEMBLY_INTERFACE { out_fp << "#org " << kOrigin << "\n\n"; while (std::getline(src_fp, line_source)) { - out_fp << kCompilerFrontend->Compile(line_source, src).fUserValue; + out_fp << kFrontend->Compile(line_source, src).fUserValue; } return kExitOK; @@ -830,15 +836,15 @@ NECTI_MODULE(CompilerCPlusPlusAMD64) { kErrorLimit = 0; - kCompilerFrontend = new CompilerFrontendCPlusPlusAMD64(); - kFactory.Mount(new AssemblyCPlusPlusInterfaceAMD64()); + kFrontend = new CompilerFrontendCPlusPlusAMD64(); + kAssembler.Mount(new AssemblyCPlusPlusInterfaceAMD64()); CompilerKit::install_signal(SIGSEGV, Detail::drvi_crash_handler); // Ensure cleanup on exit std::atexit([]() { - delete kCompilerFrontend; - kCompilerFrontend = nullptr; + delete kFrontend; + kFrontend = nullptr; }); for (auto index = 1UL; index < argc; ++index) { @@ -852,12 +858,11 @@ NECTI_MODULE(CompilerCPlusPlusAMD64) { if (strcmp(argv[index], "-cxx-verbose") == 0) { kVerbose = true; - continue; } if (strcmp(argv[index], "-cxx-dialect") == 0) { - if (kCompilerFrontend) std::cout << kCompilerFrontend->Language() << "\n"; + if (kFrontend) std::cout << kFrontend->Language() << "\n"; return NECTI_SUCCESS; } @@ -890,7 +895,7 @@ NECTI_MODULE(CompilerCPlusPlusAMD64) { for (CompilerKit::STLString ext : exts) { if (argv_i.ends_with(ext)) { - if (kFactory.Compile(argv_i, kMachine) != kExitOK) { + if (kAssembler.Compile(argv_i, kMachine) != kExitOK) { return NECTI_INVALID_DATA; } @@ -899,7 +904,7 @@ NECTI_MODULE(CompilerCPlusPlusAMD64) { } } - kFactory.Unmount(); + kAssembler.Unmount(); return NECTI_SUCCESS; } |
