maug
Quick and dirty C mini-augmentation library.
Loading...
Searching...
No Matches
MLISP_EXEC_STATE Struct Reference

Current execution state to associate with a MLISP_PARSER. More...

#include <mlisps.h>

Collaboration diagram for MLISP_EXEC_STATE:

Data Fields

uint16_t uid
 
uint8_t flags
 Flags which dictate the behavior of this object.
 
struct MDATA_VECTOR per_node_visit_ct
 The number of times each node has been visited ever.
 
struct MDATA_VECTOR per_node_child_idx
 The hild index that will be visited on next visit of each node.
 
struct MDATA_VECTOR stack
 A stack of data values resulting from evaluating statements.
 
struct MDATA_TABLE env [MLISP_EXEC_ENV_FRAME_CT_MAX]
 Environment in which statements are defined if ::MLISP_.
 
int8_t env_select
 The current topmost frame of MLISP_EXEC_STATE::env. Please see that for more information.
 
int8_t no_serial
 Dummy field; do not serialize fields after this!
 
struct MDATA_VECTOR lambda_trace
 Path through any lambdas the execution has entered during this heartbeat cycle. Used to detect tail calls.
 
union MAUG_MHANDLEPTR cb_attachment
 Handle/pointer for use by addtional native callbacks. This is not used within mlisp or its builtin callbacks and can be manipulated freely by the embedding implementation.
 
struct MDATA_TABLEglobal_env
 

Related Symbols

(Note that these are not member symbols.)

#define MLISP_EXEC_FLAG_TRANSIENT_MASK   0x0f
 Mask for MLISP_EXEC_STATE::flags to block off flags that persist between steps.
 
#define MLISP_EXEC_FLAG_DEF_TERM   0x20
 Flag for MLISP_EXEC_STATE::flags indicating next token is a term to be defined.
 

Detailed Description

Current execution state to associate with a MLISP_PARSER.

Note
In general, this library uses nested locks because MLISP_STACK_NODE and MLISP_ENV_NODE do not have MDATA_VECTOR structs attached, so there's no danger of a MDATA_VECTOR being reallocated out from beneath another.

Field Documentation

◆ env

struct MDATA_TABLE MLISP_EXEC_STATE::env[MLISP_EXEC_ENV_FRAME_CT_MAX]

Environment in which statements are defined if ::MLISP_.

This is an array indexed by MLISP_EXEC_STATE::env_select, below. The members of this array are referred to as frames, elsewhere. Diving into a lambda during execution will increment MLISP_EXEC_STATE::env_select and initialize a new table here (unless it's the same lambda doing a tail call, which will free the current env frame first). Leaving that lambda will free the current env frame and decrement MLISP_EXEC_STATE::env_select.

mlisp_env_get() will search the highest-indexed (most recent) frame before searching lower frames. mlisp_env_set() will store in the highest-indexed (currently selected) frame.

◆ per_node_child_idx

struct MDATA_VECTOR MLISP_EXEC_STATE::per_node_child_idx

The hild index that will be visited on next visit of each node.

This is tracked per MLISP_AST_NODE, so each node has its own "program counter." This facilitates things like tail call optimization.


The documentation for this struct was generated from the following file: