40 lines
1.3 KiB
C++
40 lines
1.3 KiB
C++
#include <array>
|
|
#include <execute/argumentvalue.hpp>
|
|
#include <execute/bytecode.hpp>
|
|
#include <execute/state.hpp>
|
|
#include <memory>
|
|
|
|
namespace Execute
|
|
{
|
|
class VirtualMachine {
|
|
private:
|
|
State state;
|
|
|
|
void DoArithmatic(InstructionByte const instruction, std::array<ArgumentValue, 3> & arguments);
|
|
void SetInteger(std::array<ArgumentValue, 3> & arguments);
|
|
void ExecuteJump(std::array<ArgumentValue, 3> & arguments);
|
|
void ExecuteInterrupt(std::array<ArgumentValue, 3> & arguments);
|
|
void ExecuteCall(std::array<ArgumentValue, 3> & arguments, std::size_t const returnByte);
|
|
void ExecuteReturn();
|
|
void DoBooleanLogic(
|
|
InstructionByte const instruction,
|
|
std::array<ArgumentValue, 3> & arguments,
|
|
std::size_t const nextInstruction);
|
|
void ExecutePop(std::array<ArgumentValue, 3> & arguments);
|
|
void ExecutePush(std::array<ArgumentValue, 3> & arguments);
|
|
|
|
void Step();
|
|
|
|
public:
|
|
void Run();
|
|
void SingleStep();
|
|
|
|
void SetMemorySize(std::size_t const size);
|
|
void LoadCode(std::vector<std::uint8_t> const & byteCode, bool const printDecodedBytes);
|
|
|
|
State const & GetState() const;
|
|
Execute::InstructionByte GetCurrentInstruction() const;
|
|
|
|
bool IsTerminated() const;
|
|
};
|
|
} |