Fixed debugger bugs

Made exponentiation larger precedence than unary
This commit is contained in:
Productive2 2021-01-05 13:15:43 +01:00
parent 9e4329981c
commit 8fe70d2f95
3 changed files with 7 additions and 6 deletions

View File

@ -71,8 +71,8 @@ type
Comparison,
Term,
Factor,
Exponentiation,
Unary,
Exponentiation,
Call,
Primary

View File

@ -79,10 +79,11 @@ const simpleInstructions* = {OpCode.Return, OpCode.Add, OpCode.Multiply,
OpCode.Inf, OpCode.Shl, OpCode.Shr,
OpCode.Xor, OpCode.Not, OpCode.Equal,
OpCode.Greater, OpCode.Less, OpCode.GetItem,
OpCode.Slice, OpCode.Pop, OpCode.DefineGlobal,
OpCode.GetGlobal, OpCode.SetGlobal,
OpCode.DeleteGlobal}
const constantInstructions* = {OpCode.Constant}
OpCode.Slice, OpCode.Pop, OpCode.Negate}
const constantInstructions* = {OpCode.Constant, OpCode.DefineGlobal,
OpCode.GetGlobal, OpCode.SetGlobal,
OpCode.DeleteGlobal}
const constantLongInstructions* = {OpCode.ConstantLong}
const byteInstructions* = {OpCode.SetLocal, OpCode.GetLocal, OpCode.DeleteLocal,
OpCode.Call}

View File

@ -30,7 +30,7 @@ proc simpleInstruction(name: string, index: int): int =
proc byteInstruction(name: string, chunk: Chunk, offset: int): int =
var slot = chunk.code[offset + 1]
echo &"\tInstruction at IP: {name}, points to slot {slot}\n"
return offset + 1
return offset + 2
proc constantLongInstruction(name: string, chunk: Chunk, offset: int): int =