Commit Graph

4 Commits

Author SHA1 Message Date
2b86b658d8 docs(repl): Phase 288 documentation cleanup
Updated documentation to reflect actual implementation status:
- docs/reference/language/repl.md: Corrected examples (variable persistence TODO)
- docs/development/current/main/10-Now.md: Phase 288 completion noted
- docs/development/current/main/30-Backlog.md: Updated with Phase 288.1 tasks
- docs/development/current/main/phases/phase-288/: Added phase documentation

Accurate REPL behavior examples:
- x = 1 works (implicit local)
- print(x) errors (persistence in Phase 288.1)
- Expression auto-display deferred

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-25 14:01:32 +09:00
38968efa3c docs(repl): Update Phase 288 P3 completion status
Updated implementation status to reflect actual working features:
-  print() output displays
-  .reset command works
-  Implicit local binding compiles
-  Variable persistence (deferred to Phase 288.1+)

Known limitations documented:
- Variable access across lines not yet working
- _ variable stored but not accessible yet
- Expression auto-display deferred

Accurate current behavior examples added.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-25 13:48:39 +09:00
796089688a docs(repl): Phase 288 P0 - Establish REPL SSOT
Expanded docs/reference/language/repl.md (123→336 lines):
- Philosophy: "Two execution contexts, one language"
- File mode vs REPL mode: Concrete code examples
- Implementation Contract: VMValue persistence (not ValueId)
- Architecture: Box-First modularization (ReplSessionBox)
- Evaluation Pipeline: Parse→Compile→Execute→Store VMValue
- Phase 288 MVP status: P0-P3 completed, P288.1 deferred

Key design decisions documented:
- Session stores VMValue (runtime values, persist across lines)
- NOT ValueId (MIR-specific, invalidated per compilation)
- assignment_resolver.rs unchanged (file mode専用)
- 80/20 rule: Working REPL first, expression auto-display later

SSOT ensures implementation matches user expectations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-25 13:24:32 +09:00
c117a04035 fix(rewrite): toString normalization to BoxCall(slot #0) - Phase 287 P4
Root cause: toString/stringify/str were being rewritten to Global/Method calls
with class inference, causing Main.toString/0 to be called for primitives.

Fix (Box-First + Legacy Deletion):
1.  MIR Builder - toString normalization (special.rs)
   - ALWAYS emit BoxCall with method_id=0 for toString/stringify/str
   - Do NOT rewrite to Global(Class.str/0) or Method calls
   - DELETED 70+ lines of complex class inference logic
   - Primitive guard with method name filter (known.rs)

2.  JSON Serializer - method_id output (mir_json_emit.rs)
   - Include method_id field in BoxCall JSON for LLVM

3.  LLVM Backend - universal slot #0 support
   - Extract method_id from JSON (instruction_lower.py)
   - Box primitives via nyash.box.from_i64 (boxcall.py)
   - Invoke toString via plugin system with method_id=0
   - ⚠️ TODO: Add nyash.integer.tostring_h to kernel

Test Results:
 VM: local x = 1; print(x.toString()) → "1" (PASS)
 VM: array_length test (boxed Integer) → PASS
⚠️ LLVM: Compiles successfully, needs kernel function

SSOT: slot_registry - toString is ALWAYS universal slot #0

Legacy Deleted:
- special.rs: Complex class inference rewrite (~70 lines)
- special.rs: Unique suffix fallback for toString
- special.rs: Main box special handling

Files changed:
- src/mir/builder/rewrite/special.rs (try_early_str_like_to_dst)
- src/mir/builder/rewrite/known.rs (primitive guards x4)
- src/runner/mir_json_emit.rs (method_id serialization x2)
- src/llvm_py/builders/instruction_lower.py (method_id extraction)
- src/llvm_py/instructions/boxcall.py (slot #0 handler)
- docs/reference/language/quick-reference.md (toString SSOT)

🎊 Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-25 11:38:05 +09:00