cleanup old code in vm, free globals
This commit is contained in:
parent
19b8079436
commit
a13659e44f
6
vm.nim
6
vm.nim
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue