local opcodes = require('opcodes') local function set_proto(self, proto) self.proto = proto end local function step(self) if self.pc >= self.proto.numbc then return false end local ins = self.proto.bcins[self.pc+1] local decop = opcodes.decode(ins) print(opcodes.defs[decop.id].name) self.pc = self.pc + 1 return true end local function run(self) while self:step() do end end local VM = { new = function() return { set_proto = set_proto, step = step, run = run, pc = 0, } end } return { VM = VM }