diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-10-14 18:06:03 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-10-14 18:06:03 +0200 |
commit | 5577b531291fd5e8e02d2a1246d72ef7c129e3cf (patch) | |
tree | da264dd58cb197773ee8bf8d77760ef0510a97cd | |
parent | 29b57bfa7c2c7b3297e88c66ad9e45a5979844a8 (diff) |
Registration of instructions, parameterized by argument types
-rw-r--r-- | intel.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
@@ -372,6 +372,16 @@ protected: std::vector<uint8_t> machine_code; }; +class Op_Label: public OpSimple +{ +public: + Op_Label(const std::string& name) : OpSimple({}), m_name(name) {} + std::string name(){return m_name;} + +private: + std::string m_name; +}; + class Op_nop: public OpSimple { public: @@ -379,7 +389,24 @@ public: }; -bool registered { registerOp("nop", [](AsmArgs& args) -> std::shared_ptr<Op>{ return std::make_shared<Op_nop>(); }) }; +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()); +} + +bool registered { registerOp("nop", [](AsmArgs& args) -> std::shared_ptr<Op>{ + return std::make_shared<Op_nop>(); + }) }; class Assembler { |