selfhost/runtime: Stage 0-1 runner + MIR JSON loader (summary) with trace; compiler: scopebox/loopform prepass wiring (flags, child args); libs: add P1 standard boxes (console/string/array/map) as thin wrappers; runner: pass --box-pref via env; ops_calls dispatcher skeleton; docs: selfhost executor roadmap + scopebox/loopform notes; smokes: selfhost runner + identity prepasses; CURRENT_TASK: update plan and box lib schedule

This commit is contained in:
Selfhosting Dev
2025-09-22 21:52:39 +09:00
parent b00dc4ec37
commit da78fc174b
72 changed files with 3163 additions and 2557 deletions

View File

@ -30,6 +30,16 @@ unset NYASH_PYVM_DUMP_CODE
unset NYASH_RESOLVE_SEAM_DEBUG
unset NYASH_RESOLVE_FIX_BRACES
unset NYASH_RESOLVE_DEDUP_BOX
"$BIN" --backend vm "$APP_INS"
# Run inspector and capture output
OUT=$("$BIN" --backend vm "$APP_INS")
echo "$OUT"
# CI guard: brace delta must be zero after FIX_BRACES normalization in the dump
echo "[dev] assert: prelude_brace_delta==0" >&2
echo "$OUT" | grep -q "^prelude_brace_delta=0$" || {
echo "[error] prelude_brace_delta is not zero" >&2
exit 1
}
popd >/dev/null

View File

@ -50,6 +50,7 @@ check_case "apps/tests/macro/loopform/two_vars.nyash"
check_case "apps/tests/macro/loopform/with_continue.nyash"
check_case "apps/tests/macro/loopform/with_break.nyash"
check_case "apps/tests/llvm_phi_mix.nyash"
check_case "apps/tests/loop_if_phi_continue.nyash"
if [ "$fails" -ne 0 ]; then
exit 2

View File

@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR=$(cd "$(dirname "$0")/../../.." && pwd)
echo "[smoke] loop phi values (then-continue + per-var PHI)" >&2
pushd "$ROOT_DIR" >/dev/null
cargo build --release -q
BIN=./target/release/nyash
APP=apps/tests/loop_if_phi_continue.nyash
# Run VM (PyVM) and suppress runner result line to compare pure prints
export NYASH_VM_USE_PY=1
export NYASH_JSON_ONLY=1
out=$("$BIN" --backend vm "$APP")
expected=$'7\n1'
if [[ "$out" != "$expected" ]]; then
echo "[smoke] FAIL: unexpected output" >&2
echo "--- got ---" >&2
printf '%s\n' "$out" >&2
echo "--- exp ---" >&2
printf '%s\n' "$expected" >&2
exit 1
fi
echo "[smoke] OK: loop phi values correct" >&2
popd >/dev/null

View File

@ -36,4 +36,15 @@ if [[ "$out" != "$expected" ]]; then
fi
echo "[smoke] OK: collect_prints using + mixed order" >&2
# Seam hygiene check: ensure prelude_brace_delta==0 on the dump
NYASH_PYVM_DUMP_CODE=1 NYASH_RESOLVE_SEAM_DEBUG=1 NYASH_RESOLVE_FIX_BRACES=1 NYASH_RESOLVE_DEDUP_BOX=1 \
"$BIN" --backend vm "$APP" >/dev/null 2>&1 || true
INS_OUT=$("$BIN" --backend vm apps/tests/dev_seam_inspect_dump.nyash)
echo "$INS_OUT" | grep -q "^prelude_brace_delta=0$" || {
echo "[smoke] FAIL: seam prelude_brace_delta is not zero" >&2
echo "$INS_OUT" >&2
exit 1
}
echo "[smoke] OK: seam prelude brace delta == 0" >&2
popd >/dev/null

View File

@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR=$(cd "$(dirname "$0")/../../.." && pwd)
cd "$ROOT_DIR"
echo "[smoke] build nyash (release)"
cargo build --release -q
BIN=./target/release/nyash
CHILD=apps/selfhost/compiler/compiler.nyash
echo "[smoke] run child (baseline)"
BASE=$("$BIN" --backend vm "$CHILD" -- --min-json)
echo "[smoke] run child (loopform on)"
WITH=$("$BIN" --backend vm "$CHILD" -- --min-json --loopform)
if [[ "$BASE" != "$WITH" ]]; then
echo "❌ loopform identity prepass altered JSON" >&2
diff -u <(echo "$BASE") <(echo "$WITH") || true
exit 1
fi
echo "$BASE" | grep -q '"kind":"Program"' || { echo "❌ baseline JSON missing Program kind" >&2; exit 1; }
echo "✅ loopform identity smoke passed"

View File

@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR=$(cd "$(dirname "$0")/../../.." && pwd)
cd "$ROOT_DIR"
echo "[smoke] build nyash (release)"
cargo build --release -q
BIN=./target/release/nyash
CHILD=apps/selfhost/compiler/compiler.nyash
if [[ ! -x "$BIN" ]]; then
echo "nyash binary not found: $BIN" >&2
exit 1
fi
echo "[smoke] run child (baseline)"
BASE=$("$BIN" --backend vm "$CHILD" -- --min-json)
echo "[smoke] run child (scopebox on)"
WITH=$("$BIN" --backend vm "$CHILD" -- --min-json --scopebox)
if [[ "$BASE" != "$WITH" ]]; then
echo "❌ scopebox identity prepass altered JSON" >&2
diff -u <(echo "$BASE") <(echo "$WITH") || true
exit 1
fi
echo "$BASE" | grep -q '"kind":"Program"' || { echo "❌ baseline JSON missing Program kind" >&2; exit 1; }
echo "✅ scopebox identity smoke passed"

View File

@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -euo pipefail
# Smoke: Stage 0/1 selfhost runner wiring (harness JSON path)
ROOT_DIR=$(cd "$(dirname "$0")/../../.." && pwd)
cd "$ROOT_DIR"
echo "[smoke] building nyash (release)"
cargo build --release -q
BIN=./target/release/nyash
APP=apps/tests/dev_prints_count_probe.nyash
if [[ ! -x "$BIN" ]]; then
echo "nyash binary not found: $BIN" >&2
exit 1
fi
echo "[smoke] running selfhost runner (harness)"
set +e
OUT=$(NYASH_VM_USE_PY=1 NYASH_SELFHOST_EXEC=1 "$BIN" --backend vm "$APP" -- --trace 2>&1)
CODE=$?
set -e
echo "$OUT" | sed -e 's/^/[child] /'
if [[ $CODE -ne 0 ]]; then
echo "❌ selfhost runner exited with code $CODE" >&2
exit $CODE
fi
if ! echo "$OUT" | grep -q "\[selfhost\] harness summary: functions="; then
echo "❌ expected harness summary line not found" >&2
exit 1
fi
echo "✅ selfhost runner smoke passed"