1#ifndef REDUCT_INTRINSIC_IMPL_H
2#define REDUCT_INTRINSIC_IMPL_H 1
34 REDUCT_ERROR_COMPILE(compiler, list,
"%s expects between %zu and %zu argument(s), got %zu", name,
96 if (startIdx >= list->
length)
110 if (_iter.index == list->
length)
202 "undefined variable '%s'", captureName->
string);
356 REDUCT_ERROR_COMPILE(compiler, pair,
"%s clauses must be lists of exactly two items, got %s (length %u)", name,
372 *result = (cmp == 0);
375 *result = (cmp != 0);
387 *result = (cmp <= 0);
393 *result = (cmp >= 0);
419 else if (list->
length == 4)
662 if (shortCircuits || _iter.index == list->
length)
690 if (_iter.index != list->
length)
909 leftExpr = foldedExpr;
1085 leftExpr = rightExpr;
1125 if (_iter.index != list->
length)
1129 REDUCT_ERROR_COMPILE(compiler, list,
"comparison expects at most 256 arguments, got %u", jumpCount);
1134 leftExpr = rightExpr;
1280#define REDUCT_INTRINSIC_NATIVE_ARITH(_name, _op, _identity) \
1281 static reduct_handle_t reduct_intrinsic_native_##_name(reduct_t* reduct, reduct_size_t argc, \
1282 reduct_handle_t* argv) \
1286 return REDUCT_HANDLE_FROM_INT(_identity); \
1290 reduct_handle_t res; \
1291 reduct_handle_t id = REDUCT_HANDLE_FROM_INT(_identity); \
1292 REDUCT_HANDLE_ARITHMETIC_FAST(reduct, &res, &id, &argv[0], _op); \
1295 reduct_handle_t res = argv[0]; \
1296 for (reduct_size_t i = 1; i < argc; i++) \
1298 REDUCT_HANDLE_ARITHMETIC_FAST(reduct, &res, &res, &argv[i], _op); \
1303#define REDUCT_INTRINSIC_NATIVE_LOGIC(_name, _short_circuit_truth) \
1304 static reduct_handle_t reduct_intrinsic_native_##_name(reduct_t* reduct, reduct_size_t argc, \
1305 reduct_handle_t* argv) \
1307 REDUCT_UNUSED(reduct); \
1310 return REDUCT_HANDLE_FALSE(); \
1312 reduct_handle_t res = argv[0]; \
1313 for (reduct_size_t i = 0; i < argc; i++) \
1316 if (REDUCT_HANDLE_IS_TRUTHY(&res) == (_short_circuit_truth)) \
1324#define REDUCT_INTRINSIC_NATIVE_BITWISE(_name, _op) \
1325 static reduct_handle_t reduct_intrinsic_native_##_name(reduct_t* reduct, reduct_size_t argc, \
1326 reduct_handle_t* argv) \
1328 reduct_error_check_min_arity(reduct, argc, 2, #_op); \
1329 reduct_int64_t res = reduct_get_int(reduct, &argv[0]); \
1330 for (reduct_size_t i = 1; i < argc; i++) \
1332 res _op## = reduct_get_int(reduct, &argv[i]); \
1334 return REDUCT_HANDLE_FROM_INT(res); \
1337#define REDUCT_INTRINSIC_NATIVE_COMPARE(_name, _op) \
1338 static reduct_handle_t reduct_intrinsic_native_##_name(reduct_t* reduct, reduct_size_t argc, \
1339 reduct_handle_t* argv) \
1343 return REDUCT_HANDLE_TRUE(); \
1345 for (reduct_size_t i = 0; i < argc - 1; i++) \
1347 if (!(reduct_handle_compare(reduct, &argv[i], &argv[i + 1]) _op 0)) \
1349 return REDUCT_HANDLE_FALSE(); \
1352 return REDUCT_HANDLE_TRUE(); \
1355#define REDUCT_INTRINSIC_NATIVE_COMPARE_STRICT(_name, _expected) \
1356 static reduct_handle_t reduct_intrinsic_native_##_name(reduct_t* reduct, reduct_size_t argc, \
1357 reduct_handle_t* argv) \
1361 return REDUCT_HANDLE_TRUE(); \
1363 for (reduct_size_t i = 0; i < argc - 1; i++) \
1365 if (reduct_handle_is_equal(reduct, &argv[i], &argv[i + 1]) != (_expected)) \
1367 return REDUCT_HANDLE_FALSE(); \
1370 return REDUCT_HANDLE_TRUE(); \
1450 if (right < 0 || right >= 64)
1462 if (right < 0 || right >= 64)
1475 return argv[argc - 1];
#define REDUCT_UNLIKELY(_x)
reduct_bool_t
Boolean type.
#define REDUCT_CONTAINER_OF(_ptr, _type, _member)
Container of macro.
reduct_uint64_t reduct_handle_t
Handle type.
#define REDUCT_ASSERT(_cond)
REDUCT_API reduct_atom_t * reduct_atom_lookup(struct reduct *reduct, const char *str, reduct_size_t len, reduct_atom_lookup_flags_t flags)
Lookup an atom in the Reduct structure.
REDUCT_API reduct_atom_t * reduct_atom_lookup_int(struct reduct *reduct, reduct_int64_t value)
Lookup an atom by integer value.
REDUCT_API reduct_atom_t * reduct_atom_lookup_float(struct reduct *reduct, reduct_float_t value)
Lookup an atom by float value.
@ REDUCT_ATOM_LOOKUP_NONE
No flags.
static void reduct_compile_jump_patch(reduct_compiler_t *compiler, reduct_size_t pos)
Patch a previously emitted jump instruction to point to the current instruction.
reduct_const_t constant
Constant index.
#define REDUCT_EXPR_CONST_ITEM(_compiler, _item)
Create a REDUCT_MODE_CONST mode expression for a specific item.
#define REDUCT_EXPR_GET_TARGET(_expr)
Get the target register index from an expression, or -1 if no target is specified.
REDUCT_API reduct_local_t * reduct_local_add_arg(reduct_compiler_t *compiler, reduct_atom_t *name)
Add a function argument local to the compiler context.
REDUCT_API void reduct_reg_free(reduct_compiler_t *compiler, reduct_reg_t reg)
Free a register.
reduct_mode_t mode
Expression mode.
static void reduct_compile_capture(reduct_compiler_t *compiler, reduct_reg_t closureReg, reduct_uint32_t slot, reduct_expr_t *expr)
Emits a REDUCT_OPCODE_CAPTURE instruction.
#define REDUCT_EXPR_NIL(_compiler)
Create a REDUCT_MODE_CONST mode expression for the nil constant.
static void reduct_expr_done(reduct_compiler_t *compiler, reduct_expr_t *expr)
Free resources associated with an expression descriptor.
REDUCT_API void reduct_expr_build(reduct_compiler_t *compiler, reduct_item_t *item, reduct_expr_t *out)
Compiles a single Reduct item into an expression descriptor.
reduct_uint16_t localCount
The amount of local variables.
REDUCT_API reduct_local_t * reduct_local_def(reduct_compiler_t *compiler, reduct_atom_t *name)
Define a new local variable.
static void reduct_compile_jump_patch_list(reduct_compiler_t *compiler, reduct_size_t *jumps, reduct_size_t count)
Patch a list of jump instructions to point to the current instruction.
static void reduct_compile_binary(reduct_compiler_t *compiler, reduct_opcode_t opBase, reduct_reg_t target, reduct_reg_t left, reduct_expr_t *right)
Emits a comparison, arithmetic or bitwise instruction.
REDUCT_API void reduct_local_def_done(reduct_compiler_t *compiler, reduct_local_t *local, reduct_expr_t *expr)
Finalize a local variable definition with its value expression.
#define REDUCT_EXPR_TRUE(_compiler)
Create a REDUCT_MODE_CONST mode expression for the true constant.
static void reduct_compile_inst(reduct_compiler_t *compiler, reduct_inst_t inst)
Emits an instruction to the current function.
static void reduct_compile_return(reduct_compiler_t *compiler, reduct_expr_t *expr)
Emits a REDUCT_OPCODE_RET instruction.
REDUCT_API void reduct_reg_free_range(reduct_compiler_t *compiler, reduct_reg_t start, reduct_uint32_t count)
Free a range of registers.
reduct_expr_t expr
The expression representing the local's value.
reduct_reg_t reg
Register index.
#define REDUCT_EXPR_CONST_ATOM(_compiler, _atom)
Create a REDUCT_MODE_CONST mode expression for a specific atom.
static reduct_size_t reduct_compile_jump(reduct_compiler_t *compiler, reduct_opcode_t op, reduct_reg_t a)
Emits a jump instruction without a target offset.
reduct_t * reduct
The Reduct structure.
#define REDUCT_EXPR_TARGET(_reg)
Create a REDUCT_MODE_TARGET mode expression.
static void reduct_compile_closure(reduct_compiler_t *compiler, reduct_reg_t target, reduct_const_t funcConst)
Emits a REDUCT_OPCODE_CLOSURE instruction.
#define REDUCT_EXPR_INT(_compiler, _val)
Create a REDUCT_MODE_CONST mode expression for an integer.
static void reduct_compile_call(reduct_compiler_t *compiler, reduct_reg_t target, reduct_expr_t *callable, reduct_uint32_t arity)
Emits a REDUCT_OPCODE_CALL instruction, that returns its result in the target register.
static reduct_reg_t reduct_compile_move_or_alloc(reduct_compiler_t *compiler, reduct_expr_t *expr)
Emits a move instruction or allocates a new register if the expression is not already in a register.
REDUCT_API void reduct_local_pop(reduct_compiler_t *compiler, reduct_uint16_t toCount, reduct_expr_t *result)
Pop local variables from the stack, releasing their registers if they are no longer used.
static void reduct_compile_list(reduct_compiler_t *compiler, reduct_reg_t target)
Emits a REDUCT_OPCODE_LIST instruction, that creates a list in the target register.
#define REDUCT_EXPR_NONE()
Create a REDUCT_MODE_NONE mode expression.
reduct_uint16_t value
Raw union value.
reduct_function_t * function
The function being compiled.
REDUCT_API void reduct_compiler_init(reduct_compiler_t *compiler, reduct_t *reduct, reduct_function_t *function, reduct_compiler_t *enclosing)
Initialize a compiler context.
REDUCT_API reduct_reg_t reduct_reg_alloc(reduct_compiler_t *compiler)
Allocate a new register.
REDUCT_API void reduct_compiler_deinit(reduct_compiler_t *compiler)
Deinitialize a compiler context.
static void reduct_compile_move(reduct_compiler_t *compiler, reduct_reg_t target, reduct_expr_t *expr)
Emits a REDUCT_OPCODE_MOVE instruction, that moves the value of the source expression to the target r...
#define REDUCT_LOCAL_IS_DEFINED(_local)
Check if a local variable has finished being defined.
#define REDUCT_EXPR_FALSE(_compiler)
Create a REDUCT_MODE_CONST mode expression for the false constant.
static void reduct_compile_append(reduct_compiler_t *compiler, reduct_reg_t target, reduct_expr_t *expr)
Emits an REDUCT_OPCODE_APPEND instruction.
static reduct_reg_t reduct_expr_get_reg(reduct_compiler_t *compiler, reduct_expr_t *out)
Allocate a new register, favoring the output expression's target if provided.
REDUCT_API reduct_reg_t reduct_reg_alloc_range(reduct_compiler_t *compiler, reduct_uint32_t count)
Allocate a range of registers.
#define REDUCT_EXPR_REG(_reg)
Create a REDUCT_MODE_REG mode expression.
REDUCT_API reduct_local_t * reduct_local_lookup(reduct_compiler_t *compiler, reduct_atom_t *name)
Look up a local by name and return its expression.
#define REDUCT_ERROR_RUNTIME(_reduct,...)
Throw a runtime error using the jump buffer in the error structure.
REDUCT_API void reduct_error_check_arity(struct reduct *reduct, reduct_size_t argc, reduct_size_t expected, const char *name)
Check the arity of a native function call.
#define REDUCT_ERROR_COMPILE(_compiler, _item,...)
Throw a compile error using the jump buffer in the error structure.
reduct_uint16_t reduct_const_t
Constant index type.
REDUCT_API reduct_function_t * reduct_function_new(struct reduct *reduct)
Create a new function.
#define REDUCT_CONST_SLOT_ITEM(_item)
Create a constant slot containing an item.
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_GC_RETAIN_ITEM(_reduct, _item)
Retain a item, preventing it from being collected by the GC.
#define REDUCT_HANDLE_FALSE()
Constant false handle.
#define REDUCT_HANDLE_FROM_LIST(_list)
Create a handle from a list pointer.
#define REDUCT_HANDLE_TO_ITEM(_handle)
Get the item pointer of a handle.
REDUCT_API void reduct_handle_promote(struct reduct *reduct, reduct_handle_t *a, reduct_handle_t *b, reduct_promotion_t *out)
Promote two handles to a common numeric type.
REDUCT_API reduct_handle_t reduct_handle_nil(struct reduct *reduct)
Get the constant nil handle.
REDUCT_API reduct_bool_t reduct_handle_is_equal(struct reduct *reduct, reduct_handle_t *a, reduct_handle_t *b)
Check if two items are exactly equal string-wise or structurally.
#define REDUCT_HANDLE_FROM_INT(_val)
Create a handle from an integer.
#define REDUCT_HANDLE_FROM_ITEM(_ptr)
Create a handle from an item pointer.
#define REDUCT_HANDLE_IS_TRUTHY(_handle)
Check if a handle is truthy.
REDUCT_API reduct_int64_t reduct_handle_compare(struct reduct *reduct, reduct_handle_t *a, reduct_handle_t *b)
Compare two items for ordering (less than, equal, or greater than).
#define REDUCT_HANDLE_TRUE()
Constant true handle.
#define REDUCT_HANDLE_ARITHMETIC_FAST(_reduct, _a, _b, _c, _op)
Perform a arithmetic operation on two handles with a fast path for integers and floats.
@ REDUCT_PROMOTION_TYPE_INT
#define REDUCT_REG_INVALID
Invalid register value.
#define REDUCT_INST_MAKE_ABC(_op, _a, _b, _c)
Create an instruction with opcode, A, B, and C operands.
reduct_opcode_t
Opcode enumeration.
reduct_uint16_t reduct_reg_t
Register type.
#define REDUCT_REGISTER_MAX
The max number of registers per function frame.
@ REDUCT_MODE_REG
Register operand mode.
@ REDUCT_MODE_NONE
Invalid mode.
@ REDUCT_MODE_CONST
Constant operand mode.
@ REDUCT_OPCODE_DIV
(A, B, C) R(A) = R(B) / R/K(C)
@ REDUCT_OPCODE_JMPF
(A, sBx) Jump by sBx if R(A) is falsy.
@ REDUCT_OPCODE_JMPT
(A, sBx) Jump by sBx if R(A) is truthy.
@ REDUCT_OPCODE_SHR
(A, B, C) R(A) = R(B) >> R/K(C)
@ REDUCT_OPCODE_SEQ
(A, B, C) If R(B) === R/K(C) store true in R(A), else false.
@ REDUCT_OPCODE_SHL
(A, B, C) R(A) = R(B) << R/K(C)
@ REDUCT_OPCODE_SUB
(A, B, C) R(A) = R(B) - R/K(C)
@ REDUCT_OPCODE_NEQ
(A, B, C) If R(B) != R/K(C) store true in R(A), else false.
@ REDUCT_OPCODE_MUL
(A, B, C) R(A) = R(B) * R/K(C)
@ REDUCT_OPCODE_ADD
(A, B, C) R(A) = R(B) + R/K(C)
@ REDUCT_OPCODE_BAND
(A, B, C) R(A) = R(B) & R/K(C)
@ REDUCT_OPCODE_BNOT
(A, C) R(A) = ~R/K(C)
@ REDUCT_OPCODE_EQ
(A, B, C) If R(B) == R/K(C) store true in R(A), else false.
@ REDUCT_OPCODE_GT
(A, B, C) If R(B) > R/K(C) store true in R(A), else false.
@ REDUCT_OPCODE_JMP
(sBx) Unconditional jump by relative offset sBx.
@ REDUCT_OPCODE_SNEQ
(A, B, C) If R(B) !== R/K(C) store true in R(A), else false.
@ REDUCT_OPCODE_GE
(A, B, C) If R(B) >= R/K(C) store true in R(A), else false.
@ REDUCT_OPCODE_BOR
(A, B, C) R(A) = R(B) | R/K(C)
@ REDUCT_OPCODE_LE
(A, B, C) If R(B) <= R/K(C) store true in R(A), else false.
@ REDUCT_OPCODE_BXOR
(A, B, C) R(A) = R(B) ^ R/K(C)
@ REDUCT_OPCODE_MOD
(A, B, C) R(A) = R(B) % R/K(C)
@ REDUCT_OPCODE_LT
(A, B, C) If R(B) < R/K(C) store true in R(A), else false.
#define REDUCT_INTRINSIC_BOR
Bitwise Or.
#define REDUCT_INTRINSIC_SHL
Bitwise Shift Left.
#define REDUCT_INTRINSIC_INC
Inc.
#define REDUCT_INTRINSIC_THREAD
Thread.
reduct_intrinsic_handler_t reductIntrinsicHandlers[REDUCT_INTRINSIC_MAX]
Intrinsic handler functions array.
#define REDUCT_INTRINSIC_ADD
Add.
#define REDUCT_INTRINSIC_NONE
None.
#define REDUCT_INTRINSIC_BAND
Bitwise And.
const char * reductIntrinsics[REDUCT_INTRINSIC_MAX]
Intrinsic names array.
#define REDUCT_INTRINSIC_OR
Or.
#define REDUCT_INTRINSIC_MOD
Mod.
#define REDUCT_INTRINSIC_COND
Cond.
#define REDUCT_INTRINSIC_AND
And.
#define REDUCT_INTRINSIC_DEF
Def.
#define REDUCT_INTRINSIC_MAX
The amount of intrinsics.
#define REDUCT_INTRINSIC_GE
Greater Equal.
#define REDUCT_INTRINSIC_IF
If.
#define REDUCT_INTRINSIC_BXOR
Bitwise Xor.
#define REDUCT_INTRINSIC_NOT
Not.
#define REDUCT_INTRINSIC_DO
Do.
#define REDUCT_INTRINSIC_NEQ
Not Equal.
#define REDUCT_INTRINSIC_LIST
List.
#define REDUCT_INTRINSIC_SEQ
Strict Equal.
#define REDUCT_INTRINSIC_DIV
Div.
#define REDUCT_INTRINSIC_EQ
Equal.
#define REDUCT_INTRINSIC_LAMBDA
Lambda.
reduct_native_fn reductIntrinsicNatives[REDUCT_INTRINSIC_MAX]
Intrinsic native functions array.
reduct_uint8_t reduct_intrinsic_t
Intrinsic types.
#define REDUCT_INTRINSIC_DEC
Dec.
#define REDUCT_INTRINSIC_LT
Less.
#define REDUCT_INTRINSIC_SUB
Sub.
#define REDUCT_INTRINSIC_LE
Less Equal.
#define REDUCT_INTRINSIC_GT
Greater.
#define REDUCT_INTRINSIC_BNOT
Bitwise Not.
#define REDUCT_INTRINSIC_MATCH
Match.
void(* reduct_intrinsic_handler_t)(struct reduct_compiler *compiler, struct reduct_item *expr, struct reduct_expr *out)
Intrinsic handler function type.
#define REDUCT_INTRINSIC_QUOTE
Quote.
#define REDUCT_INTRINSIC_MUL
Mul.
#define REDUCT_INTRINSIC_SHR
Bitwise Shift Right.
#define REDUCT_INTRINSIC_SNEQ
Strict Not Equal.
#define REDUCT_ITEM_TYPE_LIST
A list.
REDUCT_API const char * reduct_item_type_str(reduct_item_type_t type)
Get the string representation of an Reduct item type.
#define REDUCT_ITEM_TYPE_ATOM
An atom.
REDUCT_API reduct_float_t reduct_item_get_float(reduct_item_t *item)
Get the float value of an item if it is number shaped.
REDUCT_API reduct_int64_t reduct_item_get_int(reduct_item_t *item)
Get the integer value of an item if it is number shaped.
#define REDUCT_ITEM_FLAG_INT_SHAPED
Item is an integer shaped atom.
#define REDUCT_ITEM_FLAG_FLOAT_SHAPED
Item is a float shaped atom.
#define REDUCT_ITEM_FLAG_NATIVE
Item is an atom and a native function.
#define REDUCT_ITEM_FLAG_INTRINSIC
Item is an atom and a intrinsic.
reduct_handle_t(* reduct_native_fn)(struct reduct *reduct, reduct_size_t argc, reduct_handle_t *argv)
Native function pointer type.
REDUCT_API reduct_handle_t reduct_get_int(struct reduct *reduct, reduct_handle_t *handle)
void reduct_intrinsic_strict_not_equal(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
void reduct_intrinsic_do(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
#define REDUCT_INTRINSIC_NATIVE_COMPARE(_name, _op)
static void reduct_intrinsic_and_or(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out, reduct_opcode_t jumpOp)
#define REDUCT_INTRINSIC_NATIVE_LOGIC(_name, _short_circuit_truth)
void reduct_intrinsic_bit_not(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
static reduct_bool_t reduct_fold_comparison(reduct_t *reduct, reduct_opcode_t opBase, reduct_handle_t left, reduct_handle_t right, reduct_bool_t *result)
void reduct_intrinsic_inc(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
static void reduct_intrinsic_check_min_arity(reduct_compiler_t *compiler, reduct_item_t *list, reduct_size_t min, const char *name)
static reduct_bool_t reduct_fold_binary_expr(reduct_compiler_t *compiler, reduct_opcode_t opBase, reduct_expr_t *leftExpr, reduct_expr_t *rightExpr, reduct_expr_t *outExpr)
void reduct_intrinsic_list(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
static reduct_handle_t reduct_intrinsic_native_not(reduct_t *reduct, reduct_size_t argc, reduct_handle_t *argv)
static reduct_handle_t reduct_intrinsic_native_inc(reduct_t *reduct, reduct_size_t argc, reduct_handle_t *argv)
void reduct_intrinsic_quote(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
static reduct_handle_t reduct_intrinsic_native_list(reduct_t *reduct, reduct_size_t argc, reduct_handle_t *argv)
static reduct_atom_t * reduct_fold_binary_calc(reduct_compiler_t *compiler, reduct_opcode_t op, reduct_float_t lf, reduct_float_t rf, reduct_int64_t li, reduct_int64_t ri, reduct_bool_t isFloat)
static reduct_handle_t reduct_intrinsic_native_do(reduct_t *reduct, reduct_size_t argc, reduct_handle_t *argv)
static void reduct_intrinsic_register(reduct_t *reduct, reduct_intrinsic_t intrinsic)
void reduct_intrinsic_bit_shl(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
void reduct_intrinsic_not(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
static reduct_item_t * reduct_intrinsic_get_pair(reduct_compiler_t *compiler, reduct_handle_t *h, const char *name)
void reduct_intrinsic_def(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
static reduct_handle_t reduct_intrinsic_native_shl(reduct_t *reduct, reduct_size_t argc, reduct_handle_t *argv)
void reduct_intrinsic_if(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
static void reduct_compile_build_into_target(reduct_compiler_t *compiler, reduct_item_t *item, reduct_reg_t target)
void reduct_intrinsic_strict_equal(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
static void reduct_intrinsic_check_arity_range(reduct_compiler_t *compiler, reduct_item_t *list, reduct_size_t min, reduct_size_t max, const char *name)
static reduct_bool_t reduct_expr_get_item(reduct_compiler_t *compiler, reduct_expr_t *expr, reduct_handle_t *outItem)
REDUCT_API void reduct_intrinsic_register_all(reduct_t *reduct)
#define REDUCT_INTRINSIC_NATIVE_BITWISE(_name, _op)
void reduct_intrinsic_or(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
void reduct_intrinsic_greater(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
static void reduct_intrinsic_check_arity(reduct_compiler_t *compiler, reduct_item_t *list, reduct_size_t expected, const char *name)
void reduct_intrinsic_greater_equal(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
static void reduct_intrinsic_comparison_generic(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out, reduct_opcode_t opBase)
void reduct_intrinsic_block_generic(reduct_compiler_t *compiler, reduct_item_t *list, reduct_uint32_t startIdx, reduct_expr_t *out)
void reduct_intrinsic_less(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
void reduct_intrinsic_bit_and(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
void reduct_intrinsic_add(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
void reduct_intrinsic_bit_or(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
void reduct_intrinsic_less_equal(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
#define REDUCT_INTRINSIC_NATIVE_COMPARE_STRICT(_name, _expected)
#define REDUCT_INTRINSIC_NATIVE_ARITH(_name, _op, _identity)
void reduct_intrinsic_sub(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
static reduct_handle_t reduct_intrinsic_native_dec(reduct_t *reduct, reduct_size_t argc, reduct_handle_t *argv)
void reduct_intrinsic_div(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
void reduct_intrinsic_dec(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
void reduct_intrinsic_bit_shr(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
static reduct_handle_t reduct_intrinsic_native_bnot(reduct_t *reduct, reduct_size_t argc, reduct_handle_t *argv)
void reduct_intrinsic_lambda(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
static reduct_handle_t reduct_intrinsic_native_mod(reduct_t *reduct, reduct_size_t argc, reduct_handle_t *argv)
static void reduct_intrinsic_unary_op_generic(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out, reduct_opcode_t op, reduct_expr_t rightExpr, const char *name)
void reduct_intrinsic_binary_generic(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out, reduct_opcode_t opBase)
void reduct_intrinsic_match(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
void reduct_intrinsic_bit_xor(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
void reduct_intrinsic_equal(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
void reduct_intrinsic_not_equal(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
void reduct_intrinsic_thread(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
static reduct_bool_t reduct_expr_is_known_truthy(reduct_compiler_t *compiler, reduct_expr_t *expr, reduct_bool_t *isTruthy)
void reduct_intrinsic_and(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
void reduct_intrinsic_cond(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
static reduct_handle_t reduct_intrinsic_native_shr(reduct_t *reduct, reduct_size_t argc, reduct_handle_t *argv)
void reduct_intrinsic_mul(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
void reduct_intrinsic_mod(reduct_compiler_t *compiler, reduct_item_t *list, reduct_expr_t *out)
#define REDUCT_LIST_ITER_AT(_list, _start)
Create a initializer for a list iterator start at a specific index.
#define REDUCT_LIST_FOR_EACH_AT(_handle, _list, _start)
Macro for iterating over elements in a list starting from a specific index.
REDUCT_API void reduct_list_append(struct reduct *reduct, reduct_list_t *list, reduct_handle_t val)
Append an element to the list.
#define REDUCT_LIST_FOR_EACH(_handle, _list)
Macro for iterating over all elements in a list.
REDUCT_API reduct_bool_t reduct_list_iter_next(reduct_list_iter_t *iter, reduct_handle_t *out)
Get the next element from the iterator.
REDUCT_API reduct_list_t * reduct_list_new(struct reduct *reduct)
Create a new editable list.
REDUCT_API struct reduct_item * reduct_list_nth_item(struct reduct *reduct, reduct_list_t *list, reduct_size_t index)
Get the nth element of the list as an item.
reduct_native_fn native
Native function, item must have REDUCT_ITEM_FLAG_NATIVE.
reduct_int64_t integerValue
Pre-computed integer value, item must have REDUCT_ITEM_FLAG_INT_SHAPED.
char * string
Pointer to the string.
reduct_intrinsic_t intrinsic
Cached intrinsic, item must have REDUCT_ITEM_FLAG_INTRINSIC.
reduct_const_slot_type_t type
The type of the constant slot.
struct reduct_item * item
The item contained in the constant slot.
struct reduct_atom * capture
The name of the variable to be captured.
Expression descriptor structure.
Compiled function structure.
reduct_const_slot_t * constants
The array of constant slots forming the constant template.
reduct_uint16_t constantCount
Number of constants.
reduct_uint8_t arity
The number of arguments the function expects.
reduct_list_t list
A list.
reduct_uint32_t length
Common length for the item. (Stored in the union to save space due to padding rules....
struct reduct_input * input
The parsed input that created this item.
reduct_item_flags_t flags
Flags for the item.
reduct_atom_t atom
An atom.
reduct_item_type_t type
The type of the item.