summaryrefslogtreecommitdiffhomepage
path: root/C++Kit/AsmKit/AsmKit.cpp
blob: 75aaa55301a2a0fc4ac9ee473ea47c9f79fa1e24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
 *	========================================================
 *
 *	C++Kit
 * 	Copyright WestCo, all rights reserved.
 *
 * 	========================================================
 */

#include <AsmKit/AsmKit.hpp>
#include <StdKit/ErrorID.hpp>

#include <iostream>

//! @file AsmKit.cpp
//! @brief AssemblyKit

namespace CxxKit
{
	//! @brief Compile for specific format (ELF, PEF, ZBIN)
	Int32 AssemblyFactory::Compile(StringView& sourceFile, 
                                   const Int32& arch) noexcept
	{
		if (sourceFile.Length() < 1 ||
			!fMounted)	
			return CXXKIT_UNIMPLEMENTED;
		
		return fMounted->CompileToFormat(sourceFile, arch);		
	}
	
	//! @brief mount assembly backend.
	void AssemblyFactory::Mount(AssemblyMountpoint* mountPtr) noexcept
	{
		if (mountPtr)
			fMounted = mountPtr;
	}
	
	AssemblyMountpoint* AssemblyFactory::Unmount() noexcept
	{
		auto mount_prev = fMounted;
		
		if (mount_prev)
			fMounted = nullptr;
		
		return mount_prev;
	}
}