From f86999e137f43372236f2dccd1fe3572a85c0dcd Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 17 Oct 2020 14:16:46 +0200 Subject: Separate-out assembler --- asm/assembler.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 asm/assembler.h (limited to 'asm/assembler.h') 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 +#include +#include +#include +#include +#include + +using AsmArgs = std::vector; // 0th element is mnemonic +using FactoryFunction = std::function(AsmArgs&)>; + +bool registerOp(const std::string& mnemonic, FactoryFunction f); + +template +std::string mangleNameOne(const std::string& s) +{ + return s + "_" + typeid(T).name(); +} + +template +std::string mangleName(const std::string& s) +{ + if constexpr (sizeof...(Targs) == 0) + return mangleNameOne(s); + else + return mangleName(s + "_" + typeid(T).name()); +} + -- cgit v1.2.3