diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-17 11:00:30 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-17 11:00:30 +0100 |
| commit | 2e9741a0af3ffcc613101b47ba39b883e26e39ea (patch) | |
| tree | 73c05e9d2e51488d895e9d899eaf29640265e552 /dev/CompilerKit/src | |
| parent | 215f6fc35253a2326888b49a618f5cb758813977 (diff) | |
| parent | 0cca08fb5a26a9c50632d2a2a7cd49e8db55badc (diff) | |
Merge pull request #18 from nekernel-org/dev
version: v0.0.7
Diffstat (limited to 'dev/CompilerKit/src')
| -rw-r--r-- | dev/CompilerKit/src/AssemblyFactory.cc | 4 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Backend/Assembler32x0.cc | 4 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Backend/Assembler64x0.cc | 4 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Backend/AssemblerAMD64.cc | 6 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Backend/AssemblerARM64.cc | 4 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Backend/AssemblerPowerPC.cc | 4 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Frontend.cc (renamed from dev/CompilerKit/src/FrontendHelpers.cc) | 14 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Frontend/CCompiler64x0.cc | 4 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Frontend/CCompilerARM64.cc | 4 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Frontend/CCompilerPower64.cc | 4 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc | 55 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Linker/DynamicLinker64PEF.cc | 6 | ||||
| -rw-r--r-- | dev/CompilerKit/src/Macro/CPlusPlusPreprocessor.cc | 4 | ||||
| -rw-r--r-- | dev/CompilerKit/src/StringKit.cc | 4 |
14 files changed, 68 insertions, 53 deletions
diff --git a/dev/CompilerKit/src/AssemblyFactory.cc b/dev/CompilerKit/src/AssemblyFactory.cc index 1f08b32..927fcdd 100644 --- a/dev/CompilerKit/src/AssemblyFactory.cc +++ b/dev/CompilerKit/src/AssemblyFactory.cc @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024-2025 Amlal EL Mahrouss, all rights reserved + Copyright (C) 2024-2025 Amlal EL Mahrouss, Licensed under Apache 2.0 ------------------------------------------- */ @@ -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..e85a510 100644 --- a/dev/CompilerKit/src/Backend/Assembler32x0.cc +++ b/dev/CompilerKit/src/Backend/Assembler32x0.cc @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024-2025 Amlal EL Mahrouss, all rights reserved + Copyright (C) 2024-2025 Amlal EL Mahrouss, Licensed under Apache 2.0 ------------------------------------------- */ @@ -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..d0cf327 100644 --- a/dev/CompilerKit/src/Backend/Assembler64x0.cc +++ b/dev/CompilerKit/src/Backend/Assembler64x0.cc @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024-2025 Amlal EL Mahrouss, all rights reserved + Copyright (C) 2024-2025 Amlal EL Mahrouss, Licensed under Apache 2.0 ------------------------------------------- */ @@ -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 603b441..c684a07 100644 --- a/dev/CompilerKit/src/Backend/AssemblerAMD64.cc +++ b/dev/CompilerKit/src/Backend/AssemblerAMD64.cc @@ -1,13 +1,13 @@ /* ------------------------------------------- - Copyright (C) 2024-2025 Amlal EL Mahrouss, all rights reserved + Copyright (C) 2024-2025 Amlal EL Mahrouss, Licensed under Apache 2.0 ------------------------------------------- */ ///////////////////////////////////////////////////////////////////////////////////////// /// @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. @@ -965,7 +965,7 @@ bool CompilerKit::EncoderAMD64::WriteLine(std::string line, std::string file) { {.fName = "si", .fModRM = 0x6}, {.fName = "di", .fModRM = 7}, }; - BOOL foundInstruction = false; + Bool foundInstruction = false; for (auto& opcodeAMD64 : kOpcodesAMD64) { // strict check here diff --git a/dev/CompilerKit/src/Backend/AssemblerARM64.cc b/dev/CompilerKit/src/Backend/AssemblerARM64.cc index fb03da8..0cb7540 100644 --- a/dev/CompilerKit/src/Backend/AssemblerARM64.cc +++ b/dev/CompilerKit/src/Backend/AssemblerARM64.cc @@ -1,13 +1,13 @@ /* ------------------------------------------- - Copyright (C) 2024-2025 Amlal EL Mahrouss, all rights reserved + Copyright (C) 2024-2025 Amlal EL Mahrouss, Licensed under Apache 2.0 ------------------------------------------- */ ///////////////////////////////////////////////////////////////////////////////////////// /// @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..084e1fe 100644 --- a/dev/CompilerKit/src/Backend/AssemblerPowerPC.cc +++ b/dev/CompilerKit/src/Backend/AssemblerPowerPC.cc @@ -1,13 +1,13 @@ /* ------------------------------------------- - Copyright (C) 2024-2025 Amlal EL Mahrouss, all rights reserved + Copyright (C) 2024-2025 Amlal EL Mahrouss, Licensed under Apache 2.0 ------------------------------------------- */ ///////////////////////////////////////////////////////////////////////////////////////// /// @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 37b36f7..d34f064 100644 --- a/dev/CompilerKit/src/FrontendHelpers.cc +++ b/dev/CompilerKit/src/Frontend.cc @@ -1,17 +1,27 @@ /* ------------------------------------------- - Copyright (C) 2025 Amlal EL Mahrouss, all rights reserved + Copyright (C) 2025 Amlal EL Mahrouss, Licensed under Apache 2.0 ------------------------------------------- */ #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 /// \param needle the string we search for. /// \return if we found it or not. -BOOL find_word(STLString haystack, STLString needle) noexcept { +Bool find_word(STLString haystack, STLString needle) noexcept { auto index = haystack.find(needle); // check for needle validity. diff --git a/dev/CompilerKit/src/Frontend/CCompiler64x0.cc b/dev/CompilerKit/src/Frontend/CCompiler64x0.cc index c23f255..ec72570 100644 --- a/dev/CompilerKit/src/Frontend/CCompiler64x0.cc +++ b/dev/CompilerKit/src/Frontend/CCompiler64x0.cc @@ -2,7 +2,7 @@ * ======================================================== * * cc - * Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved. + * Copyright (C) 2024-2025 Amlal El Mahrouss, Licensed under Apache 2.0. * * ======================================================== */ @@ -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..9d1fd87 100644 --- a/dev/CompilerKit/src/Frontend/CCompilerARM64.cc +++ b/dev/CompilerKit/src/Frontend/CCompilerARM64.cc @@ -2,7 +2,7 @@ * ======================================================== * * CCompilerARM64 - * Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved. + * Copyright (C) 2024-2025 Amlal El Mahrouss, Licensed under Apache 2.0. * * ======================================================== */ @@ -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..6cdfc09 100644 --- a/dev/CompilerKit/src/Frontend/CCompilerPower64.cc +++ b/dev/CompilerKit/src/Frontend/CCompilerPower64.cc @@ -2,7 +2,7 @@ * ======================================================== * * CompilerPower64 - * Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved. + * Copyright (C) 2024-2025 Amlal El Mahrouss, Licensed under Apache 2.0. * * ======================================================== */ @@ -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..bf6ece0 100644 --- a/dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc +++ b/dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc @@ -2,19 +2,35 @@ * ======================================================== * * C++ Compiler Driver - * Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved. + * Copyright (C) 2024-2025 Amlal El Mahrouss, Licensed under Apache 2.0. * * ======================================================== */ /// 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..93f7919 100644 --- a/dev/CompilerKit/src/Linker/DynamicLinker64PEF.cc +++ b/dev/CompilerKit/src/Linker/DynamicLinker64PEF.cc @@ -1,13 +1,13 @@ /* ------------------------------------------- - Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved + Copyright (C) 2024-2025 Amlal El Mahrouss, Licensed under Apache 2.0 @file DynamicLinker64PEF.cc @brief: C++ 64-Bit PEF Linker for NeKernel.org's NeKernel ------------------------------------------- */ -/// @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! @@ -26,7 +26,7 @@ "NeKernel.org 64-Bit Linker (Preferred Executable Format) %s, (c) Amlal El Mahrouss, and " \ "NeKernel Contributors " \ "2024-2025 " \ - "all rights reserved.\n" + "Licensed under Apache 2.0.\n" #define kPefNoCpu (0U) #define kPefNoSubCpu (0U) diff --git a/dev/CompilerKit/src/Macro/CPlusPlusPreprocessor.cc b/dev/CompilerKit/src/Macro/CPlusPlusPreprocessor.cc index 3a649a7..fa5b043 100644 --- a/dev/CompilerKit/src/Macro/CPlusPlusPreprocessor.cc +++ b/dev/CompilerKit/src/Macro/CPlusPlusPreprocessor.cc @@ -2,7 +2,7 @@ * ======================================================== * * C++ Preprocessor Driver - * Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved. + * Copyright (C) 2024-2025 Amlal El Mahrouss, Licensed under Apache 2.0. * * ======================================================== */ @@ -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..99f3ef2 100644 --- a/dev/CompilerKit/src/StringKit.cc +++ b/dev/CompilerKit/src/StringKit.cc @@ -2,13 +2,13 @@ * ======================================================== * * CompilerKit - * Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved. + * Copyright (C) 2024-2025 Amlal El Mahrouss, Licensed under Apache 2.0. * * ======================================================== */ /** - * @file BasicString.cc + * @file StringKit.cc * @author Amlal (amlal@nekernel.org) * @brief C++ string manipulation API. * @version 0.2 |
