From d16d4d5977e8ef596bb20b96bc22a1731917b7d7 Mon Sep 17 00:00:00 2001 From: Mattia Giambirtone Date: Mon, 23 Jan 2023 01:12:09 +0100 Subject: [PATCH] Minor changes and fixes --- src/config.nim | 2 +- src/frontend/compiler/targets/bytecode/target.nim | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/config.nim b/src/config.nim index b916e90..b8c0958 100644 --- a/src/config.nim +++ b/src/config.nim @@ -29,7 +29,7 @@ const HeapGrowFactor* = 2 # The growth factor used by the G const FirstGC* = 1024 * 1024; # How many bytes to allocate before running the first GC const enableVMChecks* {.booldefine.} = true; # Enables all types of compiler (nim-wise) checks in the VM # List of paths where peon looks for modules, in order (empty path means current directory, which always takes precedence) -const moduleLookupPaths*: seq[string] = @["", "src/peon/stdlib"] +const moduleLookupPaths*: seq[string] = @["", "src/peon/stdlib", "/home/nocturn9x/.local/peon/stdlib"] when HeapGrowFactor <= 1: {.fatal: "Heap growth factor must be > 1".} const PeonVersion* = (major: 0, minor: 1, patch: 0) diff --git a/src/frontend/compiler/targets/bytecode/target.nim b/src/frontend/compiler/targets/bytecode/target.nim index b0c7eef..1c373b7 100644 --- a/src/frontend/compiler/targets/bytecode/target.nim +++ b/src/frontend/compiler/targets/bytecode/target.nim @@ -136,7 +136,7 @@ proc newBytecodeCompiler*(replMode: bool = false): BytecodeCompiler = result.functions = @[] result.stackIndex = 1 -## Low-level code generation +## Low-level code generation helpers proc emitByte(self: BytecodeCompiler, byt: OpCode | uint8, line: int) {.inline.} = ## Emits a single byte, writing it to @@ -303,7 +303,6 @@ proc emitJump(self: BytecodeCompiler, opcode: OpCode, line: int): int = result = self.jumps.high() - proc fixFunctionOffsets(self: BytecodeCompiler, where, oldLen: int) = ## Fixes function offsets after the size of our ## bytecode has changed @@ -895,8 +894,6 @@ proc prepareAutoFunction(self: BytecodeCompiler, fn: Name, args: seq[tuple[name: # First we declare the function's generics, if it has any. # This is because the function's return type may in itself # be a generic, so it needs to exist first - # We now declare and typecheck the function's - # arguments let idx = self.stackIndex self.stackIndex = 1 var default: Expression @@ -905,6 +902,8 @@ proc prepareAutoFunction(self: BytecodeCompiler, fn: Name, args: seq[tuple[name: fn.valueType.isAuto = false fn.valueType.compiled = false self.names.add(fn) + # We now declare and typecheck the function's + # arguments for (argument, val) in zip(node.arguments, args): if self.names.high() > 16777215: self.error("cannot declare more than 16777215 variables at a time")