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 | |
| parent | 49064df5303b9a96f6b11dd0aed27dc1e269aa9e (diff) | |
feat: API and codebase tweaks.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/CompilerKit/src')
| -rw-r--r-- | dev/CompilerKit/src/AssemblyFactory.cc | 2 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Backend/Assembler32x0.cc | 2 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Backend/Assembler64x0.cc | 2 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Backend/AssemblerAMD64.cc | 2 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Backend/AssemblerARM64.cc | 2 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Backend/AssemblerPowerPC.cc | 2 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Frontend.cc (renamed from dev/CompilerKit/src/FrontendHelpers.cc) | 10 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Frontend/CCompiler64x0.cc | 2 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Frontend/CCompilerARM64.cc | 2 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Frontend/CCompilerPower64.cc | 2 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc | 53 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Linker/DynamicLinker64PEF.cc | 2 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Macro/CPlusPlusPreprocessor.cc | 2 | ||||
| -rw-r--r-- | dev/CompilerKit/src/StringKit.cc | 2 |
14 files changed, 51 insertions, 36 deletions
diff --git a/dev/CompilerKit/src/AssemblyFactory.cc b/dev/CompilerKit/src/AssemblyFactory.cc index 1f08b32..b047c04 100644 --- a/dev/CompilerKit/src/AssemblyFactory.cc +++ b/dev/CompilerKit/src/AssemblyFactory.cc @@ -10,7 +10,7 @@ /** * @file AssemblyFactory.cc * @author Amlal El Mahrouss (amlal@nekernel.org) - * @brief Compiler API of NeCTI + * @brief Assembly API of NeCTI * @version 0.0.2 * * @copyright Copyright (c) 2024-2025 Amlal El Mahrouss diff --git a/dev/CompilerKit/src/Backend/Assembler32x0.cc b/dev/CompilerKit/src/Backend/Assembler32x0.cc index 5534f59..0fd83d2 100644 --- a/dev/CompilerKit/src/Backend/Assembler32x0.cc +++ b/dev/CompilerKit/src/Backend/Assembler32x0.cc @@ -9,7 +9,7 @@ ///////////////////////////////////////////////////////////////////////////////////////// // @file 32asm.cc -// @author EL Mahrouss Amlal +// @author El Mahrouss Amlal // @brief 32x0 Assembler. // REMINDER: when dealing with an undefined symbol use (string diff --git a/dev/CompilerKit/src/Backend/Assembler64x0.cc b/dev/CompilerKit/src/Backend/Assembler64x0.cc index 7aa991b..435af3c 100644 --- a/dev/CompilerKit/src/Backend/Assembler64x0.cc +++ b/dev/CompilerKit/src/Backend/Assembler64x0.cc @@ -9,7 +9,7 @@ ///////////////////////////////////////////////////////////////////////////////////////// // @file Assembler64x0.cc -// @author EL Mahrouss Amlal +// @author El Mahrouss Amlal // @brief 64x000 Assembler. // REMINDER: when dealing with an undefined symbol use (string diff --git a/dev/CompilerKit/src/Backend/AssemblerAMD64.cc b/dev/CompilerKit/src/Backend/AssemblerAMD64.cc index ec71f9b..03e3db0 100644 --- a/dev/CompilerKit/src/Backend/AssemblerAMD64.cc +++ b/dev/CompilerKit/src/Backend/AssemblerAMD64.cc @@ -7,7 +7,7 @@ ///////////////////////////////////////////////////////////////////////////////////////// /// @file AssemblerAMD64.cc -/// @author EL Mahrouss Amlal +/// @author El Mahrouss Amlal /// @brief AMD64 Assembler. /// REMINDER: when dealing with an undefined symbol use (string /// size):LinkerFindSymbol:(string) so that ld will look for it. diff --git a/dev/CompilerKit/src/Backend/AssemblerARM64.cc b/dev/CompilerKit/src/Backend/AssemblerARM64.cc index fb03da8..59002a3 100644 --- a/dev/CompilerKit/src/Backend/AssemblerARM64.cc +++ b/dev/CompilerKit/src/Backend/AssemblerARM64.cc @@ -7,7 +7,7 @@ ///////////////////////////////////////////////////////////////////////////////////////// /// @file AssemblerARM64.cc -/// @author EL Mahrouss Amlal +/// @author El Mahrouss Amlal /// @brief 'ACORN' Assembler. /// REMINDER: when dealing with an undefined symbol use (string diff --git a/dev/CompilerKit/src/Backend/AssemblerPowerPC.cc b/dev/CompilerKit/src/Backend/AssemblerPowerPC.cc index ffcc102..7fddffc 100644 --- a/dev/CompilerKit/src/Backend/AssemblerPowerPC.cc +++ b/dev/CompilerKit/src/Backend/AssemblerPowerPC.cc @@ -7,7 +7,7 @@ ///////////////////////////////////////////////////////////////////////////////////////// /// @file AssemblerPower.cc -/// @author EL Mahrouss Amlal +/// @author El Mahrouss Amlal /// @brief POWER Assembler. /// REMINDER: when dealing with an undefined symbol use (string diff --git a/dev/CompilerKit/src/FrontendHelpers.cc b/dev/CompilerKit/src/Frontend.cc index dc81fa2..ef7b79f 100644 --- a/dev/CompilerKit/src/FrontendHelpers.cc +++ b/dev/CompilerKit/src/Frontend.cc @@ -6,6 +6,16 @@ #include <CompilerKit/Frontend.h> +/** + * @file Frontend.cc + * @author Amlal El Mahrouss (amlal@nekernel.org) + * @brief Frontend API of NeCTI + * @version 0.0.2 + * + * @copyright Copyright (c) 2025 Amlal El Mahrouss and NeKernel.org Contributors + * + */ + namespace CompilerKit { /// find the perfect matching word in a haystack. /// \param haystack base string diff --git a/dev/CompilerKit/src/Frontend/CCompiler64x0.cc b/dev/CompilerKit/src/Frontend/CCompiler64x0.cc index c23f255..1b04260 100644 --- a/dev/CompilerKit/src/Frontend/CCompiler64x0.cc +++ b/dev/CompilerKit/src/Frontend/CCompiler64x0.cc @@ -27,7 +27,7 @@ /* This is part of the CompilerKit. */ /* (c) Amlal El Mahrouss */ -/// @author EL Mahrouss Amlal (amlel) +/// @author El Mahrouss Amlal (amlel) /// @file 64x0-cc.cc /// @brief 64x0 C Compiler. diff --git a/dev/CompilerKit/src/Frontend/CCompilerARM64.cc b/dev/CompilerKit/src/Frontend/CCompilerARM64.cc index 88e2113..5c03d41 100644 --- a/dev/CompilerKit/src/Frontend/CCompilerARM64.cc +++ b/dev/CompilerKit/src/Frontend/CCompilerARM64.cc @@ -28,7 +28,7 @@ /* This is part of the CompilerKit. */ /* (c) Amlal El Mahrouss */ -/// @author EL Mahrouss Amlal (amlel) +/// @author El Mahrouss Amlal (amlel) /// @file ARM64-cc.cc /// @brief ARM64 C Compiler. diff --git a/dev/CompilerKit/src/Frontend/CCompilerPower64.cc b/dev/CompilerKit/src/Frontend/CCompilerPower64.cc index 39bb58c..2167e21 100644 --- a/dev/CompilerKit/src/Frontend/CCompilerPower64.cc +++ b/dev/CompilerKit/src/Frontend/CCompilerPower64.cc @@ -22,7 +22,7 @@ #define kExitOK 0 -/// @author EL Mahrouss Amlal (amlal@nekernel.org) +/// @author El Mahrouss Amlal (amlal@nekernel.org) /// @file cc.cc /// @brief POWER64 C Compiler. 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; } diff --git a/dev/CompilerKit/src/Linker/DynamicLinker64PEF.cc b/dev/CompilerKit/src/Linker/DynamicLinker64PEF.cc index 617ee03..efc4c83 100644 --- a/dev/CompilerKit/src/Linker/DynamicLinker64PEF.cc +++ b/dev/CompilerKit/src/Linker/DynamicLinker64PEF.cc @@ -7,7 +7,7 @@ ------------------------------------------- */ -/// @author EL Mahrouss Amlal (amlal@nekernel.org) +/// @author El Mahrouss Amlal (amlal@nekernel.org) /// @brief NeKernel.org 64-bit PEF Linker. /// Last Rev: Sat Apr 19 CET 2025 /// @note Do not look up for anything with .code64/.data64/.zero64! diff --git a/dev/CompilerKit/src/Macro/CPlusPlusPreprocessor.cc b/dev/CompilerKit/src/Macro/CPlusPlusPreprocessor.cc index 3a649a7..2f16d01 100644 --- a/dev/CompilerKit/src/Macro/CPlusPlusPreprocessor.cc +++ b/dev/CompilerKit/src/Macro/CPlusPlusPreprocessor.cc @@ -20,7 +20,7 @@ #define kMacroPrefix '#' -/// @author EL Mahrouss Amlal (amlel) +/// @author El Mahrouss Amlal (amlel) /// @file CPlusPlusPreprocessor.cc /// @brief Preprocessor. diff --git a/dev/CompilerKit/src/StringKit.cc b/dev/CompilerKit/src/StringKit.cc index 67f2f55..35775f1 100644 --- a/dev/CompilerKit/src/StringKit.cc +++ b/dev/CompilerKit/src/StringKit.cc @@ -8,7 +8,7 @@ */ /** - * @file BasicString.cc + * @file StringKit.cc * @author Amlal (amlal@nekernel.org) * @brief C++ string manipulation API. * @version 0.2 |
