Updates to bytecode doc

This commit is contained in:
Mattia Giambirtone 2023-01-22 20:58:25 +01:00
parent 3ced4c358f
commit 63a3f5b228
1 changed files with 7 additions and 8 deletions

View File

@ -36,7 +36,7 @@ in release builds.
The line data segment contains information about each instruction in the code segment and associates them
1:1 with a line number in the original source file for easier debugging using run-length encoding. The section's
size is fixed and is encoded at the beginning as a sequence of 4 bytes (i.e. a single 32 bit integer). The data
in this segment can be decoded as explained in [this file](../src/frontend/meta/bytecode.nim#L28), which is quoted
in this segment can be decoded as explained in [this file](../src/frontend/compiler/targgets/bytecode/opcodes.nim#L29), which is quoted
below:
```
[...]
@ -55,18 +55,17 @@ below:
### Functions segment
This segment , contains details about each function in
the original file. The segment's size is fixed and is encoded at the beginning as a sequence of 4 bytes (i.e. a single 32 bit integer).
The data in this segment can be decoded as explained in [this file](../src/frontend/meta/bytecode.nim#L41), which is quoted
below:
This segment contains details about each function in the original file. The segment's size is fixed and is encoded at the
beginning as a sequence of 4 bytes (i.e. a single 32 bit integer). The data in this segment can be decoded as explained
in [this file](../src/frontend/compiler/targgets/bytecode/opcodes.nim#L39), which is quoted below:
```
[...]
## [...] encodes the following information:
## functions encodes the following information:
## - Function name
## - Argument count
## - Function boundaries
## The encoding for is the following:
## The encoding for functions is the following:
## - First, the position into the bytecode where the function begins is encoded (as a 3 byte integer)
## - Second, the position into the bytecode where the function ends is encoded (as a 3 byte integer)
## - After that follows the argument count as a 1 byte integer
@ -90,4 +89,4 @@ real-world scenarios it likely won't be.
The code segment contains the linear sequence of bytecode instructions of a peon program. It is to be read directly
and without modifications. The segment's size is fixed and is encoded at the beginning as a sequence of 3 bytes
(i.e. a single 24 bit integer).
(i.e. a single 24 bit integer). All the instructions are documented [here](../src/frontend/compiler/targgets/bytecode/opcodes.nim)