A chunk of byte code. It holds code and constants needed by the code. Constants are accessed by index.
More...
#include <vm.h>
|
| | Chunk ()=default |
| | ~Chunk ()=default |
| void | disassemble (const std::string &name) const |
| | Prints a human-readable view of the chunk.
|
| uint8_t | addConstant (const Value &value) |
| | Stores a constant and returns the index that can be used to refer to it.
|
| const Value & | getConstant (uint8_t offset) const |
| | The constant stored at a given slot.
|
| void | addCode (uint8_t byte) |
| | Appends a byte to the code. The line is just for debugging.
|
| Span< const std::string > | getVariables () const |
| | The variables used by this chunk.
|
| uint8_t | getOrRegisterVariable (const std::string &name) |
| | Registers a variable and obtains the index.
|
| bool | isValid () const noexcept |
| | Returns true if it contains code.
|
| const uint8_t * | code () const noexcept |
| | The stored code.
|
| int | count () const noexcept |
| | The size of the code.
|
| void | patch (std::size_t offset, uint8_t byte) |
| | Patches the a code byte at some offset.
|
| std::size_t | disassembleInstruction (std::size_t offset) const |
| | Prints a human-readable view of the instruction at a given offset.
|
A chunk of byte code. It holds code and constants needed by the code. Constants are accessed by index.
◆ Chunk()
| sen::lang::Chunk::Chunk |
( |
| ) |
|
|
default |
◆ ~Chunk()
| sen::lang::Chunk::~Chunk |
( |
| ) |
|
|
default |
◆ disassemble()
| void sen::lang::Chunk::disassemble |
( |
const std::string & | name | ) |
const |
Prints a human-readable view of the chunk.
◆ addConstant()
| uint8_t sen::lang::Chunk::addConstant |
( |
const Value & | value | ) |
|
|
nodiscard |
Stores a constant and returns the index that can be used to refer to it.
◆ getConstant()
| const Value & sen::lang::Chunk::getConstant |
( |
uint8_t | offset | ) |
const |
|
nodiscard |
The constant stored at a given slot.
◆ addCode()
| void sen::lang::Chunk::addCode |
( |
uint8_t | byte | ) |
|
Appends a byte to the code. The line is just for debugging.
◆ getVariables()
| Span< const std::string > sen::lang::Chunk::getVariables |
( |
| ) |
const |
|
nodiscard |
The variables used by this chunk.
◆ getOrRegisterVariable()
| uint8_t sen::lang::Chunk::getOrRegisterVariable |
( |
const std::string & | name | ) |
|
|
nodiscard |
Registers a variable and obtains the index.
◆ isValid()
| bool sen::lang::Chunk::isValid |
( |
| ) |
const |
|
nodiscardnoexcept |
Returns true if it contains code.
◆ code()
| const uint8_t * sen::lang::Chunk::code |
( |
| ) |
const |
|
nodiscardnoexcept |
◆ count()
| int sen::lang::Chunk::count |
( |
| ) |
const |
|
nodiscardnoexcept |
◆ patch()
| void sen::lang::Chunk::patch |
( |
std::size_t | offset, |
|
|
uint8_t | byte ) |
Patches the a code byte at some offset.
◆ disassembleInstruction()
| std::size_t sen::lang::Chunk::disassembleInstruction |
( |
std::size_t | offset | ) |
const |
|
nodiscard |
Prints a human-readable view of the instruction at a given offset.
◆ printValue()
| void sen::lang::Chunk::printValue |
( |
const Value & | value | ) |
|
|
static |
The documentation for this class was generated from the following file: