diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-19 09:21:48 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-19 09:21:48 +0100 |
| commit | 281bef7f35e63a9c5daf37cca5bb8eea64c12693 (patch) | |
| tree | 43025631e922b4d61b4b19e0f84cde8b7dd785b2 /dev | |
| parent | 893c7e2169bfce6211a23e865a1f7efb43d025c7 (diff) | |
| parent | a48098479269cdace4d9ce32264a73eef76994dc (diff) | |
Merge pull request #23 from nekernel-org/dev
feat: new documented codebase and improvements.
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/CompilerKit/Compiler.h | 16 | ||||
| -rw-r--r-- | dev/CompilerKit/Defines.h | 6 | ||||
| -rw-r--r-- | dev/CompilerKit/ErrorID.h | 6 | ||||
| -rw-r--r-- | dev/CompilerKit/ErrorOr.h | 6 | ||||
| -rw-r--r-- | dev/CompilerKit/Frontend.h | 19 | ||||
| -rw-r--r-- | dev/CompilerKit/StringKit.h | 6 | ||||
| -rw-r--r-- | dev/CompilerKit/Version.h | 2 | ||||
| -rw-r--r-- | dev/DebuggerKit/DebuggerContract.h | 6 | ||||
| -rw-r--r-- | dev/DebuggerKit/NeKernelContract.h | 4 | ||||
| -rw-r--r-- | dev/DebuggerKit/POSIXMachContract.h | 4 | ||||
| -rw-r--r-- | dev/DebuggerKit/Platform.h | 2 | ||||
| -rw-r--r-- | dev/DebuggerKit/Version.h | 2 |
12 files changed, 76 insertions, 3 deletions
diff --git a/dev/CompilerKit/Compiler.h b/dev/CompilerKit/Compiler.h index 3da99ca..a14005b 100644 --- a/dev/CompilerKit/Compiler.h +++ b/dev/CompilerKit/Compiler.h @@ -17,7 +17,9 @@ namespace CompilerKit { class AssemblyFactory; class AssemblyInterface; +/// =========================================================== /// /// @brief Simple assembly factory +/// =========================================================== /// class AssemblyFactory final { public: explicit AssemblyFactory() = default; @@ -47,8 +49,10 @@ class AssemblyFactory final { AssemblyInterface* fMounted{nullptr}; }; +/// =========================================================== /// /// @brief Assembly to binary generator class. /// @note This interface creates according to the CPU target of the child class. +/// =========================================================== /// class AssemblyInterface { public: explicit AssemblyInterface() = default; @@ -58,11 +62,16 @@ class AssemblyInterface { virtual UInt32 Arch() noexcept { return AssemblyFactory::kArchAMD64; } + /// =========================================================== /// /// @brief compile to object file. /// @note Example C++ -> MASM -> AE object. + /// =========================================================== /// virtual Int32 CompileToFormat(std::string src, Int32 arch) = 0; }; +/// =========================================================== /// +/// @brief Number casting unions for different sizes. +/// =========================================================== /// union NumberCastBase { NumberCastBase() = default; ~NumberCastBase() = default; @@ -108,6 +117,9 @@ union NumberCast8 final { UInt8 raw; }; +/// =========================================================== /// +/// @brief Assembly encoder interface. +/// =========================================================== /// class EncoderInterface { public: explicit EncoderInterface() = default; @@ -120,6 +132,10 @@ class EncoderInterface { virtual bool WriteNumber(const std::size_t& pos, std::string& from_what) = 0; }; +/// =========================================================== /// +/// @brief Different architecture encoders. +/// =========================================================== /// + #ifdef __ASM_NEED_AMD64__ class EncoderAMD64 final : public EncoderInterface { diff --git a/dev/CompilerKit/Defines.h b/dev/CompilerKit/Defines.h index 56e8dd3..34b43d6 100644 --- a/dev/CompilerKit/Defines.h +++ b/dev/CompilerKit/Defines.h @@ -7,6 +7,12 @@ #ifndef __NECTI_DEFINES_H__ #define __NECTI_DEFINES_H__ +/// =========================================================== /// +/// @file Defines.h +/// @author Amlal El Mahrouss +/// @brief Basic defines and types for CompilerKit. +/// =========================================================== /// + #ifndef Yes #define Yes true #endif // ifndef Yes diff --git a/dev/CompilerKit/ErrorID.h b/dev/CompilerKit/ErrorID.h index 7c76f86..c16f682 100644 --- a/dev/CompilerKit/ErrorID.h +++ b/dev/CompilerKit/ErrorID.h @@ -11,6 +11,12 @@ #include <CompilerKit/Defines.h> +/// =========================================================== /// +/// @file ErrorID.h +/// @author Amlal El Mahrouss +/// @brief Error IDs for CompilerKit. +/// =========================================================== /// + #define NECTI_SUCCESS 0 #define NECTI_EXEC_ERROR -30 #define NECTI_FILE_NOT_FOUND -31 diff --git a/dev/CompilerKit/ErrorOr.h b/dev/CompilerKit/ErrorOr.h index d5a1c08..66a90ee 100644 --- a/dev/CompilerKit/ErrorOr.h +++ b/dev/CompilerKit/ErrorOr.h @@ -9,6 +9,12 @@ #pragma once +/// =========================================================== /// +/// @file ErrorOr.h +/// @author Amlal El Mahrouss +/// @brief ErrorOr for CompilerKit. +/// =========================================================== /// + #include <CompilerKit/StringKit.h> #include <CompilerKit/Defines.h> #include <CompilerKit/ErrorID.h> diff --git a/dev/CompilerKit/Frontend.h b/dev/CompilerKit/Frontend.h index 4b03651..225de96 100644 --- a/dev/CompilerKit/Frontend.h +++ b/dev/CompilerKit/Frontend.h @@ -17,7 +17,10 @@ struct SyntaxLeafList; struct SyntaxLeafList; struct CompilerKeyword; +/// =========================================================== /// /// we want to do that because to separate keywords. +/// =========================================================== /// + enum KeywordKind { kKeywordKindNamespace, kKeywordKindFunctionStart, @@ -56,7 +59,9 @@ enum KeywordKind { kKeywordKindPtr, }; +/// =========================================================== /// /// \brief Compiler keyword information struct. +/// =========================================================== /// struct CompilerKeyword { CompilerKeyword(STLString name, KeywordKind kind) : keyword_name(name), keyword_kind(kind) {} @@ -81,20 +86,26 @@ struct SyntaxLeafList final { SyntaxLeaf& At(SizeType index) { return fLeafList[index]; } }; +/// =========================================================== /// /// 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; +/// =========================================================== /// /// find a word within strict conditions and returns a range of it. /// \param haystack /// \param needle /// \return position of needle. +/// =========================================================== /// SizeType find_word_range(STLString haystack, STLString needle) noexcept; +/// =========================================================== /// /// @brief Compiler backend, implements a frontend, such as C, C++... /// See Toolchain, for some examples. +/// =========================================================== /// class CompilerFrontendInterface { public: explicit CompilerFrontendInterface() = default; @@ -102,18 +113,26 @@ class CompilerFrontendInterface { NECTI_COPY_DEFAULT(CompilerFrontendInterface); + /// =========================================================== /// // NOTE: cast this to your user defined ast. + /// =========================================================== /// typedef void* AstType; + /// =========================================================== /// //! @brief Compile a syntax tree ouf of the text. //! Also takes the source file name for metadata. + /// =========================================================== /// virtual CompilerKit::SyntaxLeafList::SyntaxLeaf Compile(std::string text, std::string file) = 0; + /// =========================================================== /// //! @brief What language are we dealing with? + /// =========================================================== /// virtual const char* Language() { return kInvalidFrontend; } + /// =========================================================== /// /// @brief Checks if language is a valid frontend. + /// =========================================================== /// virtual bool IsValid() { return strcmp(this->Language(), kInvalidFrontend) > 0; } }; } // namespace CompilerKit diff --git a/dev/CompilerKit/StringKit.h b/dev/CompilerKit/StringKit.h index 69efb9c..0fbe58a 100644 --- a/dev/CompilerKit/StringKit.h +++ b/dev/CompilerKit/StringKit.h @@ -13,6 +13,12 @@ #include <CompilerKit/Defines.h> #include <CompilerKit/ErrorOr.h> +/// =========================================================== /// +/// @file StringKit.h +/// @author Amlal El Mahrouss +/// @brief StringKit for CompilerKit. +/// =========================================================== /// + namespace CompilerKit { class StringBuilder; class BasicString; diff --git a/dev/CompilerKit/Version.h b/dev/CompilerKit/Version.h index dd5e1f8..577e034 100644 --- a/dev/CompilerKit/Version.h +++ b/dev/CompilerKit/Version.h @@ -6,7 +6,7 @@ #pragma once -#define kDistVersion "v0.0.6-compilerkit" +#define kDistVersion "v0.0.7-compilerkit" #define kDistVersionBCD 0x0002 #define ToString(X) Stringify(X) diff --git a/dev/DebuggerKit/DebuggerContract.h b/dev/DebuggerKit/DebuggerContract.h index 9ee17d1..d1c8ed1 100644 --- a/dev/DebuggerKit/DebuggerContract.h +++ b/dev/DebuggerKit/DebuggerContract.h @@ -13,14 +13,20 @@ namespace DebuggerKit { class DebuggerContract; +/// =========================================================== /// /// \brief Process ID +/// =========================================================== /// typedef uint64_t ProcessID; +/// =========================================================== /// /// \brief Address type, a la BSD. +/// =========================================================== /// typedef char* CAddress; +/// =========================================================== /// /// \brief Debugger contract class in C++, as per the design states. /// \author Amlal El Mahrouss +/// =========================================================== /// class DebuggerContract { public: explicit DebuggerContract() = default; diff --git a/dev/DebuggerKit/NeKernelContract.h b/dev/DebuggerKit/NeKernelContract.h index 3a1fbad..669ee1f 100644 --- a/dev/DebuggerKit/NeKernelContract.h +++ b/dev/DebuggerKit/NeKernelContract.h @@ -27,6 +27,10 @@ namespace Detail { typedef int64_t dk_socket_type; } // namespace Detail +/// =========================================================== /// +/// \brief NeKernel Debugger Contract +/// \author Amlal El Mahrouss +/// =========================================================== /// class NeKernelContract final DK_DEBUGGER_CONTRACT { public: NeKernelContract(); diff --git a/dev/DebuggerKit/POSIXMachContract.h b/dev/DebuggerKit/POSIXMachContract.h index 2df6ef1..4c20d38 100644 --- a/dev/DebuggerKit/POSIXMachContract.h +++ b/dev/DebuggerKit/POSIXMachContract.h @@ -42,8 +42,10 @@ CK_IMPORT_C kern_return_t mach_vm_protect(vm_map_t target_task, mach_vm_address_ #define PTRACE_PEEKTEXT PT_READ_I namespace DebuggerKit::POSIX { -/// \brief POSIXMachContract engine interface class in C++ +/// =========================================================== /// +/// \brief POSIXMachContract engine class in C++ /// \author Amlal El Mahrouss +/// =========================================================== /// class POSIXMachContract final DK_DEBUGGER_CONTRACT { public: explicit POSIXMachContract() = default; diff --git a/dev/DebuggerKit/Platform.h b/dev/DebuggerKit/Platform.h index 7de443b..26f47ff 100644 --- a/dev/DebuggerKit/Platform.h +++ b/dev/DebuggerKit/Platform.h @@ -7,7 +7,9 @@ #pragma once +/// =========================================================== /// /// @author Amlal El Mahrouss +/// =========================================================== /// #include <arpa/inet.h> #include <sys/socket.h> diff --git a/dev/DebuggerKit/Version.h b/dev/DebuggerKit/Version.h index 5aff977..d7e3985 100644 --- a/dev/DebuggerKit/Version.h +++ b/dev/DebuggerKit/Version.h @@ -6,7 +6,7 @@ #pragma once -#define kDistVersion "v0.0.6-debuggerkit" +#define kDistVersion "v0.0.7-debuggerkit" #define kDistVersionBCD 0x0001 #define ToString(X) Stringify(X) |
