From d8d943929c25151fd6a8aadd6ea4cdbd5065845a Mon Sep 17 00:00:00 2001 From: Amlal Date: Wed, 7 May 2025 09:18:33 +0200 Subject: feat(LibCompiler): Reworking architecture to integrate the Arch() method in the AssemblyInterface. Signed-off-by: Amlal --- dev/LibCompiler/AssemblyInterface.h | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'dev/LibCompiler/AssemblyInterface.h') diff --git a/dev/LibCompiler/AssemblyInterface.h b/dev/LibCompiler/AssemblyInterface.h index 5450f84..b612962 100644 --- a/dev/LibCompiler/AssemblyInterface.h +++ b/dev/LibCompiler/AssemblyInterface.h @@ -13,19 +13,8 @@ #define ASSEMBLY_INTERFACE : public LibCompiler::AssemblyInterface namespace LibCompiler { -/// @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; - virtual ~AssemblyInterface() = default; - - LIBCOMPILER_COPY_DEFAULT(AssemblyInterface); - - /// @brief compile to object file. - /// @note Example C++ -> MASM -> AE object. - virtual Int32 CompileToFormat(std::string src, Int32 arch) = 0; -}; +class AssemblyFactory; +class AssemblyInterface; /// @brief Simple assembly factory class AssemblyFactory final { @@ -37,7 +26,8 @@ class AssemblyFactory final { public: enum { - kArchAMD64, + kArchInvalid = 0, + kArchAMD64 = 100, kArch32x0, kArch64x0, kArchRISCV, @@ -55,6 +45,22 @@ 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; + virtual ~AssemblyInterface() = default; + + LIBCOMPILER_COPY_DEFAULT(AssemblyInterface); + + [[maybe_unused]] virtual Int32 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; +}; + union NumberCastBase { NumberCastBase() = default; ~NumberCastBase() = default; -- cgit v1.2.3