simple-jit/include/Executable.h
2025-10-15 11:30:58 +00:00

26 lines
522 B
C++
Executable file

#include <cstddef>
#include "Types.h"
#include "Noncopyable.h"
class Executable {
MAKE_NONCOPYABLE(Executable);
MAKE_NONMOVABLE(Executable);
public:
Executable(void* code, std::size_t code_size);
~Executable();
template<typename Return>
Return run() const
{
using ExecutableFunction = Return();
auto executable_function = reinterpret_cast<ExecutableFunction*>(m_code);
return executable_function();
}
private:
void* m_code;
std::size_t m_code_size;
};