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
Chunk* = ref object
## A piece of bytecode.
## consts represents the constants table the code is referring to.
## byteConsts represents the actual encoding of the constants table
## used when serializing to/from a bytecode stream.
## consts represents the high-level constants table the code is
## referring to and is only meaningful at compile time (not stored
## in bytecode dumps!).
## byteConsts is used when serializing to/from a bytecode stream.
## code is the linear sequence of compiled bytecode instructions.
## lines maps bytecode instructions to line numbers using Run
## Length Encoding. Instructions are encoded in groups whose structure
@ -87,7 +88,7 @@ type
## Basic stack operations
Pop, # Pops an element off the stack and discards it
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
LoadAttribute, # Pushes the attribute b of object a 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
# 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,
LoadTrue, LoadFalse,
LoadNan, LoadInf,