mirror of
https://github.com/Druthulu/BFM-decomp
synced 2026-10-05 08:57:59 -04:00
3.1 KiB
3.1 KiB
T2.c3 — type_census --check-casts (coder log)
Changed
- tools/type_census.py
KEPT_MACROSregistry (CAST_ALIAS/SIGN/WIDTH/MISALIGNED/NONSTRUCT → class; LOBU..LOWU → REINTERP),FORM_Kregex,DEFLINE_FILE/DEFLINE_RX(after FORM_C).- find_sites: form K pass after M; every K site has tu, fn, line, pos, end, name, cls, bclass ("other" default), base, off; CAST_* get parse_base(args[1]) + classify, off += int(args[2]), ctype = args[0], stars=1 (so width/sign fill). raw_counts["K"] counted so coverage per walk stays equal. K not in RAW_FORMS (build_struct_map, deref_total, by_bclass untouched).
- walk_file: for include/common.h, sites on a
#define <KEPT_MACROS|M2C_FIELD>line getdefline=True; abs_casts excludes K. check_casts_counts(sites, raw_counts)→ ({P,I,X,M} minus defline sites, macro sites minus deflines); used by run_census and selftest.- summary: casts.macros {name:n}, casts.check_raw, casts.macro_sites; decls.lying_rows [{callee, defined_in, kind}].
check_casts_inputs()(lazy restruct import;rs.ledger_latest(rs.load_ledger()); TSV exceptions set),check_casts_verdict(raw_by_form, macro_sites, latest, lying_rows, exceptions)→ (rc, line);--check-castsin main.- selftest: +18 checks (per-form positive + near-misses p->f, CAST_ALIAS-as-P/M, (u8)x, q[k]; K sites name/cls/base; common.h define lines dropped vs same text in a .c counted; backed / unbacked / wrong class; lying ledgered vs not; all-zero exact line; raw FAIL).
- config/lying_exceptions.tsv:
#contract line + header, no rows. - Caches: removed .run/P37/census/cache/walk_cache.json; .run/P39/census/cache absent after rm -rf.
Base string
- ledger site base = restruct.site_row
f"{bclass}:{base}"from census sites after classify() → "param:a0"; K uses the same classify → match. No mismatch.
Verified
/usr/bin/python3 tools/type_census.py --selftest→50/50 checks OK, rc 0.- live
--check-casts --no-cache --out-dir .run/P39/census -j 16 --quiet→check-casts: raw P=408974 I=60666 X=13800 M=19542; macros none (unbacked 0); lying=229 (ledgered 0), exit 1 (expected FAIL). by_form deref_total 502988 (P=408979 incl. the 5 CAST_* define lines in common.h). --check-structs --quiet→type_census --check-structs: OK, conflicting_types=0, rc 0.make kit-corpus→ rc 0, < 2 min.
Notes for the expert
- restruct.py:802/914 iterate ALL tc sites with
s.get("bclass") + ":"; K sites therefore always carry a bclass (REINTERP "other"). A CAST_* K site with a ctype on the same base now adds its ctype to restruct's ctypes_by_off (evidence, not a raw site); restruct's RAW_FORMS filters elsewhere exclude K. - type_census.json grows ~1.2k lines (lying_rows, indent=1).
- Uncommitted side effects of the briefed commands (not in my commit paths): --check-structs (default out-dir) rewrote tracked .run/P37/census/{type_census.json,txt,struct_map_top.json} and docs/struct-map.md (19123 types / 502988 sites); kit-corpus touched decomp-architect/corpus/* and docs/gen3-standards.md diffs present (source of gen3-standards change not verified). Also P37 walk cache was rebuilt by the --check-structs run under the new TOOL_STAMP.