40 lines
739 B
C++
40 lines
739 B
C++
#ifndef roza_PROGRAM_HPP
|
|
#define roza_PROGRAM_HPP
|
|
|
|
#include "commons.hpp"
|
|
#include "opcodes.hpp"
|
|
#include "Value.hpp"
|
|
|
|
namespace roza
|
|
{
|
|
using param_t = int;
|
|
|
|
struct Instr {
|
|
Opcode opcode;
|
|
std::optional<param_t> param;
|
|
};
|
|
|
|
class Program
|
|
{
|
|
public:
|
|
explicit Program();
|
|
virtual ~Program();
|
|
|
|
size_t size() const { return m_instrs.size(); }
|
|
|
|
void push_instr(Opcode opcode, std::optional<param_t> param = std::nullopt);
|
|
size_t push_value(std::shared_ptr<Value> value);
|
|
|
|
Opcode opcode(size_t index) const;
|
|
std::optional<param_t> param(size_t index) const;
|
|
|
|
std::string string() const;
|
|
|
|
private:
|
|
std::vector<Instr> m_instrs;
|
|
std::vector<std::shared_ptr<Value>> m_values;
|
|
};
|
|
}
|
|
|
|
#endif
|