summaryrefslogtreecommitdiff
path: root/src/core/interpret.c
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-28 14:06:05 +0200
committerPaul Buetow <paul@buetow.org>2026-02-28 14:06:05 +0200
commit40ea1d6c3bc0fa587113225a20a3b52560182761 (patch)
tree22ecffe3d9e311017892a6b05aee26892751097a /src/core/interpret.c
parent61190b56be38a0a39fc37307a9fbfce759b505c3 (diff)
Replace built-in strcmp chains with dispatch table in functions.c
Extract each of the 21 built-in function handlers (assert, decr, double, end, exit, fork, gc, incr, ind, integer, len, ln, neg, no, not, put, refs, say, scope, string, yes) into individual static _builtin_XXX() functions, each focused on a single responsibility. Add a null-terminated BuiltinEntry g_builtins[] dispatch table mapping name strings to handler function pointers. Rewrite function_is_buildin() and function_process_buildin() to iterate the table instead of maintaining parallel 21-branch strcmp chains. This satisfies OCP (adding a built-in only requires a new table row), SRP (each handler owns exactly one built-in's logic), and DRY (name lookup done in one place). The array special-case (len/ind on TT_ARRAY vs element-wise iteration) is preserved inline before the table dispatch. Also add missing NO_DEFAULT; to _builtin_say's switch for style consistency with all other handlers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'src/core/interpret.c')
0 files changed, 0 insertions, 0 deletions