summaryrefslogtreecommitdiffhomepage
path: root/dev/LibCompiler/src/AssemblyFactory.cc
diff options
context:
space:
mode:
authorAmlal <amlal.elmahrouss@icloud.com>2025-01-21 20:23:15 +0100
committerAmlal <amlal.elmahrouss@icloud.com>2025-01-21 20:23:15 +0100
commita133c71c22b8f9576bfc667f000c7c764d4505c8 (patch)
tree03b3edef5ebf7e0182b4ae73cd5d38c370ed947c /dev/LibCompiler/src/AssemblyFactory.cc
ADD: NeKernel Toolchain 0.0.9 (Beta Release)
Signed-off-by: Amlal <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/LibCompiler/src/AssemblyFactory.cc')
-rw-r--r--dev/LibCompiler/src/AssemblyFactory.cc59
1 files changed, 59 insertions, 0 deletions
diff --git a/dev/LibCompiler/src/AssemblyFactory.cc b/dev/LibCompiler/src/AssemblyFactory.cc
new file mode 100644
index 0000000..bfa0ef2
--- /dev/null
+++ b/dev/LibCompiler/src/AssemblyFactory.cc
@@ -0,0 +1,59 @@
+/* -------------------------------------------
+
+ Copyright (C) 2024 Amlal EL Mahrouss, all rights reserved
+
+------------------------------------------- */
+
+#include <LibCompiler/AAL/AssemblyInterface.h>
+#include <LibCompiler/NFC/ErrorID.h>
+
+/**
+ * @file AssemblyFactory.cxx
+ * @author amlal (amlal@zka.com)
+ * @brief Assembler Kit
+ * @version 0.1
+ * @date 2024-01-27
+ *
+ * @copyright Copyright (c) 2024 Amlal EL Mahrouss
+ *
+ */
+
+#include <iostream>
+
+//! @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;
+
+ 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