// Kyler Olsen // YREA SLS // Builtin Functions // November 2025 #include #include "sls/bool.h" #include "sls/builtin.h" #include "sls/hash_table.h" #include "sls/interpreter.h" #include "sls/lexer.h" Boolean builtin_addition(InterpreterState *interpreter_state); Boolean builtin_subtraction(InterpreterState *interpreter_state); Boolean builtin_multiplication(InterpreterState *interpreter_state); Boolean builtin_division(InterpreterState *interpreter_state); Boolean builtin_modulus(InterpreterState *interpreter_state); Boolean builtin_exponential(InterpreterState *interpreter_state); Boolean builtin_greater_than(InterpreterState *interpreter_state); Boolean builtin_greater_than_or_equal_to(InterpreterState *interpreter_state); Boolean builtin_less_than(InterpreterState *interpreter_state); Boolean builtin_less_than_or_equal_to(InterpreterState *interpreter_state); Boolean builtin_equal_to(InterpreterState *interpreter_state); Boolean builtin_not_equal_to(InterpreterState *interpreter_state); Boolean builtin_abs(InterpreterState *interpreter_state); Boolean builtin_acos(InterpreterState *interpreter_state); Boolean builtin_asin(InterpreterState *interpreter_state); Boolean builtin_assert(InterpreterState *interpreter_state); Boolean builtin_at(InterpreterState *interpreter_state); Boolean builtin_atan(InterpreterState *interpreter_state); Boolean builtin_atan2(InterpreterState *interpreter_state); Boolean builtin_bitand(InterpreterState *interpreter_state); Boolean builtin_bitnot(InterpreterState *interpreter_state); Boolean builtin_bitor(InterpreterState *interpreter_state); Boolean builtin_bitxor(InterpreterState *interpreter_state); Boolean builtin_ceil(InterpreterState *interpreter_state); Boolean builtin_concat(InterpreterState *interpreter_state); Boolean builtin_cos(InterpreterState *interpreter_state); Boolean builtin_depth(InterpreterState *interpreter_state); Boolean builtin_drop(InterpreterState *interpreter_state); Boolean builtin_dup(InterpreterState *interpreter_state); Boolean builtin_each(InterpreterState *interpreter_state); Boolean builtin_ends_with(InterpreterState *interpreter_state); Boolean builtin_enum(InterpreterState *interpreter_state); Boolean builtin_enumerate(InterpreterState *interpreter_state); Boolean builtin_eval(InterpreterState *interpreter_state); Boolean builtin_filter(InterpreterState *interpreter_state); Boolean builtin_find(InterpreterState *interpreter_state); Boolean builtin_floor(InterpreterState *interpreter_state); Boolean builtin_fn(InterpreterState *interpreter_state); Boolean builtin_foldl(InterpreterState *interpreter_state); Boolean builtin_foldr(InterpreterState *interpreter_state); Boolean builtin_for(InterpreterState *interpreter_state); Boolean builtin_format(InterpreterState *interpreter_state); Boolean builtin_get(InterpreterState *interpreter_state); Boolean builtin_if(InterpreterState *interpreter_state); Boolean builtin_impl(InterpreterState *interpreter_state); Boolean builtin_implements(InterpreterState *interpreter_state); Boolean builtin_inher(InterpreterState *interpreter_state); Boolean builtin_lambda(InterpreterState *interpreter_state); Boolean builtin_length(InterpreterState *interpreter_state); Boolean builtin_ln(InterpreterState *interpreter_state); Boolean builtin_log(InterpreterState *interpreter_state); Boolean builtin_logb(InterpreterState *interpreter_state); Boolean builtin_map(InterpreterState *interpreter_state); Boolean builtin_match(InterpreterState *interpreter_state); Boolean builtin_max(InterpreterState *interpreter_state); Boolean builtin_mean(InterpreterState *interpreter_state); Boolean builtin_min(InterpreterState *interpreter_state); Boolean builtin_not(InterpreterState *interpreter_state); Boolean builtin_or(InterpreterState *interpreter_state); Boolean builtin_over(InterpreterState *interpreter_state); Boolean builtin_pick(InterpreterState *interpreter_state); Boolean builtin_rand(InterpreterState *interpreter_state); Boolean builtin_reduce(InterpreterState *interpreter_state); Boolean builtin_replace(InterpreterState *interpreter_state); Boolean builtin_reverse(InterpreterState *interpreter_state); Boolean builtin_roll(InterpreterState *interpreter_state); Boolean builtin_round(InterpreterState *interpreter_state); Boolean builtin_seed(InterpreterState *interpreter_state); Boolean builtin_set(InterpreterState *interpreter_state); Boolean builtin_shl(InterpreterState *interpreter_state); Boolean builtin_shr(InterpreterState *interpreter_state); Boolean builtin_sin(InterpreterState *interpreter_state); Boolean builtin_slice(InterpreterState *interpreter_state); Boolean builtin_split(InterpreterState *interpreter_state); Boolean builtin_sqrt(InterpreterState *interpreter_state); Boolean builtin_starts_with(InterpreterState *interpreter_state); Boolean builtin_struct(InterpreterState *interpreter_state); Boolean builtin_substr(InterpreterState *interpreter_state); Boolean builtin_sum(InterpreterState *interpreter_state); Boolean builtin_swap(InterpreterState *interpreter_state); Boolean builtin_tan(InterpreterState *interpreter_state); Boolean builtin_trait(InterpreterState *interpreter_state); Boolean builtin_transpose(InterpreterState *interpreter_state); Boolean builtin_trim(InterpreterState *interpreter_state); Boolean builtin_type_of(InterpreterState *interpreter_state); Boolean builtin_union(InterpreterState *interpreter_state); Boolean builtin_while(InterpreterState *interpreter_state); Boolean builtin_window(InterpreterState *interpreter_state); Boolean builtin_zip(InterpreterState *interpreter_state); static inline Boolean hash_table_put_funcs(HashTable *ht, SlsStr key, FunctionItem *item) { return hash_table_put(ht, key, (void *)item); } Boolean load_builtins(InterpreterState *interpreter_state) { FunctionItem *func; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_addition}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("+"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_subtraction}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("-"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_multiplication}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("*"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_division}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("/"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_modulus}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("%"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_exponential}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("^"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_greater_than}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR(">"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_greater_than_or_equal_to}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR(">="), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_less_than}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("<"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_less_than_or_equal_to}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("<="), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_equal_to}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("=="), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_not_equal_to}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("!="), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_abs}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("abs"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_acos}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("acos"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_asin}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("asin"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_assert}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("assert"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_at}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("at"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_atan}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("atan"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_atan2}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("atan2"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_bitand}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("bitand"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_bitnot}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("bitnot"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_bitor}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("bitor"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_bitxor}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("bitxor"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_ceil}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("ceil"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_concat}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("concat"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_cos}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("cos"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_depth}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("depth"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_drop}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("drop"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_dup}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("dup"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_each}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("each"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_ends_with}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("ends_with"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_enum}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("enum"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_enumerate}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("enumerate"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_eval}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("eval"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_filter}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("filter"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_find}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("find"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_floor}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("floor"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_fn}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("fn"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_foldl}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("foldl"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_foldr}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("foldr"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_for}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("for"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_format}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("format"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_get}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("get"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_if}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("if"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_impl}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("impl"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_implements}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("implements"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_inher}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("inher"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_lambda}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("lambda"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_length}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("length"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_ln}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("ln"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_log}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("log"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_logb}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("logb"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_map}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("map"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_match}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("match"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_max}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("max"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_mean}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("mean"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_min}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("min"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_not}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("not"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_or}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("or"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_over}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("over"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_pick}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("pick"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_rand}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("rand"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_reduce}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("reduce"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_replace}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("replace"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_reverse}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("reverse"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_roll}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("roll"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_round}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("round"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_seed}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("seed"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_set}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("set"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_shl}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("shl"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_shr}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("shr"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_sin}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("sin"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_slice}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("slice"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_split}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("split"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_sqrt}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("sqrt"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_starts_with}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("starts_with"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_struct}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("struct"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_substr}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("substr"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_sum}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("sum"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_swap}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("swap"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_tan}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("tan"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_trait}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("trait"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_transpose}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("transpose"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_trim}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("trim"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_type_of}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("type_of"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_union}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("union"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_while}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("while"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_window}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("window"), func)) return FALSE; func = (FunctionItem *)malloc(sizeof(FunctionItem)); if (func == NULL) return FALSE; *func = (FunctionItem){ .type = FUNCTION_BUILTIN, .builtin = *builtin_zip}; if (!hash_table_put_funcs(interpreter_state->functions, SLS_STR("zip"), func)) return FALSE; return TRUE; } Boolean builtin_addition(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_subtraction(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_multiplication(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_division(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_modulus(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_exponential(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_greater_than(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_greater_than_or_equal_to(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_less_than(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_less_than_or_equal_to(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_equal_to(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_not_equal_to(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_abs(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_acos(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_asin(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_assert(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_at(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_atan(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_atan2(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_bitand(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_bitnot(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_bitor(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_bitxor(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_ceil(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_concat(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_cos(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_depth(InterpreterState *interpreter_state) { size_t depth = 0; for (StackItem *node = interpreter_state->stack; node; node = node->next) depth++; return push_token(interpreter_state, (Token){ .type = TOKEN_INTEGER, .integer_literal = (IntegerLiteral){ .type = INTEGER_U64, .value = (uint64_t)depth, }, }); } Boolean builtin_drop(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_dup(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_each(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_ends_with(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_enum(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_enumerate(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_eval(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_filter(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_find(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_floor(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_fn(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_foldl(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_foldr(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_for(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_format(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_get(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_if(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_impl(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_implements(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_inher(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_lambda(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_length(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_ln(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_log(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_logb(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_map(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_match(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_max(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_mean(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_min(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_not(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_or(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_over(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_pick(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_rand(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_reduce(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_replace(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_reverse(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_roll(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_round(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_seed(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_set(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_shl(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_shr(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_sin(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_slice(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_split(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_sqrt(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_starts_with(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_struct(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_substr(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_sum(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_swap(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_tan(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_trait(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_transpose(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_trim(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_type_of(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_union(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_while(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_window(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; } Boolean builtin_zip(InterpreterState *interpreter_state) { (void)interpreter_state; return FALSE; }