From f61c814a0a95e98529c96361c992f1a8ea24688a Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 27 Dec 2024 07:39:05 +0100 Subject: META: Refactor source code. Signed-off-by: Amlal El Mahrouss --- dev/LibCompiler/src/AssemblyFactory.cc | 59 ++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 dev/LibCompiler/src/AssemblyFactory.cc (limited to 'dev/LibCompiler/src/AssemblyFactory.cc') diff --git a/dev/LibCompiler/src/AssemblyFactory.cc b/dev/LibCompiler/src/AssemblyFactory.cc new file mode 100644 index 0000000..a0d7bd8 --- /dev/null +++ b/dev/LibCompiler/src/AssemblyFactory.cc @@ -0,0 +1,59 @@ +/* ------------------------------------------- + + Copyright (C) 2024 Theater Quality Inc, all rights reserved + +------------------------------------------- */ + +#include +#include + +/** + * @file AssemblyFactory.cxx + * @author amlal (amlal@zka.com) + * @brief Assembler Kit + * @version 0.1 + * @date 2024-01-27 + * + * @copyright Copyright (c) 2024 Theater Quality Inc + * + */ + +#include + +//! @file Asm.cpp +//! @brief AssemblyKit source implementation. + +namespace LibCompiler +{ + ///! @brief Compile for specific format (ELF, PEF, ZBIN) + Int32 AssemblyFactory::Compile(std::string& sourceFile, + const Int32& arch) noexcept + { + if (sourceFile.length() < 1 || !fMounted) + return TOOLCHAINKIT_UNIMPLEMENTED; + + return fMounted->CompileToFormat(sourceFile, arch); + } + + ///! @brief mount assembly backend. + void AssemblyFactory::Mount(AssemblyInterface* mountPtr) noexcept + { + if (mountPtr) + { + fMounted = mountPtr; + } + } + + ///! @brief Unmount assembler. + AssemblyInterface* AssemblyFactory::Unmount() noexcept + { + auto mount_prev = fMounted; + + if (mount_prev) + { + fMounted = nullptr; + } + + return mount_prev; + } +} // namespace LibCompiler -- cgit v1.2.3