cleanup old code in vm, free globals

This commit is contained in:
prod2 2022-01-29 06:12:08 +01:00
parent 19b8079436
commit a13659e44f
1 changed files with 2 additions and 4 deletions

6
vm.nim
View File

@ -1,5 +1,4 @@
import strformat
#import tables
import chunk
import config
@ -37,7 +36,6 @@ proc run*(chunk: Chunk): InterpretResult =
ip: ptr uint8 = chunk.code[0].unsafeAddr
stack: Stack[NdValue] = newStack[NdValue](256)
hadError: bool
#globals: Table[string, NdValue]
globals: Table[NdValue, NdValue]
frames: Stack[Frame] = newStack[Frame](4)
@ -64,8 +62,7 @@ proc run*(chunk: Chunk): InterpretResult =
let index = readDU8()
chunk.constants[index]
#template frameBottom: int = frames.peek().stackBottom
template frameBottom: int = frames[frames.high].stackBottom
template frameBottom: int = frames.peek().stackBottom
while true:
{.computedgoto.} # See https://nim-lang.org/docs/manual.html#pragmas-computedgoto-pragma
@ -242,6 +239,7 @@ proc run*(chunk: Chunk): InterpretResult =
stack.free()
frames.free()
globals.free()
if hadError:
irRuntimeError