1#ifndef REDUCT_FUNCTION_H
2#define REDUCT_FUNCTION_H 1
43typedef enum reduct_function_flags
64typedef struct reduct_function
114 assert(reduct != NULL);
115 assert(func != NULL);
133 uint16_t captureCount);
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 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 reduct_function_t * reduct_function_new(struct reduct *reduct)
Create a new function.
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.
REDUCT_API void reduct_function_grow(struct reduct *reduct, reduct_function_t *func)
Grow the instruction buffer.
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 void reduct_function_init(reduct_function_t *func)
Initialize a function structure.
@ REDUCT_FUNCTION_FLAG_OPTIMIZED
Function has been optimized.
@ REDUCT_FUNCTION_FLAG_VARIADIC
Function accepts variadic arguments.
@ REDUCT_FUNCTION_FLAG_NONE
uint16_t reduct_const_t
Constant index type.
uint32_t reduct_inst_t
Instruction type.
uint16_t reduct_module_id_t
Identifies a reduct_module_t within a Reduct structure.
Bytecode instruction format.
Source position of a parallel instruction.
uint32_t modulePos
The index within the modules buffer that created the parallel instruction.
reduct_module_id_t moduleId
The ID of the module that the parallel instruction is associated with.
Compiled function structure.
reduct_inst_t * insts
An array of instructions.
uint16_t captureCount
Number of captured-variable slots.
reduct_function_inst_source_t * sources
An array specifying the source of instructions.
uint32_t instCount
Number of instructions.
uint16_t registerCount
The number of registers the function uses.
uint8_t arity
The number of arguments the function expects.
uint16_t constantCapacity
Capacity of the constants array.
uint16_t constantCount
Number of static constants.
reduct_handle_t * constants
Static constant values. Slot i is captureCount + i.
uint32_t instCapacity
Capacity of the instruction array.
reduct_function_flags_t flags
The function flags.