#ifndef jk_PROGRAM_HPP #define jk_PROGRAM_HPP #include "commons.hpp" #include "Opcodes.hpp" #include "Value.hpp" namespace jk { using param_t = size_t; struct Instr { OpcodeType opcode; std::optional param; }; class Program { public: explicit Program(); virtual ~Program(); size_t size() const { return m_instrs.size(); } Instr get(size_t index) const; void push_instr(OpcodeType opcode, std::optional param = std::nullopt); void set_param(size_t index, param_t param); size_t push_constant(std::shared_ptr value); std::shared_ptr constant(size_t index) const; std::string string() const; private: std::vector m_instrs; std::vector> m_constants; }; } #endif