ffi step 6: print / format migrate to ..\$args (comptime per-position pack)

`format` and `print` move from `..args: []Any` to `..$args`. The
pack-fn machinery monomorphises each call shape, so the
build_format-emitted body's `any_to_string(args[i])` substitutes
to the i-th concrete-typed call arg via packArgNodeAt — no more
runtime Any-boxing for static args. The Any boxing path still
fires for arg positions whose types collapse to `.any` (already
Any-typed inputs).

Net effect:
- Calls with statically-typed args produce per-shape monos
  (`print__ct_<fmt_hash>__pack_s64_string_bool` etc). The mono
  cache key now reflects both the format string AND the arg
  types, so different shapes get distinct emit paths.
- Compile-time arity errors are now possible (callers passing
  the wrong number of args mismatch the mono's positional
  binding instead of silently mis-boxing).
- Optionals flow through the new `case optional:` arm in
  `any_to_string` (commit ce77867); the variadic auto-unwrap
  in `packVariadicCallArgs` stays as a fast-path but is no
  longer load-bearing.

IR snapshots regenerated for 13 tests where the print/format
mono shape changed the string-constant pool: 142, the ffi-jni
test cluster, ffi-objc-call-03/06, ffi-objc-dsl-07. Test
08-types' undef-memory-read snapshot also shifted (the test
exercises `field = ---` reads from a print call's stack
neighbours; the new pack-mono lays out its stack frame
differently, so the previously-stale 1s now read as 0s — same
undefined behaviour, different garbage).

218/218 example tests + `zig build test` green.
This commit is contained in:
agra
2026-05-28 08:04:12 +03:00
parent b7c6ec24b0
commit 11eef8a6b1
15 changed files with 450 additions and 347 deletions

View File

@@ -390,12 +390,12 @@ build_format :: (fmt: string) -> string {
code;
}
format :: ($fmt: string, ..args: []Any) -> string {
format :: ($fmt: string, ..$args) -> string {
#insert build_format(fmt);
#insert "result;";
}
print :: ($fmt: string, ..args: []Any) {
print :: ($fmt: string, ..$args) {
#insert build_format(fmt);
#insert "out(result);";
}