Fix some stuff?

This commit is contained in:
Mattia Giambirtone 2022-10-06 00:21:25 +02:00
parent c230142378
commit 9c878e5b9e
2 changed files with 4 additions and 7 deletions

View File

@ -31,7 +31,7 @@ when debugVM or debugMem or debugGC:
import std/terminal
{.push checks:on.} # The VM is a critical point where checks are deleterious
{.push checks:off.} # The VM is a critical point where checks are deleterious
type
PeonVM* = ref object
@ -1028,7 +1028,6 @@ proc run*(self: PeonVM, chunk: Chunk) =
self.operands = @[]
self.results = @[]
self.ip = 0
#[
# Sorry, but there only is enough space
# for one GC in this VM :(
when defined(gcOrc):
@ -1036,7 +1035,6 @@ proc run*(self: PeonVM, chunk: Chunk) =
when not defined(gcArc):
GC_disable()
GC_disableMarkAndSweep()
]#
try:
self.dispatch()
except NilAccessDefect:
@ -1044,7 +1042,6 @@ proc run*(self: PeonVM, chunk: Chunk) =
quit(1)
# We clean up after ourselves!
self.gc.collect()
#[
# This is unnecessary if we use ARC,
# but *just in case*
when defined(gcOrc):
@ -1052,6 +1049,6 @@ proc run*(self: PeonVM, chunk: Chunk) =
when not defined(gcArc):
GC_enable()
GC_enableMarkAndSweep()
]#
{.pop.}

View File

@ -1480,7 +1480,7 @@ proc assignment(self: Compiler, node: ASTNode) =
elif r.isLet:
self.error(&"cannot reassign '{name.token.lexeme}'", name)
self.expression(node.value)
if self.scopeDepth > 0 and r.depth != self.scopeDepth:
if not r.isClosedOver:
self.emitByte(StoreVar, node.token.line)
self.emitBytes(self.getStackPos(r).toTriple(), node.token.line)
else:
@ -1852,7 +1852,7 @@ proc funDecl(self: Compiler, node: FunDecl, fn: Name = nil, args: seq[Expression
if not self.currentFunction.isNil():
self.currentFunction.valueType.children.add(fn.valueType)
self.currentFunction = fn
var names = self.names[^(node.arguments.len())..^1]
var names {.used.} = self.names[^(node.arguments.len())..^1]
if fn.valueType.isBuiltinFunction:
fn.codePos = self.chunk.code.len()
# We take the arguments off of our name list