#ifndef INTERPRETER_INTERPRETER_H_INCLUDED #define INTERPRETER_INTERPRETER_H_INCLUDED #include #include #include #include #include #include "opcodes.hpp" #include "runtime.hpp" #include "types.hpp" namespace Interpreter { class Interpreter { std::stack mCallstack; bool mRunning; Runtime mRuntime; std::map> mSegment0; std::map> mSegment2; std::map> mSegment3; std::map> mSegment5; // not implemented Interpreter(const Interpreter&); Interpreter& operator=(const Interpreter&); void execute(Type_Code code); void begin(); void end(); template void installSegment(TSeg& seg, int code, TOp&& op) { assert(seg.find(code) == seg.end()); seg.emplace(code, std::move(op)); } public: Interpreter(); template void installSegment0(int code, TArgs&&... args) { installSegment(mSegment0, code, std::make_unique(std::forward(args)...)); } template void installSegment2(int code, TArgs&&... args) { installSegment(mSegment2, code, std::make_unique(std::forward(args)...)); } template void installSegment3(int code, TArgs&&... args) { installSegment(mSegment3, code, std::make_unique(std::forward(args)...)); } template void installSegment5(int code, TArgs&&... args) { installSegment(mSegment5, code, std::make_unique(std::forward(args)...)); } void run(const Type_Code* code, int codeSize, Context& context); }; } #endif