KrkCodeObject Struct Reference
Code object. More...
#include <object.h>
Inheritance diagram for KrkCodeObject:

Public Member Functions | |
| void | krk_debug_addExpression (KrkCodeObject *codeobject, uint8_t start, uint8_t midStart, uint8_t midEnd, uint8_t end) |
| Add an expression mapping to the bytecode chunk. More... | |
| int | krk_debug_expressionUnderline (const KrkCodeObject *codeobject, uint8_t *start, uint8_t *midStart, uint8_t *endStart, uint8_t *end, size_t instruction) |
| Extract expression mapping from chunk. More... | |
| KrkCodeObject * | krk_newCodeObject (void) |
| Create a new, uninitialized code object. More... | |
Data Fields | |
| unsigned short | requiredArgs |
| Arity of required (non-default) arguments. | |
| unsigned short | keywordArgs |
| Arity of keyword (default) arguments. | |
| unsigned short | potentialPositionals |
| Precalculated positional arguments for complex argument processing. | |
| unsigned short | totalArguments |
| Total argument cells we can fill in complex argument processing. | |
| size_t | upvalueCount |
| Number of upvalues this function collects as a closure. | |
| KrkChunk | chunk |
| Bytecode data. | |
| KrkString * | name |
| Name of the function. | |
| KrkString * | docstring |
| Docstring attached to the function. | |
| KrkValueArray | positionalArgNames |
| Array of names for positional arguments (and *args) | |
| KrkValueArray | keywordArgNames |
| Array of names for keyword-only arguments (and **kwargs) | |
| size_t | localNameCapacity |
| Capacity of localNames. | |
| size_t | localNameCount |
| Number of entries in localNames. | |
| KrkLocalEntry * | localNames |
| Stores the names of local variables used in the function, for debugging. | |
| KrkString * | qualname |
| The dotted name of the function. | |
| size_t | expressionsCapacity |
| Capacity of expressions. | |
| size_t | expressionsCount |
| Number of entries in expressions. | |
| KrkExpressionsMap * | expressions |
| Mapping of bytecode offsets to expression spans for debugging. | |
| KrkValue | jumpTargets |
| Possibly a set of jump targets... | |
| KrkOverlongJump * | overlongJumps |
| Pessimal overlong jump container. | |
| size_t | overlongJumpsCapacity |
| Number of possible entries in pessimal jump table. | |
| size_t | overlongJumpsCount |
| Number of entries in pessimal jump table. | |
Data Fields inherited from KrkObj | |
| uint16_t | type |
| Tag indicating core type. | |
| uint16_t | flags |
| General object flags, mostly related to garbage collection. | |
| uint32_t | hash |
| Cached hash value for table keys. | |
| struct KrkObj * | next |
| Invasive linked list of all objects in the VM. | |
Protected Attributes | |
| KrkObj | obj |
| Base. | |
Detailed Description
Code object.
Contains the static data associated with a chunk of bytecode.
Member Function Documentation
◆ krk_debug_addExpression()
| void krk_debug_addExpression | ( | KrkCodeObject * | codeobject, |
| uint8_t | start, | ||
| uint8_t | midStart, | ||
| uint8_t | midEnd, | ||
| uint8_t | end | ||
| ) |
Add an expression mapping to the bytecode chunk.
Associates a span of columns representing an expression with the current opcode offset. Used to supply debug information displayed in tracebacks with tildes and carets.
- Parameters
-
codeobject Codeobject containing the instruction. start First column, 1-indexed, of tildes, left side of expression. midStart First column, 1-indexed, of carets, main token of expression. midEnd Last column, 1-indexed, of carets, main token of expression. end Last column, 1-indexed, of tildes, right side of expression.
◆ krk_debug_expressionUnderline()
| int krk_debug_expressionUnderline | ( | const KrkCodeObject * | codeobject, |
| uint8_t * | start, | ||
| uint8_t * | midStart, | ||
| uint8_t * | endStart, | ||
| uint8_t * | end, | ||
| size_t | instruction | ||
| ) |
Extract expression mapping from chunk.
Searches the debug information for the requested instruction to find an expression mapping and extracts the column values for underlining.
- Parameters
-
codeobject Codeobject containing the instruction. start First column, 1-indexed, of tildes, left side of expression. midStart First column, 1-indexed, of carets, main token of expression. midEnd Last column, 1-indexed, of carets, main token of expression. end Last column, 1-indexed, of tildes, right side of expression. instruction Offset of the last byte of an opcode, as is stored in a traceback entry.
- Returns
- Non-zero if a mapping was found.
◆ krk_newCodeObject()
| KrkCodeObject * krk_newCodeObject | ( | void | ) |
The documentation for this struct was generated from the following files:
Data Fields inherited from