Added LoadVar support to the VM and fixed a minor mistake in the debugger output

This commit is contained in:
Mattia Giambirtone 2022-05-22 13:09:46 +02:00
parent 42ab1d4c6e
commit 9f1769ab71
2 changed files with 3 additions and 1 deletions

View File

@ -165,6 +165,8 @@ proc dispatch*(self: PeonVM) =
of OpCode.Return:
# TODO
return
of OpCode.LoadVar:
self.push(self.stack[self.readLong()])
of NoOp:
continue
of Pop:

View File

@ -78,7 +78,7 @@ proc argumentDoubleInstruction(instruction: OpCode, chunk: Chunk, offset: int):
## Debugs instructions that operate on a hardcoded value on the stack using a 16-bit operand
var slot = [chunk.code[offset + 1], chunk.code[offset + 2]].fromDouble()
printInstruction(instruction)
stdout.write(&", has argument ")
stdout.styledWrite(fgGreen, &", has argument ")
setForegroundColor(fgYellow)
stdout.write(&"{slot}")
nl()