diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-12 08:29:40 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-12 08:29:40 +0200 |
| commit | 1ddeab9a4426abd781a5066ba79af2ba64de11d9 (patch) | |
| tree | 06155b0e26fcc2a9fc2d8e684155f82ded3d1552 /dev/LibCompiler/src/AssemblyFactory+AssemblyInterface.cc | |
| parent | 87979899ce833ca477bb563b84e3698224119dab (diff) | |
| parent | 2be9a150bb742987330c6de4dac23d4d2efb1ebe (diff) | |
Merge pull request #5 from nekernel-org/dev
0.0.1e2
Diffstat (limited to 'dev/LibCompiler/src/AssemblyFactory+AssemblyInterface.cc')
| -rw-r--r-- | dev/LibCompiler/src/AssemblyFactory+AssemblyInterface.cc | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/dev/LibCompiler/src/AssemblyFactory+AssemblyInterface.cc b/dev/LibCompiler/src/AssemblyFactory+AssemblyInterface.cc new file mode 100644 index 0000000..11655fb --- /dev/null +++ b/dev/LibCompiler/src/AssemblyFactory+AssemblyInterface.cc @@ -0,0 +1,51 @@ +/* ------------------------------------------- + + Copyright (C) 2024-2025 Amlal EL Mahrous, all rights reserved + +------------------------------------------- */ + +#include <LibCompiler/AssemblyInterface.h> +#include <LibCompiler/ErrorID.h> + +/** + * @file AssemblyFactory.cxx + * @author amlal (amlal@nekernel.org) + * @brief Assembler Kit + * @version 0.1 + * @date 2024-01-27 + * + * @copyright Copyright (c) 2024-2025 Amlal El Mahrouss + * + */ + +//! @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 LIBCOMPILER_UNIMPLEMENTED; + + if (arch != fMounted->Arch()) return LIBCOMPILER_INVALID_ARCH; + + 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 |
