Minor changes to bytecode file

This commit is contained in:
Nocturn9x 2022-05-18 13:47:07 +02:00
parent 2f7a628d79
commit 5a821c055a
1 changed files with 7 additions and 6 deletions

View File

@ -28,9 +28,10 @@ export ast
type type
Chunk* = ref object Chunk* = ref object
## A piece of bytecode. ## A piece of bytecode.
## consts represents the constants table the code is referring to. ## consts represents the high-level constants table the code is
## byteConsts represents the actual encoding of the constants table ## referring to and is only meaningful at compile time (not stored
## used when serializing to/from a bytecode stream. ## in bytecode dumps!).
## byteConsts is used when serializing to/from a bytecode stream.
## code is the linear sequence of compiled bytecode instructions. ## code is the linear sequence of compiled bytecode instructions.
## lines maps bytecode instructions to line numbers using Run ## lines maps bytecode instructions to line numbers using Run
## Length Encoding. Instructions are encoded in groups whose structure ## Length Encoding. Instructions are encoded in groups whose structure
@ -87,7 +88,7 @@ type
## Basic stack operations ## Basic stack operations
Pop, # Pops an element off the stack and discards it Pop, # Pops an element off the stack and discards it
Push, # Pushes x onto the stack Push, # Pushes x onto the stack
PopN, # Pops x elements off the stack (optimization for exiting scopes and returning from functions) PopN, # Pops x elements off the stack (optimization for exiting local scopes which usually pop many elements)
## Name resolution/handling ## Name resolution/handling
LoadAttribute, # Pushes the attribute b of object a onto the stack LoadAttribute, # Pushes the attribute b of object a onto the stack
LoadVar, # Pushes the object at position x in the stack onto the stack LoadVar, # Pushes the object at position x in the stack onto the stack
@ -127,9 +128,9 @@ type
NoOp, # Just a no-op NoOp, # Just a no-op
# We group instructions by their operation/operand types for easier handling when debugging # We group instructions by their operation/operand types for easier handling when debugging
# Simple instructions encompass instructions that push onto/pop off the stack unconditionally (True, False, Pop, etc.) # Simple instructions encompass instructions that push onto/pop off the stack unconditionally (True, False, Pop, etc.)
const simpleInstructions* = {OpCode.Return, LoadNil, const simpleInstructions* = {OpCode.Return, LoadNil,
LoadTrue, LoadFalse, LoadTrue, LoadFalse,
LoadNan, LoadInf, LoadNan, LoadInf,