Files
hakorune/tools/selfhost/program_read_min.hako
nyash-codex 701f1fd650 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>
2025-12-06 16:22:38 +09:00

50 lines
1.5 KiB
Plaintext

// tools/selfhost/program_read_min.hako - Phase 160-impl-1 Minimal JSON Reader
// Reads Program JSON v0 from environment and prints it.
// This is the absolute minimum proof that .hako can read JSON from Rust output.
//
// Usage:
// HAKO_PROGRAM_JSON='{"version":0,"kind":"Program"}' ./target/release/hakorune tools/selfhost/program_read_min.hako
static box Main {
main(args) {
// Get Program JSON from environment variable
local json_str = env.get("HAKO_PROGRAM_JSON")
if json_str == null {
print("[ERROR] HAKO_PROGRAM_JSON not set")
return 1
}
if json_str == "" {
print("[ERROR] HAKO_PROGRAM_JSON is empty")
return 1
}
// Print the JSON (proving we received it)
print("=== Phase 160-impl-1: .hako received JSON from Rust ===")
print("JSON length: " + ("" + json_str.length()))
// Check for "Program" marker (basic validation without parsing)
local has_program = json_str.contains("Program")
if has_program {
print("Contains 'Program': YES")
}
if has_program == 0 {
print("Contains 'Program': NO")
}
local has_version = json_str.contains("version")
if has_version {
print("Contains 'version': YES")
}
if has_version == 0 {
print("Contains 'version': NO")
}
print("")
print("[SUCCESS] Phase 160-impl-1: .hako successfully read JSON from environment!")
print("(Full JSON parsing requires JoinIR loop support - Phase 161+)")
return 0
}
}