Commit 86828e88
86828e88be37Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 6 files · ~6 modified
Description
compiler: convert the remaining five FFI registries to struct arrays
Follow-up to the ffi_func conversion: fold the const/buffer/reader/lib/cflag registries from parallel arrays into FfiConst/FfiBuf/FfiReader/FfiLib/FfiCflag struct arrays. Each grow site drops from N lockstep reallocs to one, and a new field on any registry is now a single struct member instead of a parallel array threaded through the struct, the grow block, and every access.
All six FFI registries are now arrays-of-structs. Pure internal refactor -- generated C is byte-for-byte identical across optcarrot, all benchmark/test inputs, and the FFI test programs.
Gates: 950 tests pass, optcarrot checksum 59662.
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- 86828e88be37
- Parent
- 55c3f365d345
src/analyze_infer.cmodifiedView file
/* ffi_read_*: Module.reader_name(buf) returns int or ptr */ int ri = ffi_find_reader(c, rcmod, name); if (ri >= 0) { const char *kind = c->ffi_reader_kinds[ri]; const char *kind = c->ffi_readers[ri].kind; if (kind && !strcmp(kind, "ptr")) return TY_POLY; return TY_INT; } /* FFI const: Module::NAME -> int */ if (par_nm && nm) { for (int fci = 0; fci < c->n_ffi_consts; fci++) { if (!strcmp(c->ffi_const_mods[fci], par_nm) && !strcmp(c->ffi_const_names[fci], nm)) if (!strcmp(c->ffi_consts[fci].mod, par_nm) && !strcmp(c->ffi_consts[fci].name, nm)) return TY_INT; } }src/analyze_scope.cmodifiedView file
Loading diff…
src/codegen.cmodifiedView file
Loading diff…
src/codegen_call.cmodifiedView file
Loading diff…
src/codegen_expr.cmodifiedView file
Loading diff…
src/compiler.hmodifiedView file
Loading diff…