From 9c878e5b9e72fd82566b25039a676e41cb9a1b96 Mon Sep 17 00:00:00 2001 From: Mattia Giambirtone Date: Thu, 6 Oct 2022 00:21:25 +0200 Subject: [PATCH] Fix some stuff? --- src/backend/vm.nim | 7 ++----- src/frontend/compiler.nim | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/backend/vm.nim b/src/backend/vm.nim index 7d8c071..70a8b31 100644 --- a/src/backend/vm.nim +++ b/src/backend/vm.nim @@ -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.} diff --git a/src/frontend/compiler.nim b/src/frontend/compiler.nim index 6d8f39b..da9e3b0 100644 --- a/src/frontend/compiler.nim +++ b/src/frontend/compiler.nim @@ -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