Files
ww/.gitignore
Hojun-Cho 3ec944a67f selfhost/cmd/wcc/check+test: fold size(T)/align(T)/offset(e.f) at check time
Mirror cstage cmd/wcc/check.c:907-960. Three typed-builtin
intercepts that cstage already had:

- size(T) — folds to a literal integer at check time from a
  newly-introduced astsize walker over the type AST. Mirrors the
  size computation in cstage resolve_type at check.c:286-528.
- align(T) — same, via astalign.
- offset(e.f) — folds the byte offset of field f in e's struct
  type via astoffset. Peels exactly one N_TPTR for `p.field`.

seedprimitives registers the three names as SK_FN nil; exprtype's
N_CALL arm gates on a same-module shadow check (per #23 alloc
precedent) and consumes the parser-planted type-expression arg.
The fold is in-place — foldtointlit mutates N_CALL into N_INTLIT
so cgen sees a plain integer. resolvewalk's N_CALL trigger
invokes exprtype so the fold fires from non-let contexts too
(e.g. inside `if (size(T) != …)`).

selfhost/test/smoke.ww gains a probe-8 block: size/align/offset
assertions across str, primitive widths, ptrs, slices, and
two structs (`point`, `mixalign`) covering both no-padding and
i8+i64 natural-align padding cases.

Known divergences NOT in #42 scope:
- size((*T|void)) ≠ 8 on the cstage nullable-ptr fold (#13 family,
  unreachable through current grammar).
- 8B-struct bare-let zero-init wwstage skip vs cstage emit (#59).
- Same-module shadow gate added here, cstage has none — sibling
  shape to #26 (free/append/len gates).

Closes the original chain that started with the user's call to
fix the structural debt — six precondition fixes (#51, #52, #53,
#55, #56, #50) landed before this fold could safely live in the
check pass. Unblocks #43 (sweep literal 16s → size(str)) and #1
(str → 24B becomes one line).
2026-05-20 05:22:57 +09:00

63 lines
1.9 KiB
Plaintext

# Build outputs.
/out/
# Claude Code session artifacts.
.claude/
.ai/
# Stray executables produced by ad-hoc `ww build` runs in the project
# root. Real source for these lives under selfhost/test/ as .ww files.
/loop
/sym_link
/memiotest
/trypromote
/tagged_ptr_ret
/smoke
# Per-module build artifacts. The .combined.ww files under selfhost/
# are intentionally tracked — they're frozen bootstrap inputs.
selfhost/**/*.o
selfhost/**/*.s
# Test-probe leftovers. `ww build` drops .combined.ww next to the
# source; the selfhost/test/ probes don't need them tracked.
selfhost/test/*.combined.ww
# `ww build` on a lib/ module leaves a .combined.ww next to the
# source. None of these are bootstrap inputs (those are under
# selfhost/cmd/*/main.combined.ww) — they're just transient.
# `ww test lib/foo` also drops the .s/.o triplet for *_test.ww.
lib/**/*.combined.ww
lib/**/*.s
lib/**/*.o
# examples/ build outputs. Each example has its own Makefile that
# leaves the .s/.o/.combined.ww plus a stripped binary behind.
examples/**/*.o
examples/**/*.s
examples/**/*.combined.ww
# `test/wcc/data/` holds .ww fixtures fed to the C-side wcc tests
# (e.g. attest_pass.ww). `ww build` against any of those drops the
# usual triplet next to the source — only the .ww is tracked.
test/wcc/data/*.o
test/wcc/data/*.s
test/wcc/data/*.combined.ww
test/wcc/data/**/*.o
test/wcc/data/**/*.s
test/wcc/data/**/*.combined.ww
test/wcc/data/modcollision/pos
test/wcc/data/modcollision/neg
test/wcc/data/samemodprefer/pos
examples/mandelbrot/mandelbrot
examples/cmatrix/cmatrix
examples/lisp/lisp
examples/lisp/lisp_test
# Stage-0 binaries under bootstrap/<arch>/. Untracked by default —
# committing them is the v1.0 lock per PLAN.md (the new trust
# surface). `make bootstrap-snapshot` populates the dir from the
# current wwstage; `make nocc` verifies they self-reproduce.
# To ship, `git add -f bootstrap/amd64/{ww,w6c,w6a,w6l}` explicitly.
bootstrap/*/*