summaryrefslogtreecommitdiff
path: root/src/core/functions.c
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-28 14:15:53 +0200
committerPaul Buetow <paul@buetow.org>2026-02-28 14:15:53 +0200
commit952357132060dd874fc550d35e0e4f8bc61efd87 (patch)
tree2823a61e83dac3ee0d9658767b4f8d9d3c769db2 /src/core/functions.c
parent40ea1d6c3bc0fa587113225a20a3b52560182761 (diff)
Refactor _control() by extracting per-loop handlers and stack/iter helper
Add _eval_expr_list() to isolate condition evaluation in a temporary stack+iterator, restoring the outer stack before returning. This eliminates the duplicate stack/iter backup boilerplate that existed separately in the while/until and do-while paths. Extract four static handler functions from the 280-line _control() body: _control_if_ifnot() — TT_IF / TT_IFNOT _control_while_until() — TT_WHILE / TT_UNTIL; uses _eval_expr_list _control_loop() — TT_LOOP _control_do() — TT_DO; uses _eval_expr_list for post-condition _control() itself shrinks to a ~30-line dispatcher (ret/break/next inline; loops and conditionals delegated to their handlers). Semantic improvement in while/until: the original code ran the body with a temp stack active and then did a manual stack_merge for CONTROL_RET. Since _eval_expr_list now restores the outer stack before the body runs, interpret_subprocess merges return values into the outer stack directly — the extra stack_merge is no longer needed. Also removes the leftover debug printf("FOO")/exit(0) guard. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'src/core/functions.c')
0 files changed, 0 insertions, 0 deletions