diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-18 01:57:41 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-18 01:57:41 +0100 |
| commit | 228479a454d325340326f4fd23e13d780884fd2a (patch) | |
| tree | ee35d5eecde396e674d1a0e11c5372352a49fac4 /src | |
| parent | 80de28e3472613e8f6aa8b2730d56b5307f4fb9a (diff) | |
chore & feat: New DLLLoader API and AST API improvements.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/CommandLine/pef-amd64-cxxdrv.json | 8 | ||||
| -rw-r--r-- | src/CommandLine/pef-arm64-cdrv.cc | 3 | ||||
| -rw-r--r-- | src/CommandLine/pef-arm64-cdrv.json | 4 | ||||
| -rw-r--r-- | src/CompilerKit/src/Assemblers/Assembler+32x0.cc | 4 | ||||
| -rw-r--r-- | src/CompilerKit/src/Assemblers/Assembler+64x0.cc | 4 | ||||
| -rw-r--r-- | src/CompilerKit/src/Assemblers/Assembler+AMD64.cc | 4 | ||||
| -rw-r--r-- | src/CompilerKit/src/Assemblers/Assembler+ARM64.cc | 4 | ||||
| -rw-r--r-- | src/CompilerKit/src/Assemblers/Assembler+PowerPC.cc | 4 | ||||
| -rw-r--r-- | src/CompilerKit/src/CodeGenerator+AssemblyFactory.cc | 24 | ||||
| -rw-r--r-- | src/CompilerKit/src/Compilers/CCompiler+Power64.cc | 6 | ||||
| -rw-r--r-- | src/CompilerKit/src/Compilers/CPlusPlusCompiler+AMD64.cc | 19 | ||||
| -rw-r--r-- | src/CompilerKit/src/Linkers/DynamicLinker64+PEF.cc (renamed from src/CompilerKit/src/DynamicLinkers/DynamicLinker64+PEF.cc) | 2 | ||||
| -rw-r--r-- | src/CompilerKit/src/Preprocessor/Preprocessor+Generic.cc | 2 |
13 files changed, 44 insertions, 44 deletions
diff --git a/src/CommandLine/pef-amd64-cxxdrv.json b/src/CommandLine/pef-amd64-cxxdrv.json index 62b5b4d..4520b86 100644 --- a/src/CommandLine/pef-amd64-cxxdrv.json +++ b/src/CommandLine/pef-amd64-cxxdrv.json @@ -2,9 +2,9 @@ "compiler_path": "clang++", "compiler_std": "c++20", "headers_path": [ - "../CompilerKit", - "../", - "../CompilerKit/src/Detail" + "../include/CompilerKit", + "../../include", + "../include/CompilerKit/src/Detail" ], "sources_path": [ "pef-amd64-cxxdrv.cc" @@ -16,4 +16,4 @@ "__CXXDRV__=202504", "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" ] -}
\ No newline at end of file +} diff --git a/src/CommandLine/pef-arm64-cdrv.cc b/src/CommandLine/pef-arm64-cdrv.cc index f4be5d0..c03b039 100644 --- a/src/CommandLine/pef-arm64-cdrv.cc +++ b/src/CommandLine/pef-arm64-cdrv.cc @@ -12,7 +12,7 @@ #include <CompilerKit/Utilities/Compiler.h> #include <CompilerKit/Utilities/DLL.h> -#ifdef __APPLE__ +#if defined(__APPLE__) static auto kPath = "/usr/local/lib/libCompilerKit.dylib"; #else static auto kPath = "/usr/lib/libCompilerKit.so"; @@ -22,6 +22,7 @@ static auto kSymbol = "CompilerCLangARM64"; Int32 main(Int32 argc, Char const* argv[]) { CompilerKit::DLLLoader dylib; + dylib(kPath, kSymbol); CompilerKit::DLLLoader::EntryT entrypoint_c = diff --git a/src/CommandLine/pef-arm64-cdrv.json b/src/CommandLine/pef-arm64-cdrv.json index be6a1be..e63e123 100644 --- a/src/CommandLine/pef-arm64-cdrv.json +++ b/src/CommandLine/pef-arm64-cdrv.json @@ -3,7 +3,7 @@ "compiler_std": "c++20", "headers_path": [ "../CompilerKit", - "../", + "../../include", "../CompilerKit/src/Detail" ], "sources_path": [ @@ -16,4 +16,4 @@ "__CXXDRV__=202504", "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" ] -}
\ No newline at end of file +} diff --git a/src/CompilerKit/src/Assemblers/Assembler+32x0.cc b/src/CompilerKit/src/Assemblers/Assembler+32x0.cc index dbf2898..c05bf1f 100644 --- a/src/CompilerKit/src/Assemblers/Assembler+32x0.cc +++ b/src/CompilerKit/src/Assemblers/Assembler+32x0.cc @@ -8,7 +8,7 @@ ///////////////////////////////////////////////////////////////////////////////////////// -// @file 32asm.cc +// @file Assembler+32x0.cc // @author Amlal El Mahrouss // @brief 32x0 Assembler. @@ -18,7 +18,7 @@ ///////////////////////////////////////////////////////////////////////////////////////// #ifndef __ASM_NEED_32x0__ -#define __ASM_NEED_32x0__ 1 +#define __ASM_NEED_32x0__ #endif #include <CompilerKit/AE.h> diff --git a/src/CompilerKit/src/Assemblers/Assembler+64x0.cc b/src/CompilerKit/src/Assemblers/Assembler+64x0.cc index 1ddb5d2..c7923e8 100644 --- a/src/CompilerKit/src/Assemblers/Assembler+64x0.cc +++ b/src/CompilerKit/src/Assemblers/Assembler+64x0.cc @@ -8,7 +8,7 @@ ///////////////////////////////////////////////////////////////////////////////////////// -// @file Assembler64x0.cc +// @file Assembler+64x0.cc // @author Amlal El Mahrouss // @brief 64x000 Assembler. @@ -18,7 +18,7 @@ ///////////////////////////////////////////////////////////////////////////////////////// #ifndef __ASM_NEED_64x0__ -#define __ASM_NEED_64x0__ 1 +#define __ASM_NEED_64x0__ #endif #include <CompilerKit/AE.h> diff --git a/src/CompilerKit/src/Assemblers/Assembler+AMD64.cc b/src/CompilerKit/src/Assemblers/Assembler+AMD64.cc index 6d1ca0e..b949e67 100644 --- a/src/CompilerKit/src/Assemblers/Assembler+AMD64.cc +++ b/src/CompilerKit/src/Assemblers/Assembler+AMD64.cc @@ -6,7 +6,7 @@ ///////////////////////////////////////////////////////////////////////////////////////// -/// @file AssemblerAMD64.cc +/// @file Assembler+AMD64.cc /// @author Amlal El Mahrouss /// @brief AMD64 Assembler. /// REMINDER: when dealing with an undefined symbol use (string @@ -22,7 +22,7 @@ ///////////////////////////////////////////////////////////////////////////////////////// #ifndef __ASM_NEED_AMD64__ -#define __ASM_NEED_AMD64__ 1 +#define __ASM_NEED_AMD64__ #endif #define kAssemblerPragmaSymStr "%%" diff --git a/src/CompilerKit/src/Assemblers/Assembler+ARM64.cc b/src/CompilerKit/src/Assemblers/Assembler+ARM64.cc index f5174aa..22b4023 100644 --- a/src/CompilerKit/src/Assemblers/Assembler+ARM64.cc +++ b/src/CompilerKit/src/Assemblers/Assembler+ARM64.cc @@ -6,7 +6,7 @@ ///////////////////////////////////////////////////////////////////////////////////////// -/// @file AssemblerARM64.cc +/// @file Assembler+ARM64.cc /// @author Amlal El Mahrouss /// @brief 'ACORN' Assembler. @@ -16,7 +16,7 @@ ///////////////////////////////////////////////////////////////////////////////////////// #ifndef __ASM_NEED_ARM64__ -#define __ASM_NEED_ARM64__ 1 +#define __ASM_NEED_ARM64__ #endif #include <CompilerKit/AE.h> diff --git a/src/CompilerKit/src/Assemblers/Assembler+PowerPC.cc b/src/CompilerKit/src/Assemblers/Assembler+PowerPC.cc index a61de04..48ddefe 100644 --- a/src/CompilerKit/src/Assemblers/Assembler+PowerPC.cc +++ b/src/CompilerKit/src/Assemblers/Assembler+PowerPC.cc @@ -6,7 +6,7 @@ ///////////////////////////////////////////////////////////////////////////////////////// -/// @file AssemblerPower.cc +/// @file Assembler+PowerPC.cc /// @author Amlal El Mahrouss /// @brief POWER Assembler. @@ -16,7 +16,7 @@ ///////////////////////////////////////////////////////////////////////////////////////// #ifndef __ASM_NEED_PPC__ -#define __ASM_NEED_PPC__ 1 +#define __ASM_NEED_PPC__ #endif #include <CompilerKit/AE.h> diff --git a/src/CompilerKit/src/CodeGenerator+AssemblyFactory.cc b/src/CompilerKit/src/CodeGenerator+AssemblyFactory.cc index c132638..98ba944 100644 --- a/src/CompilerKit/src/CodeGenerator+AssemblyFactory.cc +++ b/src/CompilerKit/src/CodeGenerator+AssemblyFactory.cc @@ -9,7 +9,7 @@ /** * @file AssemblyFactory.cc * @author Amlal El Mahrouss (amlal@nekernel.org) - * @brief Assembly API of Nectar + * @brief Nectar Assembly API * @version 0.0.3 * @copyright Copyright (c) 2024-2025 Amlal El Mahrouss * @@ -17,23 +17,19 @@ namespace CompilerKit { ///! @brief Compile for specific format (ELF, PEF, ZBIN) -Int32 AssemblyFactory::Compile(STLString sourceFile, const Int32& arch) noexcept { +Int32 AssemblyFactory::Compile(STLString sourceFile, const Int32& arch) { if (sourceFile.length() < 1) return NECTI_UNIMPLEMENTED; - if (!fMounted) return NECTI_UNIMPLEMENTED; - if (arch != fMounted->Arch()) return NECTI_INVALID_ARCH; + if (!this->fMounted) return NECTI_UNIMPLEMENTED; + if (arch != this->fMounted->Arch()) return NECTI_INVALID_ARCH; - try { - return this->fMounted->CompileToFormat(sourceFile, arch); - } catch (...) { - return NECTI_EXEC_ERROR; - } + return this->fMounted->CompileToFormat(sourceFile, arch); } ///! @brief mount assembly backend. -void AssemblyFactory::Mount(WeakRef<IAssembly> mountPtr) noexcept { - if (mountPtr) { - fMounted = mountPtr.Leak(); +void AssemblyFactory::Mount(WeakRef<IAssembly> mountPtr) { + if (mountPtr && !this->fMounted) { + this->fMounted = mountPtr.Leak(); } } @@ -41,8 +37,8 @@ void AssemblyFactory::Mount(WeakRef<IAssembly> mountPtr) noexcept { WeakRef<IAssembly> AssemblyFactory::Unmount() noexcept { auto mount_prev = fMounted; - if (fMounted) { - fMounted = nullptr; + if (this->fMounted) { + this->fMounted = nullptr; } return WeakRef<IAssembly>{mount_prev}; diff --git a/src/CompilerKit/src/Compilers/CCompiler+Power64.cc b/src/CompilerKit/src/Compilers/CCompiler+Power64.cc index 3867be6..39d09fd 100644 --- a/src/CompilerKit/src/Compilers/CCompiler+Power64.cc +++ b/src/CompilerKit/src/Compilers/CCompiler+Power64.cc @@ -33,14 +33,14 @@ ///////////////////////////////////// namespace Detail { -// \brief name to register struct. +/// \brief name to register struct. struct CompilerRegisterMap final { std::string fName; std::string fReg; }; -// \brief Map for C structs -// \author amlal@nekernel.org +/// \brief Map for C structs +/// \author amlal@nekernel.org struct CompilerStructMap final { /// 'struct::my_foo' std::string fName; diff --git a/src/CompilerKit/src/Compilers/CPlusPlusCompiler+AMD64.cc b/src/CompilerKit/src/Compilers/CPlusPlusCompiler+AMD64.cc index 7f92ef6..efe557f 100644 --- a/src/CompilerKit/src/Compilers/CPlusPlusCompiler+AMD64.cc +++ b/src/CompilerKit/src/Compilers/CPlusPlusCompiler+AMD64.cc @@ -30,7 +30,7 @@ #include <cstdlib> #include <filesystem> -/* NeKernel C++ Compiler Driver */ +/* NeKernel C++ Compiler Driver. */ /* This is part of the CompilerKit. */ /* (c) Amlal El Mahrouss 2024-2025 */ @@ -45,7 +45,7 @@ ///////////////////////////////////// /// @internal -// Avoids relative_path which could discard parts of the original. +/// @brief Avoids relative_path which could discard parts of the original. std::filesystem::path necti_expand_home(const std::filesystem::path& input) { const std::string& raw = input.string(); @@ -61,19 +61,20 @@ std::filesystem::path necti_expand_home(const std::filesystem::path& input) { return input; } +/// \brief Register map, i.e ({foobar, rbp+48}, etc...) struct CompilerRegisterMap final { CompilerKit::STLString fName{}; CompilerKit::STLString fReg{}; }; -/// \brief Offset based struct/class +/// \brief Offsets of struct and classes. struct CompilerStructMap final { CompilerKit::STLString fName{}; CompilerKit::STLString fReg{}; std::vector<std::pair<UInt32, CompilerKit::STLString>> fOffsets; }; -/// \brief Compiler state structure. +/// \brief State machine of the compiler. struct CompilerState final { std::vector<CompilerRegisterMap> fStackMapVector; std::vector<CompilerStructMap> fStructMapVector; @@ -83,16 +84,18 @@ struct CompilerState final { static CompilerState kState; +/// \brief Embed Scope of a class. static Int32 kOnClassScope = 0; ///////////////////////////////////////////////////////////////////////////////////////// -// Target architecture. +/// \brief Target architecture. +/// \note This shall never change. static Int32 kMachine = CompilerKit::AssemblyFactory::kArchAMD64; ///////////////////////////////////////// -// ARGUMENTS REGISTERS (R8, R15) +// ARGUMENT REGISTERS (R8, R15) ///////////////////////////////////////// @@ -111,7 +114,7 @@ static bool kOnForLoop = false; static bool kInBraces = false; static size_t kBracesCount = 0UL; -/* @brief C++ compiler backend for the NeKernel C++ driver */ +/* \brief C++ compiler backend for the NeKernel C++ driver */ class CompilerFrontendCPlusPlusAMD64 final CK_COMPILER_FRONTEND { public: explicit CompilerFrontendCPlusPlusAMD64() = default; @@ -146,7 +149,7 @@ static std::size_t kFunctionEmbedLevel = 0UL; /// detail namespaces const char* CompilerFrontendCPlusPlusAMD64::Language() { - return "AMD64 CFront"; + return "AMD64 C++"; } static std::uintptr_t kOrigin = kPefBaseOrigin; diff --git a/src/CompilerKit/src/DynamicLinkers/DynamicLinker64+PEF.cc b/src/CompilerKit/src/Linkers/DynamicLinker64+PEF.cc index f3eaaa9..6bc8063 100644 --- a/src/CompilerKit/src/DynamicLinkers/DynamicLinker64+PEF.cc +++ b/src/CompilerKit/src/Linkers/DynamicLinker64+PEF.cc @@ -2,7 +2,7 @@ Copyright (C) 2024-2025 Amlal El Mahrouss, licensed under the Apache 2.0 license - @file DynamicLinker64PEF.cc + @file DynamicLinker64+PEF.cc @brief: C++ 64-Bit PEF Linker for NeKernel.org's NeKernel ======================================== */ diff --git a/src/CompilerKit/src/Preprocessor/Preprocessor+Generic.cc b/src/CompilerKit/src/Preprocessor/Preprocessor+Generic.cc index 97bf44f..cef97b1 100644 --- a/src/CompilerKit/src/Preprocessor/Preprocessor+Generic.cc +++ b/src/CompilerKit/src/Preprocessor/Preprocessor+Generic.cc @@ -21,7 +21,7 @@ #define kMacroPrefix '#' /// @author Amlal El Mahrouss (amlal@nekernel.org) -/// @file CPlusPlusPreprocessor.cc +/// @file Preprocessor+Generic.cc /// @brief Preprocessor. typedef Int32 (*bpp_parser_fn_t)(CompilerKit::STLString& line, std::ifstream& hdr_file, |
