blob: b9c39a6e8f8efa5996108a9dbe413ad098e8a193 (
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
|
#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());
}
|