The session-long set of changes that lay the groundwork for the
Jai-literal implicit-Context-parameter refactor. Lots of accumulated
work; the new arrival is the implicit-ctx foundation (steps 1+2 of
the plan in current/CHECKPOINT-MEM.md):
Step 1 — `CAllocator :: struct {}` stateless allocator in
library/modules/allocators.sx, delegating directly to
libc_malloc/libc_free. `ConstantValue` in src/ir/inst.zig gains a
`func_ref: FuncId` leaf so nested aggregates can carry function
pointers (the inline Allocator value's fn-ptr fields). Switch
sites updated in emit_llvm.zig, print.zig, interp.zig.
Step 2 — `emitDefaultContextGlobal` in src/ir/lower.zig synthesises
a static `__sx_default_context` global with a nested-aggregate
init_val pointing at the CAllocator → Allocator thunks. The
second-pass `initVtableGlobals` in emit_llvm.zig is generalised
to handle `.aggregate` init_vals (re-emits after func_map is
populated so func_ref leaves resolve to real symbols).
Also folded in from earlier work this session:
- Phase 1.1: `xx value` heap-copy in `buildProtocolValue` routes
through `context.allocator` via the new `allocViaContext` helper.
- interp.zig: `marshalForeignArg` double-offset bug fixed —
`heapSlice` already adds `hp.offset` to the slice ptr, so the
extra `+ hp.offset` was scribbling memcpy/memset into adjacent
heap state, corrupting `heap.items[0]`. Symptom: `build_format`
at comptime produced zero bytes, all `print` calls failed.
- Lazy lowering: `lazyLowerFunction` now declares foreign-body
functions as extern stubs in the local (comptime) module so
cross-module foreign calls resolve.
- Allocator API: all stdlib allocators on one-line `init() -> *T`
(CAllocator/GPA: libc-backed; Arena/TrackingAllocator: parent-
backed; BufAlloc: embeds state at head of user buffer).
- issues 0038 (transitive #import), 0039 (chess + stdlib migration
fallout), 0040 (generic struct method dot-dispatch), 0041
(pointer types as type-arg), 0042 (alias name resolution) — all
fixed; regression tests in examples/.
- Diagnostic: `emitError` now embeds the lowering's
`current_source_file` and enclosing function in the literal
message; SX_TRACE_UNRESOLVED=1 dumps a Zig stack trace at the
emit site so misattributed spans can't hide where the failure
is.
- tools/verify-step.sh (all-platforms gate) and tools/scratch.sh
(interp/codegen parity tester) added.
Test suite: 152 example tests pass; chess builds + screenshots on
macOS / iOS sim / Android.
86 lines
3.3 KiB
Bash
Executable File
86 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# tools/verify-step.sh
|
|
#
|
|
# Single-command verification gate run after every plan step.
|
|
# Per the mem.sx implementation plan, ~/projects/game must remain
|
|
# buildable + runnable on all 3 platforms (macOS host, iOS sim,
|
|
# Android device) at every step boundary.
|
|
#
|
|
# Exits 0 if all gates pass; non-zero on any failure.
|
|
# Screenshots saved to /tmp/sx-game-{macos,iossim,android}.png.
|
|
|
|
set -e
|
|
|
|
ROOT="/Users/agra/projects/sx"
|
|
GAME="/Users/agra/projects/game"
|
|
SX="$ROOT/zig-out/bin/sx"
|
|
|
|
cd "$ROOT"
|
|
|
|
echo "── 1/5 zig build ─────────────────────────────────────"
|
|
zig build
|
|
|
|
echo "── 2/5 zig build test ────────────────────────────────"
|
|
zig build test
|
|
|
|
echo "── 3/5 example regression suite ──────────────────────"
|
|
bash tests/run_examples.sh
|
|
|
|
echo "── 4/5 chess: cross-build for all 3 platforms ────────"
|
|
# Builds must be serial — sx writes to .sx-tmp/ which would race in parallel.
|
|
cd "$GAME"
|
|
"$SX" build main.sx > /tmp/sx-game-macos-build.log 2>&1 \
|
|
|| { echo "macOS build failed:"; cat /tmp/sx-game-macos-build.log; exit 1; }
|
|
echo " macOS OK"
|
|
"$SX" build --target ios-sim main.sx > /tmp/sx-game-iossim-build.log 2>&1 \
|
|
|| { echo "iOS sim build failed:"; cat /tmp/sx-game-iossim-build.log; exit 1; }
|
|
echo " iOS sim OK"
|
|
"$SX" build --target android main.sx > /tmp/sx-game-android-build.log 2>&1 \
|
|
|| { echo "Android build failed:"; cat /tmp/sx-game-android-build.log; exit 1; }
|
|
echo " Android OK"
|
|
|
|
echo "── 5/5 chess: launch + screenshot on each platform ───"
|
|
|
|
# macOS — direct binary launch
|
|
./sx-out/macos/SxChess > /tmp/sx-game-macos-run.log 2>&1 &
|
|
PID=$!
|
|
sleep 5
|
|
if ps -p $PID > /dev/null; then
|
|
screencapture -x /tmp/sx-game-macos.png
|
|
kill $PID 2>/dev/null
|
|
wait $PID 2>/dev/null
|
|
echo " macOS screenshot saved: /tmp/sx-game-macos.png"
|
|
else
|
|
echo " macOS process exited early; log:"
|
|
cat /tmp/sx-game-macos-run.log
|
|
exit 1
|
|
fi
|
|
|
|
# iOS sim — requires booted simulator
|
|
if xcrun simctl list devices booted 2>/dev/null | grep -q "Booted"; then
|
|
xcrun simctl install booted "$GAME/sx-out/ios/SxChess.app" > /dev/null 2>&1
|
|
xcrun simctl launch booted co.swipelab.sxchess > /dev/null 2>&1
|
|
sleep 5
|
|
xcrun simctl io booted screenshot /tmp/sx-game-iossim.png > /dev/null 2>&1
|
|
echo " iOS sim screenshot saved: /tmp/sx-game-iossim.png"
|
|
else
|
|
echo " iOS sim SKIPPED (no booted simulator)"
|
|
fi
|
|
|
|
# Android — requires connected device. Needs 6s+ for the side panel to render.
|
|
if adb devices 2>/dev/null | grep -q "device$"; then
|
|
adb install -r "$GAME/sx-out/android/sxchess.apk" > /dev/null 2>&1
|
|
adb shell am force-stop co.swipelab.sxchess > /dev/null 2>&1
|
|
adb shell am start -n co.swipelab.sxchess/.SxApp > /dev/null 2>&1
|
|
sleep 6
|
|
adb exec-out screencap -p > /tmp/sx-game-android.png 2>/dev/null
|
|
echo " Android screenshot saved: /tmp/sx-game-android.png"
|
|
else
|
|
echo " Android SKIPPED (no connected device)"
|
|
fi
|
|
|
|
cd "$ROOT"
|
|
echo ""
|
|
echo "═══ all gates pass ═════════════════════════════════════"
|
|
echo "screenshots: /tmp/sx-game-{macos,iossim,android}.png"
|