slige/runtime/vm.cpp
2024-11-08 12:22:42 +01:00

52 lines
1.3 KiB
C++

#include "vm.hpp"
#include "arch.hpp"
#include <format>
#include <iostream>
using namespace sliger;
void VM::run()
{
while (!done()) {
auto op = eat_as_op();
switch (op) {
case Op::Nop:
// nothing
break;
case Op::PushNull:
this->stack.push_back(Null {});
break;
case Op::PushInt:
if (done()) {
std::cerr
<< std::format("program malformed: missing int value");
}
this->stack.push_back(Null {});
break;
case Op::PushString:
case Op::PushArray:
case Op::PushStruct:
case Op::PushPtr:
case Op::Pop:
case Op::LoadLocal:
case Op::StoreLocal:
case Op::Call:
case Op::Return:
case Op::Jump:
case Op::JumpIfNotZero:
case Op::Add:
case Op::Subtract:
case Op::Multiply:
case Op::Divide:
case Op::Remainder:
case Op::Equal:
case Op::LessThan:
case Op::And:
case Op::Or:
case Op::Xor:
case Op::Not:
break;
}
}
}