|
|
f4ae144559
|
fix(using): StringUtils using resolution - dual root cause fix
🎯 Phase 21.7++ - using StringUtils as StringUtils 完全動作化!
## Root Cause #1: TOML Parse Error (lang/src/llvm_ir/hako_module.toml)
**Problem:**
```toml
line 18: aot_prep = "boxes/aot_prep.hako" # scalar
line 19: aot_prep.passes.strlen = "..." # table - CONFLICT!
```
→ TOML parse error prevented ALL aliases from loading
→ populate_from_toml() returned Err, aliases.len() = 0
**Fix:**
Commented out conflicting line 18:
```toml
# aot_prep = "boxes/aot_prep.hako" # Commented out: conflicts with aot_prep.passes.* below
aot_prep.passes.strlen = "boxes/aot_prep/passes/strlen.hako"
```
**Result:**
✅ populate_from_toml() succeeds
✅ 4 aliases loaded including StringUtils → string_utils
## Root Cause #2: Missing Arity Suffix (src/backend/mir_interpreter/handlers/calls/global.rs)
**Problem:**
- MIR functions stored as "BoxName.method/arity"
- VM looked up "StringUtils.starts_with" (no arity)
- Function table had "StringUtils.starts_with/2" (with /2)
→ Lookup failed with "Unknown: StringUtils.starts_with"
**Fix:**
Auto-append arity from args.len() if missing:
```rust
let mut canonical = crate::mir::naming::normalize_static_global_name(func_name);
if !canonical.contains('/') {
canonical = format!("{}/{}", canonical, args.len());
}
```
**Result:**
✅ "StringUtils.starts_with" + args.len()=2 → "StringUtils.starts_with/2"
✅ VM function lookup succeeds
## Debug Infrastructure
**Added comprehensive debug logging:**
1. src/runner/pipeline.rs:36-55 - NYASH_DEBUG_USING=1 for alias loading
2. src/backend/mir_interpreter/handlers/calls/global.rs:17-42 - NYASH_DEBUG_FUNCTION_LOOKUP=1 for VM lookup
## Test Coverage
**src/tests/json_lint_stringutils_min_vm.rs:**
- Rewrote to test arity auto-completion (not using resolution)
- Inlined StringUtils implementation to avoid pipeline dependency
- Tests that VM can call "StringUtils.starts_with" without arity suffix
- ✅ Test passes
**CLI Verification:**
```bash
NYASH_PARSER_STAGE3=1 HAKO_PARSER_STAGE3=1 NYASH_DISABLE_PLUGINS=1 \
./target/release/hakorune apps/tests/json_lint_stringutils_min.hako
# Output: OK
# RC: 0
```
## Impact
- ✅ using StringUtils as StringUtils fully functional
- ✅ All using aliases load successfully
- ✅ VM can find functions with/without arity suffix
- ✅ No breaking changes to existing code
- ✅ Debug logging for future troubleshooting
## Files Modified
- lang/src/llvm_ir/hako_module.toml (TOML fix)
- src/runner/pipeline.rs (debug logging)
- src/backend/mir_interpreter/handlers/calls/global.rs (arity fix + logging)
- src/tests/json_lint_stringutils_min_vm.rs (rewrite + enable)
- src/tests/mod.rs (register test)
Co-authored-by: Task Agent <task@anthropic.com>
Co-authored-by: Claude Code <claude@anthropic.com>
|
2025-11-22 01:21:38 +09:00 |
|
|
|
fa9cea51b6
|
feat(naming): Phase 25.4-A NamingBox SSOT統一化完了
Task A: NamingBox SSOT化(static/global名前決定の一元化)
## 変更内容
### 1. Builder側をNamingBoxに統一
- `src/mir/builder/decls.rs:46`
- 手動string組み立て → `encode_static_method()`使用に変更
- "Main.main" → "Main.main/N" (arity付き正規形)
### 2. VM側の構造確認・ドキュメント強化
- `src/backend/mir_interpreter/handlers/calls/global.rs:145-149`
- NamingBox SSOT原則をコメントで明示
- レガシーフォールバック廃止を明記
## テスト結果
✅ cargo test mir_static_box_naming: 2 passed
✅ cargo test stage1_cli_entry_ssa_smoke: 2 passed
## 技術的成果
- static box / global 呼び出しの名前決定を `src/mir/naming.rs` に一本化
- 手動文字列組み立て(`format!("{}.{}", box, method)`)を排除
- 正規化ルール(main→Main等)をNamingBox経由で統一
## 参考
- Phase 25.4計画: docs/development/roadmap/phases/phase-25.4-naming-cli-cleanup/
- NamingBox SSOT: src/mir/naming.rs
🎉 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-11-21 09:16:27 +09:00 |
|
|
|
28a312ea0d
|
feat(naming): Phase 25.4-A - NamingBox SSOT化完了
🎯 目的: static/global 呼び出しの名前決定を src/mir/naming.rs に一本化
✅ 実装完了:
- NamingBox(src/mir/naming.rs)実装
- encode_static_method(box, method, arity)
- normalize_static_global_name(func_name)
- static/global 名前の正規化ロジック統一
- MIR Builder統合(SSOT使用)
- src/mir/builder/decls.rs: build_static_main_box
- src/mir/builder/exprs.rs: 静的メソッド呼び出し
- src/mir/builder/metadata/propagate.rs: メタデータ伝播
- src/mir/builder/observe/mod.rs: Observe機能
- src/mir/builder/observe/types.rs: 型観測(新規)
- VM実行器統合(SSOT使用)
- src/backend/mir_interpreter/handlers/calls/global.rs
- normalize_static_global_name使用
- レガシーフォールバック削除済み確認
- テスト追加
- src/tests/mir_static_box_naming.rs
- encode/normalize の動作検証
📚 ドキュメント:
- docs/development/architecture/mir-naming-box.md
- NamingBoxの設計思想
- SSOT原則の説明
- 使用例
🎯 効果:
- 名前決定ロジックが1箇所に集約
- Builder/VM で同じ正規化ルールを使用
- 将来の名前空間拡張が容易
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-11-21 09:01:43 +09:00 |
|
|
|
f9d100ce01
|
chore: Phase 25.1 完了 - LoopForm v2/Stage1 CLI/環境変数削減 + Phase 26-D からの変更
Phase 25.1 完了成果:
- ✅ LoopForm v2 テスト・ドキュメント・コメント完備
- 4ケース(A/B/C/D)完全テストカバレッジ
- 最小再現ケース作成(SSAバグ調査用)
- SSOT文書作成(loopform_ssot.md)
- 全ソースに [LoopForm] コメントタグ追加
- ✅ Stage-1 CLI デバッグ環境構築
- stage1_cli.hako 実装
- stage1_bridge.rs ブリッジ実装
- デバッグツール作成(stage1_debug.sh/stage1_minimal.sh)
- アーキテクチャ改善提案文書
- ✅ 環境変数削減計画策定
- 25変数の完全調査・分類
- 6段階削減ロードマップ(25→5、80%削減)
- 即時削除可能変数特定(NYASH_CONFIG/NYASH_DEBUG)
Phase 26-D からの累積変更:
- PHI実装改善(ExitPhiBuilder/HeaderPhiBuilder等)
- MIRビルダーリファクタリング
- 型伝播・最適化パス改善
- その他約300ファイルの累積変更
🎯 技術的成果:
- SSAバグ根本原因特定(条件分岐内loop変数変更)
- Region+next_iパターン適用完了(UsingCollectorBox等)
- LoopFormパターン文書化・テスト化完了
- セルフホスティング基盤強化
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: ChatGPT <noreply@openai.com>
Co-Authored-By: Task Assistant <task@anthropic.com>
|
2025-11-21 06:25:17 +09:00 |
|
|
|
dda65b94b7
|
Phase 21.7 normalization: optimization pre-work + bench harness expansion
- Add opt-in optimizations (defaults OFF)
- Ret purity verifier: NYASH_VERIFY_RET_PURITY=1
- strlen FAST enhancement for const handles
- FAST_INT gate for same-BB SSA optimization
- length cache for string literals in llvmlite
- Expand bench harness (tools/perf/microbench.sh)
- Add branch/call/stringchain/arraymap/chip8/kilo cases
- Auto-calculate ratio vs C reference
- Document in benchmarks/README.md
- Compiler health improvements
- Unify PHI insertion to insert_phi_at_head()
- Add NYASH_LLVM_SKIP_BUILD=1 for build reuse
- Runtime & safety enhancements
- Clarify Rust/Hako ownership boundaries
- Strengthen receiver localization (LocalSSA/pin/after-PHIs)
- Stop excessive PluginInvoke→BoxCall rewrites
- Update CURRENT_TASK.md, docs, and canaries
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-11-13 16:40:58 +09:00 |
|