Commit Graph

33 Commits

Author SHA1 Message Date
b92f85f993 refactor(mir): Remove TypeContext legacy fields (Phase 2-3/7)
完全移行→削除の安全順序(Option C)に従い、TypeContext の
deprecated フィールドと sync helpers を完全削除。

⚠️ 危険ゾーン: TypeFactsBox 等の同名フィールドと混同しないよう、
ファイル単位で手作業移行を実施。

## Changes
- Migrated all MirBuilder access sites to type_ctx.* (manual, 40+ files)
- Removed 3 deprecated fields (value_types, value_kinds, value_origin_newbox)
- Removed 2 sync helpers (sync_type_ctx_to_legacy, sync_legacy_to_type_ctx)
- Verified TypeFactsBox, CalleeGuardBox unchanged (no false positives)

## Tests
- cargo test --release --lib: 1029/1033 PASS
- TypeFactsBox integration: PASS (borrowed references unchanged)
- Deprecation warnings: 456 → 255 (-201, -44%)

## Safety Verification
 TypeFactsBox unchanged (still uses &'a BTreeMap borrowed references)
 CalleeGuardBox unchanged
 CalleeResolverBox unchanged
 BoxCompilationContext unchanged

Phase 2 Progress: 3/7 contexts complete (43%)
-  MetadataContext
-  CoreContext
-  TypeContext (this commit)

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-15 23:27:24 +09:00
2db8ff72d0 refactor(mir): Remove CoreContext legacy fields (Phase 2-2/7)
完全移行→削除の安全順序(Option C)に従い、CoreContext の
deprecated フィールドと sync helpers を完全削除。

## Changes
- Migrated all access sites to core_ctx.* (SSOT allocators)
  - utils.rs: value_gen (3 sites), block_gen (1 site), temp_slot_counter (1 site)
  - loop_api.rs: block_gen (1 site)
  - phi_helpers.rs: value_gen (1 site)
  - builder.rs: sync helpers (2 methods), test assertions (2 sites)
- Removed 5 deprecated fields from builder.rs
  - value_gen: ValueIdGenerator
  - block_gen: BasicBlockIdGenerator
  - next_binding_id: u32
  - temp_slot_counter: u32
  - debug_join_counter: u32
- Removed sync helper calls (allocate_binding_id, debug_next_join_id)
- Removed field initializations from MirBuilder::new()
- Maintained Phase 136 P0 SSOT structure (next_value_id() remains as high-level API)

## Tests
- cargo build --release: PASS
- cargo test --release --lib: 1029 passed (4 pre-existing failures)
- Deprecation warnings: 435 → 456 (+21)
  Note: Warnings increased due to remaining deprecated field *uses* being exposed
  after removing the field *definitions*. This is expected during migration.

## Code metrics
- Net reduction: 40 lines (-56 removed, +16 modifications)
- Files changed: 4 (builder.rs, utils.rs, loop_api.rs, phi_helpers.rs)

Phase 2 Progress: 2/7 contexts complete (MetadataContext , CoreContext )
2025-12-15 23:05:36 +09:00
a898e99310 refactor(mir): Remove MetadataContext legacy fields (Phase 2-1/7)
完全移行→削除の安全順序(Option C)に従い、MetadataContext の
deprecated フィールドと sync helpers を完全削除。

## Changes
- Migrated all access sites to metadata_ctx.* (builder methods)
  - current_span → metadata_ctx.current_span() / set_current_span()
  - source_file → metadata_ctx.current_source_file() / set_source_file() / clear_source_file()
  - hint_sink → metadata_ctx.hint_scope_enter/leave/join_result()
  - current_region_stack → metadata_ctx.push_region/pop_region/current_region_stack()
- Removed 4 deprecated fields from MirBuilder
  - current_span, source_file, hint_sink, current_region_stack
- Removed 2 sync helpers
  - sync_metadata_ctx_to_legacy(), sync_legacy_to_metadata_ctx()
- Updated 10 files with direct field accesses

## Files Modified
- src/mir/builder.rs: -56 lines (fields + sync helpers + initialization)
- src/mir/builder/exprs.rs: metadata_ctx.set_current_span()
- src/mir/builder/exprs_peek.rs: metadata_ctx.current_span()
- src/mir/builder/if_form.rs: metadata_ctx.current_span()
- src/mir/builder/phi.rs: metadata_ctx.current_span()
- src/mir/builder/stmts.rs: metadata_ctx.set_current_span()
- src/mir/builder/utils.rs: metadata_ctx.current_span()
- src/mir/loop_api.rs: metadata_ctx.current_span()
- src/mir/region/observer.rs: metadata_ctx.push/pop_region()
- src/mir/utils/phi_helpers.rs: metadata_ctx.current_span()

## Tests
- cargo build --release: SUCCESS (1m 10s)
- cargo test --release --lib: 1029 PASS, 4 FAIL (pre-existing)
- Deprecation warnings: 469 → 435 (-34 warnings)

## Verification
 No direct access to removed fields (grep count: 0)
 No sync helper calls (grep count: 0)
 Build success
 MetadataContext is now complete SSOT (二重管理解消)

Phase 2 Progress: 1/7 contexts complete (MetadataContext )

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-15 22:44:38 +09:00
81d79161e4 feat(mir): Phase 136 Step 2/7 - CoreContext extraction complete
Extract core ID generation fields from MirBuilder to improve organization:
- value_gen: ValueIdGenerator
- block_gen: BasicBlockIdGenerator
- next_binding_id: u32 (Phase 74)
- temp_slot_counter: u32
- debug_join_counter: u32

Implementation:
- Created src/mir/builder/core_context.rs (215 lines)
- Added core_ctx field to MirBuilder as SSOT
- Deprecated legacy fields with backward compat
- ID allocation methods use core_ctx and sync legacy fields
- Added next_block_id() helper, replaced 30+ block_gen.next() calls

Testing:
- cargo build --release: SUCCESS (193 warnings expected)
- cargo test --release --lib: 1004/1004 PASS (+7 tests)
- phase135_trim_mir_verify.sh: PASS
- phase132_exit_phi_parity.sh: 3/3 PASS

Progress: 2/7 Context extractions complete (TypeContext + CoreContext)

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-15 20:10:36 +09:00
32a91e31ac feat(joinir): Phase 200-B/C/D capture analysis + Phase 201-A reserved_value_ids infra
Phase 200-B: FunctionScopeCaptureAnalyzer implementation
- analyze_captured_vars_v2() with structural loop matching
- CapturedEnv for immutable function-scope variables
- ParamRole::Condition for condition-only variables

Phase 200-C: ConditionEnvBuilder extension
- build_with_captures() integrates CapturedEnv into ConditionEnv
- fn_body propagation through LoopPatternContext to Pattern 2

Phase 200-D: E2E verification
- capture detection working for base, limit, n etc.
- Test files: phase200d_capture_minimal.hako, phase200d_capture_in_condition.hako

Phase 201-A: MirBuilder reserved_value_ids infrastructure
- reserved_value_ids: HashSet<ValueId> field in MirBuilder
- next_value_id() skips reserved IDs
- merge/mod.rs sets/clears reserved IDs around JoinIR merge

Phase 201: JoinValueSpace design document
- Param/Local/PHI disjoint regions design
- API: alloc_param(), alloc_local(), reserve_phi()
- Migration plan for Pattern 1-4 lowerers

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-09 18:32:03 +09:00
8cd9729375 feat(runtime): Phase 87 CoreBoxId/CoreMethodId 箱化完了
ハードコード文字列から型安全な enum への箱化により、
Box名・メソッド名管理を完全にコンパイル時検証可能に。

主な実装:
- CoreBoxId enum 定義(19個)
  - core_required: 6個(String, Integer, Bool, Array, Map, Console)
  - core_optional: 9個(Float, Null, File, Path, Regex, Math, Time, Json, Toml)
  - 特殊型: 4個(Function, Result, Method, Missing)
- CoreMethodId enum 定義(30個)
  - 各 Box のメソッドを型安全に管理
  - 引数数、戻り値型情報を統合
- is_reserved_type() を CoreBoxId ベースにリファクタリング
- infer_boxcall_return_type() を CoreMethodId ベースに改良(75行 → 25行、67%削減)

検証結果:
- テスト:  11/11 passed(新規追加)
- ビルド:  成功(0エラー)
- 型安全性:  タイポ不可能

効果:
- SSOT 確立(src/runtime/core_box_ids.rs に一元化)
- コンパイル時検証(実行時エラー → コンパイルエラー)
- 保守性向上(変更箇所の一元化)
- IDE 支援(enum 補完可能)

ドキュメント:
- core_boxes_design.md 作成(Phase 87 完全仕様)
- Phase 85 README 更新(Phase 87 セクション追加)

Phase 15.5「Everything is Plugin」アーキテクチャ基盤完成

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 22:22:32 +09:00
345cc855a0 feat(mir): Phase 84-4-B完了 - BoxCall型情報登録で Case D 100%解決
🎉 歴史的成果: Case D panic 9件 → 0件(100%削減達成!)

Phase 84-4-B実装内容:
- infer_boxcall_return_type() 新規実装(utils.rs)
- ビルトイン Box メソッド戻り値型のハードコード推論
  - StringBox, IntegerBox, BoolBox, ArrayBox, MapBox
  - Result-like Box (isOk/getValue) - QMark 対応
  - Stage1CliBox - 暫定 Unknown 登録
- emit_box_or_plugin_call() の型登録ロジック強化
  - plugin_method_sigs フォールバック追加
  - NYASH_BOXCALL_TYPE_TRACE=1 でデバッグ出力

技術的詳細:
- 責務: PhiTypeResolver が依存する base 定義型情報を生成
- 型生成レイヤー完成(Const → BoxCall → Await)
- 箱理論: 型伝播レイヤーと型生成レイヤーの完全分離

検証結果:
- Case D panic: 9件 → 0件 
- ベースライン: 503 passed, 31 failed(変化なし)
- FALLBACK_DISABLED: 497 passed, 37 failed(Case D panic なし!)

残存 4件の状況:
- await/qmark/stage1_cli テストが FAILED(panic ではない)
- 型推論は成功(Call 命令生成)
- テスト期待値が古い(PluginInvoke 想定)

Phase 84-4-C:
- Await 型情報登録は不要(BoxCall 経路で解決済み)
- Phase 84完了条件達成済み

関連:
- Phase 84-3: PhiTypeResolver 実装(9件 → 4件)
- Phase 84-2: CopyTypePropagator 実装(12件 → 9件)
- Phase 84-1: Const 型注釈(15件 → 12件)

🎯 Phase 84 完全達成: 型推論システムの完全箱化成功!
2025-12-02 20:28:19 +09:00
466e636af6 Span trace utilities and runner source hint 2025-11-24 14:17:02 +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
39f5256c18 📊 Phase 25.1l: Region観測レイヤー骨格 + スコープ契約設計理解
**Region Box統一理論の実装開始**

新規追加:
- src/mir/region/mod.rs: Region/RefSlotKind型定義
- src/mir/region/observer.rs: Region観測レイヤー
- docs/development/roadmap/phases/phase-25.1l/: 設計ドキュメント

主要概念:
- Region Box = Function/Loop/If の統一箱
- RefSlotKind = GC管理用スロット種別(Strong/Weak/Borrowed/NonRef)
- 観測専用(NYASH_REGION_TRACE=1で動作、挙動変更なし)

設計理解の深化:
- ValueId(40)問題 = LoopForm v2スコープ契約違反の症状
- 根本解決 = Region観測で無名一時値のスコープまたぎを検出
- 箱理論3原則: 境界明確化/差し替え可能/段階的移行

関連議論:
- ChatGPT提案: Region統一理論でGC/寿命管理の基盤構築
- SlotRegistry: 変数の単一真実源(SSOT)
- 階層構造: FunctionRegion → LoopRegion → IfRegion

次のステップ:
- Phase 1: Region観測(現在)- 非破壊的追加
- Phase 2: メタデータ出力(MIR JSON拡張)
- Phase 3: GC統合(retain/release挿入)

テスト追加:
- lang/src/compiler/tests/stageb_mini_driver.hako
- tools/test_loopssa_breakfinder_slot.sh

Build:  全警告は既存のもの
Tests: 既存テスト全て緑維持
2025-11-19 02:44:40 +09:00
d3cbc71c9b feat(mir): Phase 25.1f完了 - Conservative PHI + ControlForm観測レイヤー
🎉 Conservative PHI Box理論による完全SSA構築

**Phase 7-B: Conservative PHI実装**
- 片方branchのみ定義変数に対応(emit_void使用)
- 全変数にPHI生成(Conservative Box理論)
- Stage-1 resolver全テスト緑化(3/3 PASS)

**Phase 25.1f: ControlForm観測レイヤー**
- LoopShape/IfShape/ControlForm構造定義
- Loop/If統一インターフェース実装
- debug_dump/debug_validate機能追加
- NYASH_CONTROL_FORM_TRACE環境変数対応

**主な変更**:
- src/mir/builder/phi.rs: Conservative PHI実装
- src/mir/control_form.rs: ControlForm構造(NEW)
- src/mir/loop_builder.rs: LoopForm v2デフォルト化

**テスト結果**:
 mir_stage1_using_resolver_min_fragment_verifies
 mir_stage1_using_resolver_full_collect_entries_verifies
 mir_parserbox_parse_program2_harness_parses_minimal_source

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: ChatGPT <chatgpt@openai.com>
2025-11-18 18:56:35 +09:00
4f3831c07b fix(builder): 修正案A実装 - emit_unified_call↔emit_box_or_plugin_call再入防止
🎯 無限再帰の構造的防止(修正案A採用)

## 問題
Phase 2リファクタリング後、stack overflow発生:
```
emit_unified_call (emit.rs:15)
  ↓
emit_box_or_plugin_call (utils.rs:136)
  ↓ line 190
emit_unified_call (emit.rs:15) ← 無限ループ!
```

## 修正案A: 再入防止ガード(採用理由)
- B(Math機能削除): 対処療法で仕様削減 
- C("birth"特別扱い): 局所的修正で他Boxに波及 
- A(構造的再入防止): 根治的アプローチ 

## 実装内容

### 1. MirBuilder にフラグ追加
```rust
pub(super) in_unified_boxcall_fallback: bool
```
役割: RouterPolicyでRoute::BoxCallと決めたフォールバック中マーク

### 2. emit_unified_call 側修正 (emit.rs)
```rust
// Route::BoxCall のときだけ
self.in_unified_boxcall_fallback = true;
emit_box_or_plugin_call(...);
self.in_unified_boxcall_fallback = false;
```

### 3. emit_box_or_plugin_call 側修正 (utils.rs)
```rust
if use_unified_env
    && matches!(route, Route::Unified)
    && !self.in_unified_boxcall_fallback  // ← 追加
{
    // emit_unified_call(...) への再入を防止
}
```

## 構造的改善
- RouterPolicyBox の決定を優先
- emit_unified_call → emit_box_or_plugin_call の一方向化
- 「上位の決定を尊重する」という明確なルール

## 残存課題
⚠️ まだstack overflowが残存(別の再帰ルート存在の可能性)
→ 次のステップでstack trace解析が必要

## テスト状況
- Test 1 (Direct VM):  成功
- Test 2 (Stage-B):  stack overflow(別ルート調査中)
- Test 3 (MIR verification):  成功

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 17:31:09 +09:00
6bfaaaf445 debug(mir): add comprehensive receiver tracing and block overwrite protection
This commit investigates ValueId(21) undefined error in Stage-B compilation.

Changes:
- src/mir/builder/builder_calls.rs:
  - Add NYASH_DEBUG_PARAM_RECEIVER=1 trace for method call receivers
  - Track variable_map lookups and ValueId mismatches
  - Log receiver origin and current_block context

- src/mir/builder/utils.rs:
  - Fix start_new_block() to avoid overwriting existing blocks
  - Check if block exists before calling add_block()
  - Prevents Copy instructions from being lost

- src/mir/function.rs:
  - Add warning log when replacing existing block
  - Helps detect block overwrite issues

- lang/src/mir/builder/ (Hako files):
  - Add debug prints for method lowering paths
  - These were not used (Stage-B uses Rust MIR Builder)
  - Kept for future Hako MIR Builder debugging

Key Discovery:
- Stage-B compilation uses Rust MIR Builder, not Hako MIR Builder
- ValueId(21) is undefined receiver in StageBArgsBox.resolve_src/1
- MIR shows: call_method ParserBox.length() [recv: %21] but %21 has no definition
- Likely caused by LocalSSA Copy emission failure or block overwrite

Next: Fix LocalSSA to ensure receiver Copy is properly emitted and preserved

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 09:39:26 +09:00
e2d061d113 fix(loop/phi): loop header pinned receiver PHI の未定義ValueId解消
**問題**: TestArgs.process/1 で `Invalid value: use of undefined value ValueId(14)`
- loop条件でのmethod call(args.length())がpin_to_slotで pinned receiver作成
- header PHIが未定義のValueIdを参照していた

**根本原因**:
- pinned変数のheader PHI作成時、`preheader_value = value` として
  header blockで作成された値を使用
- 正しくは preheader block の元値を参照すべき

**修正内容**:

1. **find_copy_source ヘルパー追加** (src/mir/loop_builder.rs:50-80)
   - Copy命令を遡ってpreheaderの元値を特定
   - NYASH_LOOP_TRACE=1 でデバッグ出力

2. **pinned変数PHI作成ロジック強化** (lines 368-410)
   - NEW pinned変数: find_copy_source()で正しいpreheader値取得
   - INHERITED pinned変数: pre_vars_snapshot から値取得
   - PHI inputs に正しい preheader_value を設定

3. **LoopFormOps::new_value修正** (lines 1122-1127)
   - value_gen.next() → next_value_id() に統一
   - 関数ローカルアロケーター使用でValueId整合性確保

4. **next_value_id可視性拡大** (src/mir/builder/utils.rs:33)
   - pub(super) → pub(crate) でループビルダーから使用可能に

**テスト結果**:
 Test1 (Direct VM): PASS
 Test3 (MIR verify): PASS
⚠️ Test2 (Stage-B): ValueId(17)はif-block PHI問題(別issue)

**残存問題**:
- Stage-B の ValueId(17) はループ前のif-blockで発生
- if-block PHI reassignment (%0 = phi [%2, bb3]) の構造的問題
- 別タスクで対処予定

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 06:31:31 +09:00
82b6c4e834 Phase 25.1b: VM undefined-value diagnostics and builder SSA helpers 2025-11-17 03:19:03 +09:00
eadde8d1dd fix(mir/builder): use function-local ValueId throughout MIR builder
Phase 25.1b: Complete SSA fix - eliminate all global ValueId usage in function contexts.

Root cause: ~75 locations throughout MIR builder were using global value
generator (self.value_gen.next()) instead of function-local allocator
(f.next_value_id()), causing SSA verification failures and runtime
"use of undefined value" errors.

Solution:
- Added next_value_id() helper that automatically chooses correct allocator
- Fixed 19 files with ~75 occurrences of ValueId allocation
- All function-context allocations now use function-local IDs

Files modified:
- src/mir/builder/utils.rs: Added next_value_id() helper, fixed 8 locations
- src/mir/builder/builder_calls.rs: 17 fixes
- src/mir/builder/ops.rs: 8 fixes
- src/mir/builder/stmts.rs: 7 fixes
- src/mir/builder/emission/constant.rs: 6 fixes
- src/mir/builder/rewrite/*.rs: 10 fixes
- + 13 other files

Verification:
- cargo build --release: SUCCESS
- Simple tests with NYASH_VM_VERIFY_MIR=1: Zero undefined errors
- Multi-parameter static methods: All working

Known remaining: ValueId(22) in Stage-B (separate issue to investigate)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 00:48:18 +09:00
dd65cf7e4c builder+vm: unify method calls via emit_unified_call; add RouterPolicy trace; finalize LocalSSA/BlockSchedule guards; docs + selfhost quickstart
- Unify standard method calls to emit_unified_call; route via RouterPolicy and apply rewrite::{special,known} at a single entry.\n- Stabilize emit-time invariants: LocalSSA finalize + BlockSchedule PHI→Copy→Call ordering; metadata propagation on copies.\n- Known rewrite default ON (userbox only, strict guards) with opt-out flag NYASH_REWRITE_KNOWN_DEFAULT=0.\n- Expand TypeAnnotation whitelist (is_digit_char/is_hex_digit_char/is_alpha_char/Map.has).\n- Docs: unified-method-resolution design note; Quick Reference normalization note; selfhosting/quickstart.\n- Tools: add tools/selfhost_smoke.sh (dev-only).\n- Keep behavior unchanged for Unknown/core/user-instance via BoxCall fallback; all tests green (quick/integration).
2025-09-28 20:38:09 +09:00
e442e5f612 builder: copy renamed pin slots across blocks and update user vars to new ids at block entry (fix recv undefined across loop headers) 2025-09-28 12:38:15 +09:00
a472938916 builder: pin receiver in emit_box_or_plugin_call to prevent undefined recv across blocks (Patch‑A) 2025-09-28 12:32:26 +09:00
510f4cf523 builder/vm: stabilize json_lint_vm under unified calls
- Fix condition_fn resolution: Value call path + dev safety + stub injection
- VM bridge: handle Method::birth via BoxCall; ArrayBox push/get/length/set direct bridge
- Receiver safety: pin receiver in method_call_handlers to avoid undefined use across blocks
- Local vars: materialize on declaration (use init ValueId; void for uninit)
- Prefer legacy BoxCall for Array/Map/String/user boxes in emit_box_or_plugin_call (stability-first)
- Test runner: update LLVM hint to llvmlite harness (remove LLVM_SYS_180_PREFIX guidance)
- Docs/roadmap: update CURRENT_TASK with unified default-ON + guards

Note: NYASH_DEV_BIRTH_INJECT_BUILTINS=1 can re-enable builtin birth() injection during migration.
2025-09-28 12:19:49 +09:00
cb236b7f5a json(vm): fix birth dispatch; unify constructor naming (Box.birth/N); JsonNode factories return JsonNodeInstance; quick: enable heavy JSON with probe; builder: NYASH_BUILDER_DEBUG_LIMIT guard; json_query_min(core) harness; docs/tasks updated 2025-09-27 08:45:25 +09:00
fcf8042b06 builder: propagate value_types and value_origin_newbox in pin_to_slot (stabilize rewrite/type inference across pin/PHI) 2025-09-26 14:47:52 +09:00
cf4b615afb mir/vm: SSA pin+PHI + short-circuit; user-defined method calls → functions; entry single-pred PHIs; compare-operand pin; VM BoxCall fallback to InstanceBox methods; docs: update CURRENT_TASK (plan + acceptance)
- Lower And/Or to branch+PHI (RHS not evaluated)
- Always slotify compare operands (dominance safety)
- Insert single-predecessor PHIs at then/else/short-circuit entries
- pin_to_slot now logs (NYASH_PIN_TRACE) and participates in PHI
- Rewrite user-defined instance method calls to Box.method/Arity (builder)
- VM fallback: BoxCall on InstanceBox dispatches to lowered functions with 'me'+args
- Keep plugin/BoxCall path for core boxes (String/Array/Map)
- Add env-gated pre-pin for if/loop (NYASH_MIR_PREPIN)
- CURRENT_TASK: add SSA/userbox plan, debug steps, acceptance criteria
2025-09-26 05:28:20 +09:00
6e1bf149fc builder: pre-pin comparison operands in if_form and loop_builder (lower_if_in_loop/build_loop) to slots; utils: pin_to_slot pub(crate) and entry materialize for pinned slots only; continue JSON VM debug 2025-09-26 04:17:56 +09:00
d052f9dc97 feat: using構文完全実装&json_native大幅進化
## 🎉 using構文の完全実装(ChatGPT作業)
-  **include → using移行完了**: 全ファイルでusing構文に統一
  - `local X = include` → `using "path" as X`
  - 約70ファイルを一括変換
-  **AST/パーサー/MIR完全対応**: using専用処理実装
  - ASTNode::Using追加
  - MIRビルダーでの解決処理
  - include互換性も維持

## 🚀 json_native実装進化(ChatGPT追加実装)
-  **浮動小数点対応追加**: is_float/parse_float実装
-  **配列/オブジェクトパーサー実装**: parse_array/parse_object完成
-  **エスケープ処理強化**: Unicode対応、全制御文字サポート
-  **StringUtils大幅拡張**: 文字列操作メソッド多数追加
  - contains, index_of_string, split, join等
  - 大文字小文字変換(全アルファベット対応)

## 💡 MIR SIMD & ハイブリッド戦略考察
- **MIR15 SIMD命令案**: SimdLoad/SimdScan等の新命令セット
- **C ABIハイブリッド**: ホットパスのみC委託で10倍速化可能
- **並行処理でyyjson超え**: 100KB以上で2-10倍速の可能性
- **3層アーキテクチャ**: Nyash層/MIR層/C ABI層の美しい分離

## 📊 技術的成果
- using構文により名前空間管理が明確化
- json_nativeが実用レベルに接近(完成度25%→40%)
- 将来的にyyjsonの70%速度達成可能と判明

ChatGPT爆速実装×Claude深い考察の完璧な協働!

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 00:41:56 +09:00
73b90a7c28 feat: スモークテストv2実装&Phase 15.5後のプラグイン対応
Phase 15.5 Core Box削除後の新テストシステム構築:

## 実装内容
- スモークテストv2システム完全実装(3段階プロファイル)
- 共通ライブラリ(test_runner/plugin_manager/result_checker/preflight)
- インタープリター層完全削除(約350行)
- PyVM重要インフラ特化保持戦略(JSON v0ブリッジ専用)
- nyash.tomlパス修正(13箇所、プラグイン正常ロード確認)

## 動作確認済み
- 基本算術演算(+, -, *, /)
- 制御構文(if, loop, break, continue)
- 変数代入とスコープ
- プラグインロード(20個の.soファイル)

## 既知の問題
- StringBox/IntegerBoxメソッドが動作しない
  - オブジェクト生成は成功するがメソッド呼び出しでエラー
  - Phase 15.5影響でプラグイン実装が不完全な可能性

## ドキュメント
- docs/development/testing/smoke-tests-v2.md 作成
- docs/reference/pyvm-usage-guidelines.md 作成
- CODEX_QUESTION.md(Codex相談用)作成

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-24 09:30:42 +09:00
868519c691 cleanup: MIRレガシーコード71行削除でJSON作業準備完了
Phase 15.5準備として、MIRコードベースの大規模クリーンアップを実施。
JSON centralization作業前の環境整備が完了しました。

削除内容(71行):
- コメントアウトされたimport文: 2行
- 不要なlegacy/removedコメント: 9行
- movedコメント大規模整理: 56行
- 開発用debugコード(eprintln!): 4行

安全性確認:
- 統一Call実装(NYASH_MIR_UNIFIED_CALL=1): 正常動作
- Legacy実装(NYASH_MIR_UNIFIED_CALL=0): 後方互換性維持
- JSON出力: mir_call形式で正常生成

Phase 15(80k→20k行削減)への貢献: 約0.09%

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-24 04:09:23 +09:00
28c721d82b feat: Phase 15.5 llvmlite革命達成!真の統一Call基盤完成
6種類Callee完全統一でデリゲート方式→真の統一実装へ革命的移行。
モックルート回避確立でセルフホスティング基盤強化完了。

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-24 02:11:59 +09:00
adbb0201a9 chore(fmt): add legacy stubs and strip trailing whitespace to unblock cargo fmt 2025-09-17 07:43:07 +09:00
40db299bab refactor: Gemini/ChatGPT collaborative refactoring + build fixes
Major changes:
- Split runner module: 1358→580 lines (via Gemini)
- Create new modules: dispatch.rs, selfhost.rs, pipeline.rs, pipe_io.rs
- Fix build errors from incomplete method migrations
- Add warning to CLAUDE.md about JIT/Cranelift not working
- Create interpreter.rs mode module
- Refactor loop builder into separate module

Build status:
-  Executable builds successfully
-  Basic execution works (tested with print)
- ⚠️ 106 warnings remain (to be cleaned up next)
- ⚠️ execute_mir_mode still in mod.rs (needs further migration)

Note: ChatGPT correctly fixed runner.execute_mir_mode() calls
that I incorrectly changed to super::modes::mir::

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-16 03:54:44 +09:00
ab76cd35fa refactor: 大規模なモジュールを分割し、コードの構造を改善
runner, mir/builder, backend/llvm の各モジュールが肥大化していたため、責務ごとにファイルを分割し、見通しを改善するリファクタリングを実施。

### `runner`
- `mod.rs` に集中していたロジックを、以下のモジュールに分割:
    - `tasks.rs`: `nyash.toml` のタスク実行処理
    - `build.rs`: AOTビルドパイプラインの実装
    - `pipeline.rs`: `using` の解決など、パイプライン中のユーティリティ
    - `demos.rs`: デモの実行処理

### `mir/builder`
- `if/else` 文のPHIノード生成ロジックを `stmts.rs` から `phi.rs` へ切り出し。
- `utils.rs` にあったPHI関連のヘルパーも `phi.rs` に集約。
- ASTから自由変数を収集するロジックを `vars.rs` へ切り出し。

### `backend/llvm/compiler/codegen`
- 巨大だった `lower_one_function` 関数を、`function.rs` モジュールとして分離。
- `sanitize_symbol` などのヘルパー関数を `utils.rs` へ移動。
2025-09-16 01:54:00 +09:00
fb2d8e37d5 🎉 Phase 11.8/12.7: MIR Core-13 完全実装 + 糖衣構文ドキュメント更新
主要な変更:
- MIR Core-13命令セット確定(Load/Store削除の革命的設計)
  - Const, BinOp, Compare(値・計算)
  - Jump, Branch, Return, Phi(制御)
  - Call, BoxCall, ExternCall(呼び出し)
  - TypeOp, Safepoint, Barrier(メタ)
- Phase 12.7糖衣構文ドキュメント整理(超圧縮重視、可逆変換保証)
- MIRビルダーのモジュール分割完了
- vtableテストスイート拡充
- AI協調開発ツール追加(並列リファクタリング支援)

詳細:
- src/mir/instruction_introspection.rs: core13_instruction_names()追加
- MIRビルダー分割: decls.rs, exprs_*.rs, fields.rs
- plugin_loader_v2: errors.rs, host_bridge.rs分離
- 論文用データ: mir13-final.md作成

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-04 11:34:15 +09:00
53d88157aa Phase 12: 統一TypeBox ABI実装開始 - ChatGPT5による極小コアABI基盤構築
- TypeBox ABI雛形: メソッドスロット管理システム追加
- Type Registry: Array/Map/StringBoxの基本メソッド定義
- Host API: C ABI逆呼び出しシステム実装
- Phase 12ドキュメント整理: 設計文書統合・アーカイブ化
- MIR Builder: クリーンアップと分離実装完了

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 05:04:56 +09:00