diff options
Diffstat (limited to 'js/scripting-lang/baba-yaga-c/include/baba_yaga.h')
-rw-r--r-- | js/scripting-lang/baba-yaga-c/include/baba_yaga.h | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/js/scripting-lang/baba-yaga-c/include/baba_yaga.h b/js/scripting-lang/baba-yaga-c/include/baba_yaga.h index 687b774..0bd6037 100644 --- a/js/scripting-lang/baba-yaga-c/include/baba_yaga.h +++ b/js/scripting-lang/baba-yaga-c/include/baba_yaga.h @@ -256,6 +256,25 @@ size_t baba_yaga_table_size(const Value* table); */ bool baba_yaga_table_has_key(const Value* table, const char* key); +/** + * @brief Get all keys from a table + * + * @param table Table value + * @param keys Array to store keys (caller must free) + * @param max_keys Maximum number of keys to retrieve + * @return Number of keys retrieved + */ +size_t baba_yaga_table_get_keys(const Value* table, char** keys, size_t max_keys); + +/** + * @brief Get a value from table by key (supports both string and numeric keys) + * + * @param table Table value + * @param key Key (string or numeric as string) + * @return Value at key, or nil if not found + */ +Value baba_yaga_table_get_by_key(const Value* table, const char* key); + /* ============================================================================ * Function Management Functions * ============================================================================ */ @@ -278,10 +297,11 @@ Value baba_yaga_value_function(const char* name, Value (*body)(Value*, int), * @param func Function value to call * @param args Array of argument values * @param arg_count Number of arguments + * @param scope Current scope for function execution * @return Result of function call */ Value baba_yaga_function_call(const Value* func, const Value* args, - int arg_count); + int arg_count, Scope* scope); /* ============================================================================ * Internal Table Management Functions @@ -444,6 +464,12 @@ void* baba_yaga_ast_get_when_expr_pattern(void* node, int index); void* baba_yaga_ast_get_when_pattern_test(void* node); void* baba_yaga_ast_get_when_pattern_result(void* node); +/* Table AST accessor functions */ +int baba_yaga_ast_get_table_element_count(void* node); +void* baba_yaga_ast_get_table_element(void* node, int index); +void* baba_yaga_ast_get_table_access_object(void* node); +void* baba_yaga_ast_get_table_access_key(void* node); + /** * @brief Print AST for debugging * @@ -571,11 +597,27 @@ Value stdlib_compose(Value* args, int argc); Value stdlib_out(Value* args, int argc); Value stdlib_in(Value* args, int argc); Value stdlib_assert(Value* args, int argc); +Value stdlib_emit(Value* args, int argc); +Value stdlib_listen(Value* args, int argc); /* Higher-order functions */ Value stdlib_map(Value* args, int argc); Value stdlib_filter(Value* args, int argc); Value stdlib_reduce(Value* args, int argc); +Value stdlib_each(Value* args, int argc); +Value stdlib_flip(Value* args, int argc); +Value stdlib_constant(Value* args, int argc); + +/* Table operations namespace */ +Value stdlib_t_map(Value* args, int argc); +Value stdlib_t_filter(Value* args, int argc); +Value stdlib_t_reduce(Value* args, int argc); +Value stdlib_t_set(Value* args, int argc); +Value stdlib_t_delete(Value* args, int argc); +Value stdlib_t_merge(Value* args, int argc); +Value stdlib_t_length(Value* args, int argc); +Value stdlib_t_has(Value* args, int argc); +Value stdlib_t_get(Value* args, int argc); /* ============================================================================ * Scope Management Functions @@ -592,6 +634,7 @@ bool scope_define(Scope* scope, const char* name, Value value, bool is_constant) bool scope_has(Scope* scope, const char* name); /* Scope utilities */ +Scope* scope_get_global(Scope* scope); int scope_get_names(Scope* scope, char** names, int max_names); void scope_print(Scope* scope, int indent); |