feat(joinir): Phase 164 Pattern3 (If-Else PHI) validation complete
- Created 4 representative test cases for Pattern3 patterns: * test_pattern3_if_phi_no_break.hako - Core Pattern3 (if-else PHI, no break/continue) * test_pattern3_skip_whitespace.hako - Pattern3+break style (routed to Pattern2) * test_pattern3_trim_leading.hako - Pattern3+break style (routed to Pattern2) * test_pattern3_trim_trailing.hako - Pattern3+break style (routed to Pattern2) - Validated Pattern3_WithIfPhi detection: * Pattern routing: Pattern3_WithIfPhi MATCHED confirmed * JoinIR lowering: 3 functions, 20 blocks → 8 blocks (successful) * [joinir/freeze] elimination: Complete (no errors on any test) - Clarified pattern classification: * Pattern3_WithIfPhi handles if-else PHI without break/continue * Loops with "if-else PHI + break" are routed to Pattern2_WithBreak * Break takes priority over if-else PHI in pattern detection - Cumulative achievement (Phase 162-164): * Pattern1: 6 loops working ✅ * Pattern2: 5 loops working ✅ * Pattern3 (no break): 1 loop working ✅ * Pattern3+break (as Pattern2): 3 loops working ✅ * Total: 15 loops covered, zero [joinir/freeze] errors - Updated CURRENT_TASK.md with Phase 164 section and findings Next: Phase 165 Pattern4 (continue) validation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
48
tools/selfhost/program_analyze.sh
Normal file
48
tools/selfhost/program_analyze.sh
Normal file
@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
# tools/selfhost/program_analyze.sh - Phase 160-impl-1 Program JSON Analyzer wrapper
|
||||
#
|
||||
# Usage:
|
||||
# ./tools/selfhost/program_analyze.sh /path/to/program.json
|
||||
# ./tools/selfhost/program_analyze.sh < program.json # stdin
|
||||
#
|
||||
# This script reads a Program JSON v0 file and passes it to the .hako analyzer
|
||||
# for selfhost depth-2 verification (Rust outputs IR → .hako reads IR).
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
BIN="${NYASH_BIN:-$ROOT/target/release/hakorune}"
|
||||
HAKO="$ROOT/tools/selfhost/program_analyze.hako"
|
||||
|
||||
if [ ! -x "$BIN" ]; then
|
||||
echo "[ERROR] hakorune binary not found: $BIN" >&2
|
||||
echo "Run: cargo build --release" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ ! -f "$HAKO" ]; then
|
||||
echo "[ERROR] program_analyze.hako not found: $HAKO" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Read JSON from file argument or stdin
|
||||
if [ $# -ge 1 ] && [ -f "$1" ]; then
|
||||
JSON_CONTENT="$(cat "$1")"
|
||||
elif [ ! -t 0 ]; then
|
||||
# Read from stdin
|
||||
JSON_CONTENT="$(cat)"
|
||||
else
|
||||
echo "Usage: $0 /path/to/program.json" >&2
|
||||
echo " or: cat program.json | $0" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Run the .hako analyzer with Program JSON in environment
|
||||
export HAKO_PROGRAM_JSON="$JSON_CONTENT"
|
||||
export NYASH_FEATURES="${NYASH_FEATURES:-stage3}"
|
||||
export NYASH_PARSER_ALLOW_SEMICOLON=1
|
||||
export NYASH_USING_AST=1
|
||||
export NYASH_QUIET=0
|
||||
export HAKO_QUIET=0
|
||||
|
||||
exec "$BIN" --backend vm "$HAKO"
|
||||
Reference in New Issue
Block a user