diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-22 10:25:39 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-22 10:25:39 +0200 |
| commit | 8ad58a91a11380203c4a81fe4dc93e7734631b32 (patch) | |
| tree | 33278ad442e5f20c88c2701a3cb5dcbfd7d3f589 /dev | |
| parent | ca022f27844a5475dab608bd1970c05494a67290 (diff) | |
refactor: Reworking the code base, for the C++Drv, and ARM64 assembler.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/LibCompiler/AssemblyInterface.h | 3 | ||||
| -rw-r--r-- | dev/LibCompiler/CompilerFrontend.h | 12 | ||||
| -rw-r--r-- | dev/LibCompiler/Detail/ClUtils.h | 2 | ||||
| -rw-r--r-- | dev/LibCompiler/src/CCompiler64x0.cc | 4 | ||||
| -rw-r--r-- | dev/LibCompiler/src/CCompilerARM64.cc | 4 | ||||
| -rw-r--r-- | dev/LibCompiler/src/CCompilerPower64.cc | 4 | ||||
| -rw-r--r-- | dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc | 15 |
7 files changed, 24 insertions, 20 deletions
diff --git a/dev/LibCompiler/AssemblyInterface.h b/dev/LibCompiler/AssemblyInterface.h index 81440ce..5206005 100644 --- a/dev/LibCompiler/AssemblyInterface.h +++ b/dev/LibCompiler/AssemblyInterface.h @@ -10,7 +10,8 @@ #include <LibCompiler/Macros.h> #include <LibCompiler/StringView.h> -#define ASSEMBLY_INTERFACE : public LibCompiler::AssemblyInterface +#define LC_ASSEMBLY_INTERFACE : public LibCompiler::AssemblyInterface +#define LC_ENCODER : public LibCompiler::EncoderInterface namespace LibCompiler { class AssemblyFactory; diff --git a/dev/LibCompiler/CompilerFrontend.h b/dev/LibCompiler/CompilerFrontend.h index 858473b..d9dd7a4 100644 --- a/dev/LibCompiler/CompilerFrontend.h +++ b/dev/LibCompiler/CompilerFrontend.h @@ -8,17 +8,19 @@ #include <LibCompiler/AssemblyInterface.h> +#define LC_COMPILER_FRONTEND : public LibCompiler::CompilerFrontendInterface + namespace LibCompiler { -inline auto kInvalidFrontend = "NA"; +inline static auto kInvalidFrontend = "?"; /// @brief Compiler backend, implements a frontend, such as C, C++... /// See Toolchain, for some examples. -class ICompilerFrontend { +class CompilerFrontendInterface { public: - explicit ICompilerFrontend() = default; - virtual ~ICompilerFrontend() = default; + explicit CompilerFrontendInterface() = default; + virtual ~CompilerFrontendInterface() = default; - LIBCOMPILER_COPY_DEFAULT(ICompilerFrontend); + LIBCOMPILER_COPY_DEFAULT(CompilerFrontendInterface); // NOTE: cast this to your user defined ast. typedef void* AstType; diff --git a/dev/LibCompiler/Detail/ClUtils.h b/dev/LibCompiler/Detail/ClUtils.h index f7811e7..b33f66b 100644 --- a/dev/LibCompiler/Detail/ClUtils.h +++ b/dev/LibCompiler/Detail/ClUtils.h @@ -36,7 +36,7 @@ namespace Detail { inline void print_error(std::string reason, std::string file) noexcept { if (reason[0] == '\n') reason.erase(0, 1); - kStdErr << kRed << reason << kBlank << std::endl; + kStdErr << reason << kBlank << std::endl; if (kAcceptableErrors > kErrorLimit) std::exit(LIBCOMPILER_EXEC_ERROR); diff --git a/dev/LibCompiler/src/CCompiler64x0.cc b/dev/LibCompiler/src/CCompiler64x0.cc index 17de065..55adc75 100644 --- a/dev/LibCompiler/src/CCompiler64x0.cc +++ b/dev/LibCompiler/src/CCompiler64x0.cc @@ -134,7 +134,7 @@ static bool kIfFound = false; static size_t kBracesCount = 0UL; /* @brief C compiler backend for C */ -class CompilerFrontend64x0 final : public LibCompiler::ICompilerFrontend { +class CompilerFrontend64x0 final : public LibCompiler::CompilerFrontendInterface { public: explicit CompilerFrontend64x0() = default; ~CompilerFrontend64x0() override = default; @@ -1044,7 +1044,7 @@ skip_braces_check: ///////////////////////////////////////////////////////////////////////////////////////// -class AssemblyCCInterface final ASSEMBLY_INTERFACE { +class AssemblyCCInterface final LC_ASSEMBLY_INTERFACE { public: explicit AssemblyCCInterface() = default; ~AssemblyCCInterface() override = default; diff --git a/dev/LibCompiler/src/CCompilerARM64.cc b/dev/LibCompiler/src/CCompilerARM64.cc index 3aaab5f..7a342ae 100644 --- a/dev/LibCompiler/src/CCompilerARM64.cc +++ b/dev/LibCompiler/src/CCompilerARM64.cc @@ -134,7 +134,7 @@ static bool kIfFound = false; static size_t kBracesCount = 0UL; /* @brief C compiler backend for C */ -class CompilerFrontendARM64 final : public LibCompiler::ICompilerFrontend { +class CompilerFrontendARM64 final : public LibCompiler::CompilerFrontendInterface { public: explicit CompilerFrontendARM64() = default; ~CompilerFrontendARM64() override = default; @@ -1042,7 +1042,7 @@ skip_braces_check: ///////////////////////////////////////////////////////////////////////////////////////// -class AssemblyCCInterface final ASSEMBLY_INTERFACE { +class AssemblyCCInterface final LC_ASSEMBLY_INTERFACE { public: explicit AssemblyCCInterface() = default; ~AssemblyCCInterface() override = default; diff --git a/dev/LibCompiler/src/CCompilerPower64.cc b/dev/LibCompiler/src/CCompilerPower64.cc index aa49768..91cd32f 100644 --- a/dev/LibCompiler/src/CCompilerPower64.cc +++ b/dev/LibCompiler/src/CCompilerPower64.cc @@ -125,7 +125,7 @@ static bool kIfFound = false; static size_t kBracesCount = 0UL; /* @brief C compiler backend for C */ -class CompilerFrontendPower64 final : public LibCompiler::ICompilerFrontend { +class CompilerFrontendPower64 final : public LibCompiler::CompilerFrontendInterface { public: explicit CompilerFrontendPower64() = default; ~CompilerFrontendPower64() override = default; @@ -1062,7 +1062,7 @@ skip_braces_check: ///////////////////////////////////////////////////////////////////////////////////////// -class AssemblyMountpointCLang final ASSEMBLY_INTERFACE { +class AssemblyMountpointCLang final LC_ASSEMBLY_INTERFACE { public: explicit AssemblyMountpointCLang() = default; ~AssemblyMountpointCLang() override = default; diff --git a/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc b/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc index e07029b..cc6fa67 100644 --- a/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc +++ b/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc @@ -123,7 +123,7 @@ static Boolean kInBraces = false; static size_t kBracesCount = 0UL; /* @brief C++ compiler backend for the NeKernel C++ driver */ -class CompilerFrontendCPlusPlus final : public LibCompiler::ICompilerFrontend { +class CompilerFrontendCPlusPlus final : public LibCompiler::CompilerFrontendInterface { public: explicit CompilerFrontendCPlusPlus() = default; ~CompilerFrontendCPlusPlus() override = default; @@ -710,7 +710,7 @@ Boolean CompilerFrontendCPlusPlus::Compile(std::string text, std::string file) { ///////////////////////////////////////////////////////////////////////////////////////// -class AssemblyCPlusPlusInterface final ASSEMBLY_INTERFACE { +class AssemblyCPlusPlusInterface final LC_ASSEMBLY_INTERFACE { public: explicit AssemblyCPlusPlusInterface() = default; ~AssemblyCPlusPlusInterface() override = default; @@ -723,7 +723,7 @@ class AssemblyCPlusPlusInterface final ASSEMBLY_INTERFACE { if (kCompilerFrontend == nullptr) return kExitNO; std::string dest = src; - dest += ".masm"; + dest += ".pp.masm"; std::ofstream out_fp(dest); @@ -883,11 +883,11 @@ LIBCOMPILER_MODULE(CompilerCPlusPlusAMD64) { std::string argv_i = argv[index]; - std::vector exts = kExtListCxx; + std::vector<std::string> exts = kExtListCxx; BOOL found = false; for (std::string ext : exts) { - if (argv_i.find(ext) != std::string::npos) { + if (argv_i.ends_with(ext)) { found = true; if (kFactory.Compile(argv_i, kMachine) != kExitOK) { @@ -898,7 +898,7 @@ LIBCOMPILER_MODULE(CompilerCPlusPlusAMD64) { if (!found) { if (kVerbose) { - Detail::print_error(argv_i + " is not a valid C++ source.\n", "cxxdrv"); + Detail::print_error(argv_i + " is not a valid C++ source.", "cxxdrv"); } return LIBCOMPILER_INVALID_DATA; @@ -909,12 +909,13 @@ LIBCOMPILER_MODULE(CompilerCPlusPlusAMD64) { delete kCompilerFrontend; kCompilerFrontend = nullptr; - + kRegisterMap.clear(); kOriginMap.clear(); return LIBCOMPILER_SUCCESS; } +// // Last rev 8-1-24 // |
