#include "Program.hpp" namespace roza { /*explicit*/ Program::Program() { } /*virtual*/ Program::~Program() { } void Program::push_instr(Opcode opcode, std::optional param) { m_instrs.push_back({opcode, param}); } size_t Program::push_value(std::shared_ptr value) { size_t sz = m_values.size(); m_values.push_back(value); return sz; } Opcode Program::opcode(size_t index) const { assert(index < size()); return m_instrs[index].opcode; } std::optional Program::param(size_t index) const { assert(index < size()); return m_instrs[index].param; } std::string Program::string() const { std::stringstream ss; size_t addr = 0; for (auto const& instr: m_instrs) { ss << addr << "\t" << (OpcodeStr[instr.opcode]) << "\t" << (instr.param != std::nullopt ? std::to_string(*instr.param) : "") << "\n"; } return ss.str(); } }