Fixed local variables
This commit is contained in:
parent
6b314f2882
commit
e9cb3fca89
|
@ -404,7 +404,7 @@ proc dispatch*(self: PeonVM) =
|
||||||
of StoreVar:
|
of StoreVar:
|
||||||
# Stores the value at the top of the operand stack
|
# Stores the value at the top of the operand stack
|
||||||
# into the given call stack index
|
# into the given call stack index
|
||||||
let idx = int(self.readLong())
|
let idx = int(self.readLong()) + self.frames[^1]
|
||||||
if idx <= self.calls.high():
|
if idx <= self.calls.high():
|
||||||
self.setc(idx, self.pop())
|
self.setc(idx, self.pop())
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -27,7 +27,7 @@ when len(PEON_COMMIT_HASH) != 40:
|
||||||
const PEON_BRANCH* = "master"
|
const PEON_BRANCH* = "master"
|
||||||
when len(PEON_BRANCH) > 255:
|
when len(PEON_BRANCH) > 255:
|
||||||
{.fatal: "The git branch name's length must be less than or equal to 255 characters".}
|
{.fatal: "The git branch name's length must be less than or equal to 255 characters".}
|
||||||
const DEBUG_TRACE_VM* = false # Traces VM execution
|
const DEBUG_TRACE_VM* = true # Traces VM execution
|
||||||
const DEBUG_TRACE_GC* = false # Traces the garbage collector (TODO)
|
const DEBUG_TRACE_GC* = false # Traces the garbage collector (TODO)
|
||||||
const DEBUG_TRACE_ALLOCATION* = false # Traces memory allocation/deallocation
|
const DEBUG_TRACE_ALLOCATION* = false # Traces memory allocation/deallocation
|
||||||
const DEBUG_TRACE_COMPILER* = false # Traces the compiler
|
const DEBUG_TRACE_COMPILER* = false # Traces the compiler
|
||||||
|
|
|
@ -1473,9 +1473,9 @@ proc funDecl(self: Compiler, node: FunDecl) =
|
||||||
self.error("non-empty return statement is not allowed in void functions")
|
self.error("non-empty return statement is not allowed in void functions")
|
||||||
elif not hasVal and self.currentFunction.returnType != nil:
|
elif not hasVal and self.currentFunction.returnType != nil:
|
||||||
self.error("function has an explicit return type, but no return statement was found")
|
self.error("function has an explicit return type, but no return statement was found")
|
||||||
# self.endFunctionBeforeReturn()
|
self.endFunctionBeforeReturn()
|
||||||
hasVal = hasVal and typ.returnType != nil
|
hasVal = hasVal and typ.returnType != nil
|
||||||
self.endScope(deleteNames=true, fromFunc=false)
|
self.endScope(deleteNames=true, fromFunc=true)
|
||||||
self.emitByte(OpCode.Return)
|
self.emitByte(OpCode.Return)
|
||||||
if hasVal:
|
if hasVal:
|
||||||
self.emitByte(1)
|
self.emitByte(1)
|
||||||
|
|
Loading…
Reference in New Issue