#pragma once //#include "chunk.h" //#include "segment.h" #include #include #include #include #include #include using AsmArgs = std::vector; using FactoryFunction = std::function(AsmArgs&)>; // mnemonic: mnemonic including argument types bool registerOp(const std::string& mnemonic, FactoryFunction f); // Create Op from a registered mnemonic // mnemonic: just the mnemonic name std::shared_ptr makeOp(const std::string& mnemonic, AsmArgs& args); // overload for empty list of arguments std::shared_ptr makeOp(const std::string& mnemonic); 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()); } std::string mangleName(const std::string& s, AsmArgs& args); class Immediate8 { public: Immediate8(uint8_t value): m_value(value) {} uint8_t value() {return m_value;} private: uint8_t m_value; };