summaryrefslogtreecommitdiff
path: root/src/core/interpret.c
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/interpret.c
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/interpret.c')
-rw-r--r--src/core/interpret.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/core/interpret.c b/src/core/interpret.c
index b5ec443..085f716 100644
--- a/src/core/interpret.c
+++ b/src/core/interpret.c
@@ -818,7 +818,7 @@ _compare(Interpret *p_interpret) {
_INTERPRET_ERROR("Expected sum", p_interpret->p_token);
function_process(p_interpret, p_token_op, p_token_op2,
- p_interpret->p_stack, 2);
+ p_interpret->p_stack, 2, NULL, 0);
}
break; /* case */
@@ -875,7 +875,7 @@ _sum(Interpret *p_interpret) {
_INTERPRET_ERROR("Expected product", p_token_op);
function_process(p_interpret, p_token_op, p_token_op2,
- p_interpret->p_stack, 2);
+ p_interpret->p_stack, 2, NULL, 0);
}
break; /* case */
@@ -913,7 +913,7 @@ _product(Interpret *p_interpret) {
_INTERPRET_ERROR("Expected product2", p_token);
function_process(p_interpret, p_token, NULL,
- p_interpret->p_stack, 2);
+ p_interpret->p_stack, 2, NULL, 0);
}
break; /* case */
@@ -955,12 +955,10 @@ _product2(Interpret *p_interpret) {
if (!_expression_(p_interpret))
_INTERPRET_ERROR("Expected expression", p_token);
- /* Restore array LHS so function_process can assign it */
- p_interpret->p_token_array_lhs = p_lhs;
- p_interpret->i_array_lhs_index = i_lhs_idx;
+ /* Pass array LHS explicitly; no longer stored in p_interpret */
p_interpret->p_token_temp = p_token_temp;
function_process(p_interpret, p_token, NULL,
- p_interpret->p_stack, 2);
+ p_interpret->p_stack, 2, p_lhs, i_lhs_idx);
p_interpret->p_token_temp = NULL;
} else {