A reduct function is a sequence of instructions and an associated constant pool that can be executed by the Reduct virtual machine.
Constants Template
A function's constant template is split into two contiguous regions and describe how a closures constant pool should be created.
The inital captureCount number of constant slots are for captured variables and are specified in the same order as the RVSDG lambda nodes inputs. These are not actually stored physically within the function but instead will be created as empty constants within created closures which are then filled using capture opcodes.
After the captured constants are a constantCount number of static constants which will be copied into the closure's constant pool.
|
| REDUCT_API void | reduct_function_init (reduct_function_t *func) |
| | Initialize 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, uint32_t modulePos, reduct_module_id_t moduleId) |
| | Emit an instruction to the function.
|
| |
| REDUCT_API void | reduct_function_set_capture_count (struct reduct *reduct, reduct_function_t *func, uint16_t captureCount) |
| | Set the number of captured variables for a function.
|
| |
| REDUCT_API reduct_const_t | reduct_function_add_constant (struct reduct *reduct, reduct_function_t *func, reduct_handle_t handle) |
| | Add a static constant to the function's template, returning its index.
|
| |
| REDUCT_API void | reduct_function_retain (struct reduct *reduct, reduct_function_t *function) |
| | Retain a function, preventing it from being collected by the garbage collector.
|
| |
| REDUCT_API void | reduct_function_release (struct reduct *reduct, reduct_function_t *function) |
| | Release a function, potentially allowing the garbage collector to collect it.
|
| |
◆ reduct_function_flags_t
Function flags.
| Enumerator |
|---|
| REDUCT_FUNCTION_FLAG_NONE | |
| REDUCT_FUNCTION_FLAG_VARIADIC | Function accepts variadic arguments.
|
| REDUCT_FUNCTION_FLAG_OPTIMIZED | Function has been optimized.
|
Definition at line 43 of file function.h.
◆ reduct_function_init()
Initialize a function structure.
- Parameters
-
| func | The function to initialize. |
◆ reduct_function_new()
Create a new function.
- Parameters
-
| reduct | Pointer to the Reduct structure. |
- Returns
- A pointer to the newly allocated function.
◆ reduct_function_grow()
Grow the instruction buffer.
- Parameters
-
| reduct | Pointer to the Reduct structure. |
| func | The function to grow. |
◆ reduct_function_emit()
Emit an instruction to the function.
- Parameters
-
| reduct | Pointer to the Reduct structure. |
| func | The function to emit to. |
| inst | The instruction to emit. |
| modulePos | The index within the modules buffer that created the parallel instruction. |
| moduleId | The ID of the module that the parallel instruction is associated with. |
Definition at line 111 of file function.h.
◆ reduct_function_set_capture_count()
Set the number of captured variables for a function.
- Parameters
-
| reduct | Pointer to the Reduct structure. |
| func | The function to modify. |
| captureCount | The new number of captured variables. |
◆ reduct_function_add_constant()
Add a static constant to the function's template, returning its index.
Will return the index of an existing identical constant if found.
- Parameters
-
| reduct | Pointer to the Reduct structure. |
| func | The function. |
| handle | The value to add. |
- Returns
- The index in the constant pool.
◆ reduct_function_retain()
Retain a function, preventing it from being collected by the garbage collector.
- Parameters
-
| reduct | Pointer to the Reduct structure. |
| function | Pointer to the function, can be NULL. |
◆ reduct_function_release()
Release a function, potentially allowing the garbage collector to collect it.
- Parameters
-
| reduct | Pointer to the Reduct structure. |
| function | Pointer to the function, can be NULL. |