summaryrefslogtreecommitdiff
path: root/src/core/functions.h
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-28 16:04:22 +0200
committerPaul Buetow <paul@buetow.org>2026-02-28 16:04:22 +0200
commit946fac7d813f6283c18087a46b9e2ee084852c64 (patch)
treee00bc09a5205a6699cd40cbb48e9f47e9bcdc9dc /src/core/functions.h
parent075bc33d15b4d11fa03f381c3e03437d9f759c22 (diff)
Decouple functions.c from interpreter array-LHS private state [Coupling]
functions.c::_op_assign() was reading p_interpret->p_token_array_lhs and p_interpret->i_array_lhs_index directly — a hidden cross-module coupling where the functions module reached into interpreter-private state. Pass the array-LHS context as explicit parameters instead: - _op_assign() gains Token *p_array_lhs, int i_lhs_idx params - _process() propagates them to _op_assign() - function_process() propagates them from the call site In interpret.c the "restore" lines that set p_interpret->p_token_array_lhs and p_interpret->i_array_lhs_index before calling function_process() are removed; instead p_lhs and i_lhs_idx are passed directly. The three non-array-LHS call sites pass NULL / 0. _op_assign() no longer touches Interpret internals for the array assignment path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'src/core/functions.h')
-rw-r--r--src/core/functions.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/core/functions.h b/src/core/functions.h
index e20355b..ac45d5e 100644
--- a/src/core/functions.h
+++ b/src/core/functions.h
@@ -50,9 +50,11 @@ Functions* functions_new();
void functions_delete(Functions *p_functions);
void functions_init(Functions *p_functions);
+/* p_array_lhs / i_lhs_idx carry array-element LHS context for arr[i] = val;
+ * pass NULL / 0 for plain assignment or non-assignment operators. */
void function_process(Interpret *p_interp, Token *p_token_op,
Token *p_token_op2, Stack *p_stack_args,
- int i_args);
+ int i_args, Token *p_array_lhs, int i_lhs_idx);
_Bool function_is_buildin(Token *p_token_ident);
void function_process_buildin(Interpret *p_interpret,
Token *p_token_ident,