Minor changes and fixes
This commit is contained in:
parent
63a3f5b228
commit
d16d4d5977
|
@ -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 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
|
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)
|
# 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:
|
when HeapGrowFactor <= 1:
|
||||||
{.fatal: "Heap growth factor must be > 1".}
|
{.fatal: "Heap growth factor must be > 1".}
|
||||||
const PeonVersion* = (major: 0, minor: 1, patch: 0)
|
const PeonVersion* = (major: 0, minor: 1, patch: 0)
|
||||||
|
|
|
@ -136,7 +136,7 @@ proc newBytecodeCompiler*(replMode: bool = false): BytecodeCompiler =
|
||||||
result.functions = @[]
|
result.functions = @[]
|
||||||
result.stackIndex = 1
|
result.stackIndex = 1
|
||||||
|
|
||||||
## Low-level code generation
|
## Low-level code generation helpers
|
||||||
|
|
||||||
proc emitByte(self: BytecodeCompiler, byt: OpCode | uint8, line: int) {.inline.} =
|
proc emitByte(self: BytecodeCompiler, byt: OpCode | uint8, line: int) {.inline.} =
|
||||||
## Emits a single byte, writing it to
|
## Emits a single byte, writing it to
|
||||||
|
@ -303,7 +303,6 @@ proc emitJump(self: BytecodeCompiler, opcode: OpCode, line: int): int =
|
||||||
result = self.jumps.high()
|
result = self.jumps.high()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
proc fixFunctionOffsets(self: BytecodeCompiler, where, oldLen: int) =
|
proc fixFunctionOffsets(self: BytecodeCompiler, where, oldLen: int) =
|
||||||
## Fixes function offsets after the size of our
|
## Fixes function offsets after the size of our
|
||||||
## bytecode has changed
|
## 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.
|
# First we declare the function's generics, if it has any.
|
||||||
# This is because the function's return type may in itself
|
# This is because the function's return type may in itself
|
||||||
# be a generic, so it needs to exist first
|
# be a generic, so it needs to exist first
|
||||||
# We now declare and typecheck the function's
|
|
||||||
# arguments
|
|
||||||
let idx = self.stackIndex
|
let idx = self.stackIndex
|
||||||
self.stackIndex = 1
|
self.stackIndex = 1
|
||||||
var default: Expression
|
var default: Expression
|
||||||
|
@ -905,6 +902,8 @@ proc prepareAutoFunction(self: BytecodeCompiler, fn: Name, args: seq[tuple[name:
|
||||||
fn.valueType.isAuto = false
|
fn.valueType.isAuto = false
|
||||||
fn.valueType.compiled = false
|
fn.valueType.compiled = false
|
||||||
self.names.add(fn)
|
self.names.add(fn)
|
||||||
|
# We now declare and typecheck the function's
|
||||||
|
# arguments
|
||||||
for (argument, val) in zip(node.arguments, args):
|
for (argument, val) in zip(node.arguments, args):
|
||||||
if self.names.high() > 16777215:
|
if self.names.high() > 16777215:
|
||||||
self.error("cannot declare more than 16777215 variables at a time")
|
self.error("cannot declare more than 16777215 variables at a time")
|
||||||
|
|
Loading…
Reference in New Issue