Removed some more duplicate code fragments from some opcodes

This commit is contained in:
nocturn9x 2021-01-11 08:42:05 +01:00
parent 064b3f087b
commit d0c6240b5a
1 changed files with 8 additions and 4 deletions

View File

@ -567,15 +567,19 @@ proc run(self: VM, repl: bool): InterpretResult =
else:
self.globals.del(constant)
of OpCode.GetLocal:
var slot: int
if frame.len > 255:
self.push(frame[frame.readBytes()])
slot = frame.readBytes()
else:
self.push(frame[int frame.readByte()])
slot = int frame.readByte()
self.push(frame[slot])
of OpCode.SetLocal:
var slot: int
if frame.len > 255:
frame[frame.readBytes()] = self.peek(0)
slot = frame.readBytes()
else:
frame[int frame.readByte()] = self.peek(0)
slot = int frame.readByte()
frame[slot] = self.peek(0)
of OpCode.DeleteLocal:
# TODO: Inspect potential issues with the GC
var slot: int