stage1 优化重构代码

This commit is contained in:
zzy
2026-07-12 10:01:57 +08:00
parent f1b4225c92
commit 118c153280
6 changed files with 316 additions and 655 deletions

View File

@@ -240,6 +240,21 @@ int spl_lookup_func(spl_comp_t *ctx, const char *name) {
return -1;
}
/* Ensure a native function is registered for NCALL dispatch.
* Returns the native index. */
int spl_ensure_native(spl_comp_t *ctx, const char *name) {
vec_for(ctx->prog.natives, ni) {
if (strcmp(vec_at(ctx->prog.natives, ni).name, name) == 0)
return (int)ni;
}
spl_native_t nat;
nat.name = strdup(name);
nat.idx_of_strtab = 0;
nat.impl_fn = NULL;
vec_push(ctx->prog.natives, nat);
return (int)vec_size(ctx->prog.natives) - 1;
}
/* ---- String/data management ---- */
int spl_add_string(spl_comp_t *ctx, const char *str) {