|
Reduct
v1.0.4-3-gdaf0d70
A functional and immutable language.
|
A reduct function is a sequence of instructions and an associated constant pool that can be executed by the Reduct virtual machine.
A function's constant pool is actually a template of constant slots. These slots can either contain ann item or a variable name that needs to be captured from the enclosing scope when a closure is created.
Data Structures | |
| struct | reduct_const_slot_t |
| Constant slot. More... | |
| struct | reduct_function_t |
| Compiled function structure. More... | |
Macros | |
| #define | REDUCT_CONST_SLOT_ITEM(_item) ((reduct_const_slot_t){.type = REDUCT_CONST_SLOT_ITEM, .item = (_item)}) |
| Create a constant slot containing an item. | |
| #define | REDUCT_CONST_SLOT_CAPTURE(_capture) ((reduct_const_slot_t){.type = REDUCT_CONST_SLOT_CAPTURE, .capture = (_capture)}) |
| Create a constant slot containing a variable name to be captured. | |
Typedefs | |
| typedef reduct_uint16_t | reduct_const_t |
| Constant index type. | |
Enumerations | |
| enum | reduct_const_slot_type_t { REDUCT_CONST_SLOT_NONE , REDUCT_CONST_SLOT_ITEM , REDUCT_CONST_SLOT_CAPTURE } |
| Constant slot type. More... | |
Functions | |
| REDUCT_API void | reduct_function_init (reduct_function_t *func) |
| Initialize a function structure. | |
| REDUCT_API void | reduct_function_deinit (reduct_function_t *func) |
| Deinitialize a function structure. | |
| REDUCT_API reduct_function_t * | reduct_function_new (struct reduct *reduct) |
| Create a new function. | |
| REDUCT_API void | reduct_function_grow (struct reduct *reduct, reduct_function_t *func) |
| Grow the instruction buffer. | |
| static void | reduct_function_emit (struct reduct *reduct, reduct_function_t *func, reduct_inst_t inst, reduct_uint32_t position) |
| Emit an instruction to the function. | |
| REDUCT_API reduct_const_t | reduct_function_lookup_constant (struct reduct *reduct, reduct_function_t *func, reduct_const_slot_t *slot) |
| Get the index of a constant in a function's constant template, adding it if it doesn't exist. | |
| #define REDUCT_CONST_SLOT_ITEM | ( | _item | ) | ((reduct_const_slot_t){.type = REDUCT_CONST_SLOT_ITEM, .item = (_item)}) |
Create a constant slot containing an item.
| _item | The item to wrap in a slot. |
Definition at line 57 of file function.h.
| #define REDUCT_CONST_SLOT_CAPTURE | ( | _capture | ) | ((reduct_const_slot_t){.type = REDUCT_CONST_SLOT_CAPTURE, .capture = (_capture)}) |
Create a constant slot containing a variable name to be captured.
| _capture | The name of the variable to be captured. |
Definition at line 64 of file function.h.
Constant index type.
Definition at line 71 of file function.h.
Constant slot type.
| Enumerator | |
|---|---|
| REDUCT_CONST_SLOT_NONE | No constant slot. |
| REDUCT_CONST_SLOT_ITEM | A constant slot containing an item. |
| REDUCT_CONST_SLOT_CAPTURE | A constant slot containing a variable name to be captured. |
Definition at line 31 of file function.h.
| REDUCT_API void reduct_function_init | ( | reduct_function_t * | func | ) |
Initialize a function structure.
| func | The function to initialize. |
Definition at line 10 of file function_impl.h.
| REDUCT_API void reduct_function_deinit | ( | reduct_function_t * | func | ) |
Deinitialize a function structure.
| func | The function to deinitialize. |
Definition at line 25 of file function_impl.h.
| REDUCT_API reduct_function_t * reduct_function_new | ( | struct reduct * | reduct | ) |
Create a new function.
| reduct | The Reduct structure. |
| REDUCT_API void reduct_function_grow | ( | struct reduct * | reduct, |
| reduct_function_t * | func | ||
| ) |
Grow the instruction buffer.
| reduct | The Reduct structure. |
| func | The function to grow. |
|
inlinestatic |
Emit an instruction to the function.
| reduct | The Reduct structure. |
| func | The function to emit to. |
| inst | The instruction to emit. |
| position | The position in the source code. |
Definition at line 128 of file function.h.
| REDUCT_API reduct_const_t reduct_function_lookup_constant | ( | struct reduct * | reduct, |
| reduct_function_t * | func, | ||
| reduct_const_slot_t * | slot | ||
| ) |
Get the index of a constant in a function's constant template, adding it if it doesn't exist.
| reduct | The Reduct structure. |
| func | The function. |
| slot | The constant slot to add or lookup. |