diff options
Diffstat (limited to 'asm/assembler.h')
-rw-r--r-- | asm/assembler.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/asm/assembler.h b/asm/assembler.h new file mode 100644 index 0000000..b9c39a6 --- /dev/null +++ b/asm/assembler.h @@ -0,0 +1,31 @@ +#pragma once + +#include "chunk.h" + +#include <any> +#include <functional> +#include <iostream> +#include <memory> +#include <string> +#include <unordered_map> + +using AsmArgs = std::vector<std::any>; // 0th element is mnemonic +using FactoryFunction = std::function<std::shared_ptr<Op>(AsmArgs&)>; + +bool registerOp(const std::string& mnemonic, FactoryFunction f); + +template<typename T> +std::string mangleNameOne(const std::string& s) +{ + return s + "_" + typeid(T).name(); +} + +template<typename T, typename... Targs> +std::string mangleName(const std::string& s) +{ + if constexpr (sizeof...(Targs) == 0) + return mangleNameOne<T>(s); + else + return mangleName<Targs...>(s + "_" + typeid(T).name()); +} + |