1#ifndef REDUCT_FUNCTION_H
2#define REDUCT_FUNCTION_H 1
46typedef struct reduct_const_slot
56typedef enum reduct_function_flags
67typedef struct reduct_function
115 assert(reduct != NULL);
116 assert(func != NULL);
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 reduct_const_t reduct_function_add_capture(struct reduct *reduct, reduct_function_t *func)
Add a capture placeholder slot 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.
static void reduct_function_emit(struct reduct *reduct, reduct_function_t *func, reduct_inst_t inst, uint32_t position)
Emit an instruction to the function.
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_init(reduct_function_t *func)
Initialize a function structure.
reduct_const_slot_type_t
Constant slot type.
@ REDUCT_FUNCTION_FLAG_OPTIMIZED
Function has been optimized.
@ REDUCT_FUNCTION_FLAG_VARIADIC
Function accepts variadic arguments.
@ REDUCT_FUNCTION_FLAG_NONE
@ REDUCT_CONST_SLOT_TYPE_STATIC
A constant slot containing a static value.
@ REDUCT_CONST_SLOT_TYPE_NONE
No constant slot.
@ REDUCT_CONST_SLOT_TYPE_CAPTURE
A constant slot acting as a placeholder for a capture.
uint16_t reduct_const_t
Constant index type.
uint32_t reduct_inst_t
Instruction type.
Bytecode instruction format.
reduct_handle_t handle
The static handle, or NIL for captures.
reduct_const_slot_type_t type
The type of the constant slot.
Compiled function structure.
reduct_inst_t * insts
An array of instructions.
reduct_const_slot_t * constants
The array of constant slots forming the constant template.
uint32_t * positions
An array of source positions parallel to the 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 constant array.
uint16_t constantCount
Number of constants.
uint32_t instCapacity
Capacity of the instruction array.
reduct_function_flags_t flags
The function flags.