Commit Graph

3 Commits

Author SHA1 Message Date
f740e6542f feat(phase285): Complete weak reference implementation (VM + LLVM harness)
Phase 285LLVM-1.1 to 1.4 + weak reference infrastructure:

**LLVM Harness** (Phase 285LLVM-1.x):
- 285LLVM-1.1: User Box registration & debug output
- 285LLVM-1.2: WeakRef basic operations (identity deferred)
- 285LLVM-1.3: InstanceBox field access (getField/setField)
- 285LLVM-1.4: print Handle resolution (type tag propagation)

**VM Runtime** (nyash_kernel):
- FFI functions: nyrt_weak_new, nyrt_weak_to_strong, nyrt_weak_drop
  (crates/nyash_kernel/src/lib.rs: +209 lines)
- WeakRef plugin invoke support
  (crates/nyash_kernel/src/plugin/invoke.rs: +250 lines)
- weak_handles.rs: WeakRef handle registry (NEW)

**LLVM Python Backend**:
- WeakRef instruction lowering (weak.py: NEW)
- Entry point integration (entry.py: +93 lines)
- Instruction lowering (instruction_lower.py: +13 lines)
- LLVM harness runner script (tools/run_llvm_harness.sh: NEW)

**MIR & Runtime**:
- WeakRef emission & validation
- MIR JSON export for weak instructions
- Environment variable support (NYASH_WEAK_*, HAKO_WEAK_*)

**Documentation**:
- CLAUDE.md: Phase 285 completion notes
- LANGUAGE_REFERENCE_2025.md: Weak reference syntax
- 10-Now.md & 30-Backlog.md: Phase 285 status updates

Total: +864 lines, 24 files changed

SSOT: docs/reference/language/lifecycle.md
Related: Phase 285W-Syntax-0, Phase 285W-Syntax-0.1
2025-12-25 00:11:34 +09:00
3aba574723 refactor(llvm): Phase 286B - Unify error handling with Result<T, LlvmRunError>
This refactoring consolidates 20+ duplicated error handling patterns in LLVM mode
into a unified Result-based error handling system.

New files:
- error.rs: LlvmRunError type with code, msg, and convenience constructors
- report.rs: emit_error_and_exit() - single exit point for all LLVM errors

Changes:
- harness_executor.rs: Returns Result<i32, LlvmRunError> instead of Option<i32>
- pyvm_executor.rs: Returns Result<i32, LlvmRunError> instead of Option<i32>
- fallback_executor.rs: Returns Result<i32, LlvmRunError> instead of i32
- mod.rs: Updated all error handling to use report::emit_error_and_exit()

Benefits:
1. Unified error handling with Result<T, LlvmRunError>
2. Clear separation: Executors return errors, orchestrator handles exit
3. Single exit point guarantees leak report consistency
4. Reduced code duplication (20+ patterns consolidated)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-24 11:10:57 +09:00
13545fd57e refactor(llvm): Phase 286 - Modularize llvm.rs into 10 boxes
Following Phase 33 success pattern:
- Single responsibility per box
- Testability through isolated boxes
- Reusability across backends

Before: 449 lines monolithic function
After: 229 line orchestrator + 10 focused boxes

Boxes created:
- plugin_init.rs (plugin initialization)
- using_resolver.rs (using/prelude handling)
- mir_compiler.rs (AST → MIR compilation)
- method_id_injector.rs (method_id injection)
- joinir_experiment.rs (JoinIR experiment, feature-gated)
- pyvm_executor.rs (PyVM harness, dev/test)
- object_emitter.rs (LLVM object emit)
- harness_executor.rs (LLVM harness execution)
- exit_reporter.rs (leak report, Phase 285LLVM-0)
- fallback_executor.rs (mock/legacy execution)

Test Results:
-  cargo build --release
-  cargo build --release --features llvm
-  18 VM/LLVM parity tests PASS
-  No regressions

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-24 10:45:17 +09:00