stage1 优化重构代码
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user