Commit Graph

263 Commits

Author SHA1 Message Date
af11c6855b 🚀 Start Phase 15.3: Nyash compiler MVP implementation
Major milestone:
- Set up apps/selfhost-compiler/ directory structure
- Implement basic Nyash compiler in Nyash (CompilerBox)
- Stage-1: Basic arithmetic parser (int/string/+/-/*/括弧/return)
- JSON v0 output compatible with --ny-parser-pipe
- Runner integration with NYASH_USE_NY_COMPILER=1 flag
- Comprehensive smoke tests for PHI/Bridge/Stage-2

Technical updates:
- Updated CLAUDE.md with Phase 15.3 status and MIR14 details
- Statement separation policy: newline-based with minimal ASI
- Fixed runaway ny-parser-pipe processes (CPU 94.9%)
- Clarified MIR14 as canonical instruction set (not 13/18)
- LoopForm strategy: PHI auto-generation during reverse lowering

Collaborative development:
- ChatGPT5 implementing compiler skeleton
- Codex provided LoopForm PHI generation guidance
- Claude maintaining documentation and coordination

🎉 セルフホスティングの歴史的一歩!自分自身をコンパイルする日が近いにゃ!

Co-Authored-By: ChatGPT <noreply@openai.com>
2025-09-15 01:21:37 +09:00
5cad0ab20c 🔧 Fix peek expression terminator issues and add ternary operator support
- Fix LLVM IR terminator missing in peek expression entry blocks
- Add proper jump instructions between peek blocks
- Implement ternary operator (? :) as syntactic sugar for peek
- Update Python LLVM externcall handling for improved compatibility
- Add comprehensive test cases for peek and ternary expressions
- Update language guide with ternary operator documentation

ChatGPTが頑張って修正してくれたにゃ!🐱

Co-Authored-By: ChatGPT <noreply@openai.com>
2025-09-14 20:30:38 +09:00
3ba96d9a03 🚀 feat: Multiple improvements for Nyash parser and LLVM backend
Parser improvements:
- Added expression statement fallback in parse_statement() for flexible syntax
- Fixed ternary operator to use PeekExpr instead of If AST (better lowering)
- Added peek_token() check to avoid ?/?: operator conflicts

LLVM Python improvements:
- Added optional ESC_JSON_FIX environment flag for string concatenation
- Improved PHI generation with better default handling
- Enhanced substring tracking for esc_json pattern

Documentation updates:
- Updated language guide with peek expression examples
- Added box theory diagrams to Phase 15 planning
- Clarified peek vs when syntax differences

These changes enable cleaner parser implementation for self-hosting,
especially for handling digit conversion with peek expressions instead
of 19-line if-else chains.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-14 19:16:32 +09:00
4c0e6726e3 🔧 refactor(llvm-py): Fix resolver PHI handling and add trace improvements
Changes to resolver.py:
- Improved PHI value tracking in _value_at_end_i64() (lines 268-285)
- Added trace logging for snap hits with PHI detection
- Fixed PHI placeholder reuse logic to preserve dominance
- PHI values now returned directly from snapshots when valid

Changes to llvm_builder.py:
- Fixed externcall instruction parsing (line 522: 'func' instead of 'name')
- Improved block snapshot tracing (line 439)
- Added PHI incoming metadata tracking (lines 316-376)
- Enhanced definition tracking for lifetime hints

This should help debug the string carry=0 issue in esc_dirname_smoke where
PHI values were being incorrectly coerced instead of preserved.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-14 16:25:21 +09:00
3e07763af8 docs: update CURRENT_TASK with Box Theory PHI plan (defer/finalize) and MIR v0.5 type meta; add parity tooling and PyVM scaffolding
impl(pyvm/llvmlite):
- add tools/parity.sh; tools/pyvm_runner.py; src/llvm_py/pyvm/*
- emit string const as handle type in MIR JSON; add dst_type hints
- unify '+' to concat_hh with from_i64/from_i8_string bridges; console print via to_i8p_h
- add runtime bridges: nyash.box.from_i64, nyash.string.to_i8p_h

tests:
- add apps/tests/min_str_cat_loop (minimal repro for string cat loop)
2025-09-14 04:51:33 +09:00
2a9aa5368d harness(llvm/py): fix PHI/dominance via Resolver-only; per-pred localization and constant GEPs; stabilize Main.esc_json/1, dirname/1, node_json/3; docs: add NYASH_LLVM_TRACE_FINAL and Resolver-only invariants
- Resolver-only reads across BBs; remove vmap fallbacks
- Create PHIs at block start; insert casts in preds before terminators
- Re-materialize int in preds to satisfy dominance (add/zext/trunc)
- Use constant GEP for method strings to avoid order dependency
- Order non-PHI lowering to preserve producer→consumer dominance
- Update docs: RESOLVER_API.md, LLVM_HARNESS.md
- compare_harness_on_off: ON/OFF exits match; linking green
2025-09-13 19:49:03 +09:00
1d6fab4eda 📚 Phase 15計画を詳細化・更新: Python/llvmlite正式採用とプラグイン全方向ビルド戦略
 主な更新内容:
- Python/llvmlite実装の正式採用を明記(開発速度10倍、~2400行)
- プラグイン全方向ビルド戦略(.so/.o/.a同時生成)で単一EXE生成可能に
- 各実装の予想コード量を具体化(パーサー800行、MIR Builder 2500行、VM 5000行)
- 循環依存問題の解決を明記(nyrtがC ABI経由で提供)
- 現実的なスケジュール調整(2025年9月~2026年3月)

🎉 最新進捗:
- dep_tree_min_string.nyashオブジェクト生成成功(10.4KB)
- LLVM verifier green - dominance違反解決
- Resolver patternでSSA安全性確保

🚀 次のマイルストーン:
- Python/llvmliteでEXE生成パイプライン完成
- nyash-llvm-compiler分離設計
- NyashパーサーMVP実装開始

Everything is Boxの究極形が、ついに実現へ!

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-13 15:37:58 +09:00
3bef7e8608 feat(llvm): Implement Context Boxing pattern for cleaner APIs
Major improvement to reduce parameter explosion (15+ args → 3-4 contexts):
- Add LowerFnCtx/BlockCtx for grouping related parameters
- Add lightweight StrHandle/StrPtr newtypes for string safety
- Implement boxed API wrappers for boxcall/fields/invoke
- Add dev checks infrastructure (NYASH_DEV_CHECK_DISPATCH_ONLY_PHI)

Key achievements:
- lower_boxcall: 16 args → 7 args via boxed API
- fields/invoke: Similar parameter reduction
- BuilderCursor discipline enforced throughout
- String handle invariant: i64 across blocks, i8* only at call sites

Status:
- Internal migration in progress (fields → invoke → marshal)
- Full cutover pending due to borrow checker constraints
- dep_tree_min_string.o generation successful (sealed=ON)

Next: Complete internal migration before flipping to boxed APIs

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-13 00:07:38 +09:00
d5af6b1d48 docs: Create AI-assisted compiler development paper structure
Added paper-g-ai-assisted-compiler folder documenting:
- Week-long LLVM backend development with AI assistance
- Key insights from PHI/SSA struggles to Resolver API solution
- Development log capturing the chaotic reality
- Abstract in both English and Japanese

Key quote: 'I don't remember anymore' - capturing the authentic
experience of intensive AI-assisted development where the process
itself becomes the research data.

This represents potentially the first fully documented case of
building a compiler backend primarily through AI assistance.
2025-09-12 20:27:32 +09:00
c04b0c059d feat(llvm): Major refactor - BuilderCursor全域化 & Resolver API導入
Added:
- Resolver API (resolve_i64) for unified value resolution with per-block cache
- llvmlite harness (Python) for rapid PHI/SSA verification
- Comprehensive LLVM documentation suite:
  - LLVM_LAYER_OVERVIEW.md: Overall architecture and invariants
  - RESOLVER_API.md: Value resolution strategy
  - LLVM_HARNESS.md: Python verification harness

Updated:
- BuilderCursor applied to ALL lowering paths (externcall/newbox/arrays/maps/call)
- localize_to_i64 for dominance safety in strings/compare/flow
- NYASH_LLVM_DUMP_ON_FAIL=1 for debug IR output

Key insight: LoopForm didn't cause problems, it just exposed existing design flaws:
- Scattered value resolution (now unified via Resolver)
- Inconsistent type conversion placement
- Ambiguous PHI wiring responsibilities

Next: Wire Resolver throughout, achieve sealed=ON green for dep_tree_min_string
2025-09-12 20:06:48 +09:00
043472c170 docs(papers): Update MIR13 to MIR14 and create SSA construction paper
Major changes:
- Update all MIR13 references to MIR14 throughout paper-a-mir13-ir-design/
- Add evolution history: 27 → 13 → 14 instructions (UnaryOp restoration)
- Create new paper-d-ssa-construction/ for SSA implementation struggles
- Add PAPER_INDEX.md consolidating ChatGPT5's 3-paper analysis

MIR14 updates:
- README.md: Add instruction evolution timeline
- abstract.md: Emphasize practical balance over pure minimalism
- main-paper*.md: Update titles and core concepts
- MIR13_CORE13_SPEC.md: Add UnaryOp to instruction list
- chapters/01-introduction.md: Reframe as "14-Instruction Balance"
- RENAME_NOTE.md: Document folder naming consideration

SSA paper structure:
- README.md: Paper overview and positioning
- current-struggles.md: Raw implementation challenges
- technical-details.md: BuilderCursor, Sealed SSA, type normalization
- abstract.md: English/Japanese abstracts

LoopForm experiments continue in parallel (minor adjustments to detection).

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 15:58:20 +09:00
a530b454f6 📋 Phase 15セルフホスティング戦略整理 & LLVM改善
## Phase 15戦略整理
- セルフホスティング戦略2025年9月版を作成
- Phase 15.2-15.5の段階的実装計画を明確化
  - 15.2: LLVM独立化(nyash-llvm-compiler crate)
  - 15.3: Nyashコンパイラ実装でセルフホスト達成
  - 15.4: VM層のNyash化(革新的アプローチ)
  - 15.5: ABI移行(LLVM完成後)
- ROADMAP.mdの優先順位調整、README.md更新

## LLVM改善(ChatGPT5協力)
- BuilderCursor::with_block改善(状態の適切な保存/復元)
- seal_blockでの挿入位置管理を厳密化
- 前任ブロックのみ処理、重複PHI incoming防止
- defined_in_blockトラッキングで値のスコープ管理

## 洞察
- コンパイル不要のセルフホスティング実現可能
- VM層をNyashで書けば即座実行可能
- Phase 22(Nyash LLVMコンパイラ)への道筋

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 14:59:03 +09:00
53a869136f 📚 ABI統合ドキュメント整理 & LLVM BuilderCursor改善
## ABI関連
- docs/reference/abi/ABI_INDEX.md 作成(統合インデックス)
- 分散していたABI/TypeBoxドキュメントへのリンク集約
- CLAUDE.mdに「ABI統合インデックス」リンク追加
- ABI移行タイミング詳細検討(LLVM完成後のPhase 15.5推奨)

## LLVM改善(ChatGPT5協力)
- BuilderCursor導入でposition管理を構造化
- emit_return/jump/branchをcursor経由に統一
- PHI/terminator問題への対策改善
- より明確なbasic block位置管理

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 14:12:54 +09:00
187edfcaaf 🏗️ Phase 22: Revolutionary Nyash LLVM Compiler vision
- Create Phase 22 documentation for Nyash-based LLVM compiler
- C++ thin wrapper (20-30 functions) + Nyash implementation (100-200 lines)
- Gemini & Codex discussions: Both AIs confirm technical feasibility
- Build time revolution: 5-7min → instant changes
- Code reduction: 2,500 lines → 100-200 lines (95% reduction\!)
- User insight: 'Why worry about memory leaks for a 3-second batch process?'
- Ultimate 'Everything is Box' philosophy: Even the compiler is a Box\!

🌟 Vision: After Phase 15 LLVM stabilization, we can build anything\!
2025-09-12 04:03:43 +09:00
5bee46b51f docs(phase-15): Add LLVM native EXE generation strategy
## Phase 15 Documentation Updates

### ROADMAP.md
- Added LLVM Native EXE Generation as item 5 in "Next (small boxes)"
- Covers complete pipeline from MIR to executable
- Includes plan for separate nyash-llvm-compiler crate

### New Document: llvm-exe-strategy.md
- Detailed implementation strategy for LLVM backend EXE generation
- Architecture for separating LLVM compiler into independent crate
- Reduces main build time from 5-7min to 1-2min
- Enables parallel builds in CI/CD

### README.md Updates
- Updated EXE generation section to prioritize LLVM over Cranelift
- Added links to new LLVM strategy document
- Clarified current implementation status

## Benefits
- Faster development cycles with reduced build times
- Better CI/CD performance through parallelization
- Clear separation of concerns between core and LLVM compiler

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 02:02:23 +09:00
b120e4a26b refactor(llvm): Complete Call instruction modularization + Phase 21 organization
## LLVM Call Instruction Modularization
- Moved MirInstruction::Call lowering to separate instructions/call.rs
- Follows the principle of one MIR instruction per file
- Call implementation was already complete, just needed modularization

## Phase 21 Documentation
- Moved all Phase 21 content to private/papers/paper-f-self-parsing-db/
- Preserved AI evaluations from Gemini and Codex
- Academic paper potential confirmed by both AIs
- Self-parsing AST database approach validated

## Next Steps
- Continue monitoring ChatGPT5's LLVM improvements
- Consider creating separate nyash-llvm-compiler crate when LLVM layer is stable
- This will reduce build times by isolating LLVM dependencies

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 01:58:07 +09:00
40d0cac0f1 feat(llvm): Complete function call system implementation by ChatGPT5
Major improvements to LLVM backend function call infrastructure:

## Key Changes

### Function Call System Complete
- All MIR functions now properly lowered to LLVM (not just entry)
- Function parameter binding to LLVM arguments implemented
- ny_main() wrapper added for proper entry point handling
- Callee resolution from ValueId to function symbols working

### Call Instruction Analysis
- MirInstruction::Call was implemented but system was incomplete
- Fixed "rhs missing" errors caused by undefined Call return values
- Function calls now properly return values through the system

### Code Modularization (Ongoing)
- BoxCall → instructions/boxcall.rs ✓
- ExternCall → instructions/externcall.rs ✓
- Call remains in mod.rs (to be refactored)

### Phase 21 Documentation
- Added comprehensive AI evaluation from Gemini and Codex
- Both AIs confirm academic paper potential for self-parsing AST DB approach
- "Code as Database" concept validated as novel contribution

Co-authored-by: ChatGPT5 <noreply@openai.com>

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 01:45:00 +09:00
4f4c6397a9 🏗️ Refactor: Major LLVM codegen modularization + Phase 15 docs cleanup + Phase 21 DDD concept
## LLVM Codegen Refactoring (by ChatGPT5)
- Split massive boxcall.rs into focused submodules:
  - strings.rs: String method optimizations (concat, length)
  - arrays.rs: Array operations (get, set, push, length)
  - maps.rs: Map operations (get, set, has, size)
  - fields.rs: getField/setField handling
  - invoke.rs: Tagged invoke implementation
  - marshal.rs: Helper functions for marshaling
- Improved code organization and maintainability
- No functional changes, pure refactoring

## Phase 15 Documentation Cleanup
- Restructured phase-15 folder:
  - implementation/: Technical implementation docs
  - planning/: Planning and sequence docs
  - archive/: Redundant/old content
- Removed duplicate content (80k→20k line reduction mentioned 5 times)
- Converted all .txt files to .md for consistency
- Fixed broken links in README.md
- Removed redundant INDEX.md

## Phase 21: Database-Driven Development (New)
- Revolutionary concept: Source code in SQLite instead of files
- Instant refactoring with SQL transactions
- Structured management of boxes, methods, dependencies
- Technical design with security considerations
- Vision: World's first DB-driven programming language

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 00:35:11 +09:00
89e6fbf010 feat(llvm): Comprehensive LLVM backend improvements by ChatGPT
Major enhancements to LLVM code generation and type handling:

1. String Operations:
   - Added StringBox length fast-path (length/len methods)
   - Converts i8* to handle when needed for len_h call
   - Consistent handle-based string operations

2. Array/Map Fast-paths:
   - ArrayBox: get/set/push/length operations
   - MapBox: get/set/has/size with handle-based keys
   - Optimized paths for common collection operations

3. Field Access:
   - getField/setField implementation with handle conversion
   - Proper i64 handle to pointer conversions

4. NewBox Improvements:
   - StringBox/IntegerBox pass-through optimizations
   - Fallback to env.box.new when type_id unavailable
   - Support for dynamic box creation

5. Documentation:
   - Added ARCHITECTURE.md for overall design
   - Added EXTERNCALL.md for external call specs
   - Added LOWERING_LLVM.md for LLVM lowering rules
   - Added PLUGIN_ABI.md for plugin interface

6. Type System:
   - Added UserBox type registration in nyash_box.toml
   - Consistent handle (i64) representation across system

Results: More robust LLVM code generation with proper type handling

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-11 22:30:26 +09:00
0ac22427e5 docs: Architecture decision - Box/ExternCall boundary design
Documented the architectural decision for Nyash runtime design:

1. Core boxes (String/Integer/Array/Map/Bool) built into nyrt
   - Essential for self-hosting
   - Available at boot without plugin loader
   - High performance (no FFI overhead)

2. All other boxes as plugins (File/Net/User-defined)
   - Extensible ecosystem
   - Clear separation of concerns

3. Minimal ExternCall (only 5 functions)
   - print/error (output)
   - panic/exit (process control)
   - now (time)

Key principle: Everything goes through BoxCall interface
- No special fast paths
- Unified architecture
- "Everything is Box" philosophy maintained

This design balances self-hosting requirements with architectural purity.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-11 20:58:18 +09:00
40489a3c97 feat(debug): Add debug logging to console.log_handle for plugin investigation
- Added eprintln! debug messages to trace handle values
- Helps investigate why plugin return values display as blank
- Part of ongoing LLVM backend plugin return value investigation

Related to issue where print(c.get()) shows blank output

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-11 06:03:21 +09:00
e114f9bfe3 fix(llvm): Implement handle-based console.log functions for plugin return values
- Add nyash.console.log_handle(i64) -> i64 family functions to nyrt
- Replace invalid int-to-pointer conversion with proper handle-based calls
- Fix bool(i1) -> i64 type conversion in LLVM compiler
- Resolve LLVM function verification errors
- Enable plugin method execution without NYASH_LLVM_ALLOW_BY_NAME
- Merge codex TLV fixes for plugin return value handling (2000+ lines)

Technical Details:
- Root cause: build_int_to_ptr(handle_value, i8*, "arg_i2p") treated
  handle IDs as memory addresses (invalid operation)
- Solution: Direct i64 handle passing to nyrt functions with proper
  handle registry lookup and to_string_box() conversion
- Type safety: Added proper i1/i32/i64 -> i64 conversion handling

Status: Console.log type errors resolved, plugin return value display
still under investigation

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-11 00:21:11 +09:00
92bbfd90bc Add Gemini compiler discussion summary
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-10 19:58:58 +09:00
370e725926 docs: Update current task and loop builder SSA bug details
- Update dates to 2025-09-08
- Document loop builder SSA scope management issue
- Add notes about continue/break implementation status
- Fix birth/init consistency in CLAUDE.md
2025-09-09 09:31:39 +09:00
62246c76e3 docs(current_task): add structured tasks under docs/current_task/{main,llvm,self_current_task} and unignore path 2025-09-08 11:35:30 +09:00
f22082f67c resolve: apply stashed using/module + deps bridge; remove conflict markers in runner/mod.rs 2025-09-08 04:35:50 +09:00
17225c29f7 tests: add parser/vm bitops tests; docs: update cheatsheet and language guide for bitwise ops and shift; note Arrow(>>) removal
- Add src/tests/parser_bitops_test.rs and vm_bitops_test.rs
- Update tokenizer unit test to expect SHIFT_RIGHT
- Update quick-reference and language guide to document &,|,^,<<,>> and Arrow deprecation

Known: one unrelated test failing (consolebox println TLV vs typebox) pre-existing.
2025-09-08 04:04:19 +09:00
2578120b23 docs(phases): restore Phase 18/19 from history (3826089)\n\n- Phase 18: LifeBox principles and LoopForm design doc\n- Phase 19: LoopForm <-> Core-13 PoC and zero-cost CI plan\n\nRecovered from commit 3826089; reintroduce missing directories under docs/development/roadmap/phases/ 2025-09-08 03:30:35 +09:00
864473336e merge: resolve conflicts (prefer cranelift-dev for Core-13 defaults; drop modules/using, add env.local/env.box shims) 2025-09-08 01:28:39 +09:00
4a8691014f docs/private: convert to git submodule (nyash-private-docs) (#128)
Co-authored-by: Tomoaki <tomoaki@example.com>
2025-09-07 08:49:36 +09:00
b8bdb867d8 Merge selfhosting-dev into main (Core-13 pure CI/tests + LLVM bridge) (#126)
* WIP: sync before merging origin/main

* fix: unify using/module + build CLI; add missing helper in runner; build passes; core smokes green; jit any.len string now returns 3

* Apply local changes after merging main; keep docs/phase-15 removed per main; add phase-15.1 docs and tests

* Remove legacy docs/phase-15/README.md to align with main

* integration: add Core-13 pure CI, tests, and minimal LLVM execute bridge (no docs) (#125)

Co-authored-by: Tomoaki <tomoaki@example.com>

---------

Co-authored-by: Selfhosting Dev <selfhost@example.invalid>
Co-authored-by: Tomoaki <tomoaki@example.com>
2025-09-07 07:36:15 +09:00
d62114c705 Core-13 pure: add CI workflows, VM e2e tests, LLVM parity bridge (minimal); do not touch private docs 2025-09-07 07:28:53 +09:00
07350c5dd9 windows/llvm: add build script (build_nyash_llvm.ps1); fix nyash.toml LLVM task paths; add screenshots dir placeholder; add which dep 2025-09-06 22:08:58 +09:00
07f270b966 aot: enable plugin invokes in ObjectBuilder (tagged by-id), add generic NewBox birth via nyash.instance.birth_name_u64x2; egui(plugin): cross-platform run + debug logs; docs: WSL Wayland→X11 troubleshooting and one‑shot scripts; CURRENT_TASK + READMEs updated (JIT runtime sealed). 2025-09-06 16:18:46 +09:00
7d88c04c0e wip(phase15): AOT修正作業中 - Nyプラグインと標準ライブラリ実装
Phase 15のAOT/ネイティブビルド修正作業を継続中。
ChatGPTによるstd実装とプラグインシステムの改修を含む。

主な変更点:
- apps/std/: string.nyashとarray.nyashの標準ライブラリ追加
- apps/smokes/: stdライブラリのスモークテスト追加
- プラグインローダーv2の実装改修
- BoxCallのハンドル管理改善
- JIT hostcall registryの更新
- ビルドスクリプト(build_aot.sh, build_llvm.sh)の調整

まだ修正作業中のため、一部の機能は不完全な状態。

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-06 06:24:08 +09:00
020990463d feat(papers): AI先生レビューを反映した論文改訂版
MIR13論文とNyash言語論文について、Gemini先生とCodex先生の
詳細レビューを受けて大幅改訂:

MIR13論文の改善:
- 「完全な」→「実用的な」に表現を適正化
- 57命令からの削減経緯を議論セクションに追加
- Python/Go/Rustとの絶対性能比較を追加
- BoxCallのオーバーヘッド分析を追加
- ランタイムシステムの役割を明記
- 関連研究に比較表とメッセージパッシング系譜を追加

Nyash言語論文の改善:
- マイクロベンチマーク追加(Python/Lua/Swift比較)
- HTTPサーバーベンチマーク追加
- メモリ管理モデル比較表追加
- 循環参照への対応方針(weak参照導入計画)を明記
- MIR13との相互作用を説明
- 関連研究の比較表で位置付けを明確化

また、AI先生方のレビュー記録をアーカイブに保存。
開発は2025-08-09開始、約1ヶ月での成果。

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-06 05:48:56 +09:00
e323120c59 phase15: update CLAUDE.md with Phase 15 enhancements from AGENTS.md
- Add JIT Self-Host Quickstart section for Phase 15
- Include important flags reference (plugins, parsers, debugging)
- Add Codex async workflow documentation for parallel tasks
- Update test execution with Phase 15 smoke tests
- Improve build time notes (JIT vs LLVM)
- Align with current Phase 15 progress and tooling

🎉 Bootstrap (c0→c1→c1') test confirmed working\!

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-05 15:18:13 +09:00
a2b89fae7e phase15: update CLAUDE.md and sync with current progress
- Update phase indicator to Phase 15 (Self-Hosting)
- Update documentation links to Phase 15 resources
- Reflect completion of R1-R5 tasks and ongoing work
- Fix CURRENT_TASK.md location to root directory

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-05 13:29:17 +09:00
e05a385524 phase15: add Cranelift AOT design, LinkerBox spec, and smoke skeleton docs (handoff) 2025-09-05 05:49:26 +09:00
19f775c34d feat(phase12.7): 糖衣構文Phase 12.7-B完了 + 自律型AI開発システム制御機能
🚀 Phase 12.7-B: ChatGPT5糖衣構文(基本実装完了)
- パイプライン演算子(|>)実装
- セーフアクセス(?.)とデフォルト値(??)実装
- sugar gateによる段階的有効化機能
- 糖衣構文テストスイート追加

🤖 自律型AI開発システム改善
- codex-async-notify.sh: タスク制御指示追加
  - "下の箱を積み過ぎないように先に進んでください"
  - "フェーズが終わったと判断したら止まってください"
- プロセス数表示機能の改善(count_running_codex_display)
- 自動停止機能が正常動作(Phase 12.7-C前で停止確認)

📚 ドキュメント更新
- Paper 13: 自律型AI協調開発システムの革新性を文書化
- ANCP可逆マッピング仕様追加
- nyfmt PoC(フォーマッター)計画追加

🧱 箱理論の体現
- 74k行のコードベース(Phase 15で20k行を目指す)
- ANCP適用で最終的に6k行相当を狙う
- 世界最小の実用コンパイラへの道

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-05 05:16:21 +09:00
02d36cc2cb feat: Windows native Egui demo success + Paper C unified strategy
🎉 MAJOR MILESTONE: First successful Windows native Egui application
- Fixed stack overflow in plugin initialization
- Windows Egui demo running with JIT host-bridge
- Complete plugin system validation

📚 Paper C: Unified revolution strategy
- Three-paper approach: MIR13 + BoxCall + Unified
- ChatGPT5's "one representation, two execution" concept
- Complete experimental benchmark planning

🛠️ Technical achievements:
- nyash.exe with Cranelift JIT on Windows
- nyash_egui_plugin.dll (4.39MB) successful build
- VM + JIT + host-bridge integration working
- apps/egui-hello/main.nyash: open→uiLabel→run→close pipeline

🔬 Research foundation:
- docs/papers/active/paper-c-unified-revolution/ complete structure
- Benchmark experiments ready for Load/Store elimination validation
- AI-collaborative development methodology documented

This represents Phase 15 self-hosting technical foundation completion.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-04 12:15:30 +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
4e824fa00e Phase 12.7文法改革: ドキュメント文法統一 + VMリファクタリング準備
🌟 Phase 12.7文法改革に基づくドキュメント更新
- init {} → field: TypeBox 個別フィールド宣言形式
- init() → birth() コンストラクタ統一
- pack() → 廃止(birth()に統一)
- public {}/private {} → 個別フィールド修飾子
- override → 廃止(メソッド定義はシンプルに)

📚 更新したドキュメント
- CLAUDE.md: メイン開発ガイド
- docs/quick-reference/syntax-cheatsheet.md: 構文早見表
- docs/reference/language/LANGUAGE_REFERENCE_2025.md: 言語リファレンス
- docs/development/roadmap/phases/phase-15/README.md: Phase 15計画

🔧 VMリファクタリング準備
- vm_methods.rs: VMメソッド呼び出しの分離
- plugin_loader.rs → plugin_loader/: ディレクトリ構造化
- mir/builder/exprs.rs: 式ビルダー分離

📝 新規ドキュメント追加
- 論文戦略・ロードマップ
- Phase 15セルフホスティング準備資料
- Codex Androidセットアップガイド

ビルドは正常に通ることを確認済み!🎉

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-04 06:27:39 +09:00
6488b0542e Phase 12.7完了 + ChatGPT5によるVMリファクタリング
## 📚 Phase 12.7 ドキュメント整理
- ChatGPT5作成のANCP Token仕様書v1を整備
- フォルダ構造を機能別に再編成:
  - ancp-specs/ : ANCP圧縮技法仕様
  - grammar-specs/ : 文法改革仕様
  - implementation/ : 実装計画
  - ai-feedback/ : AIアドバイザーフィードバック
- 各フォルダにREADME.md作成で導線改善

## 🔧 ChatGPT5によるVMリファクタリング
- vm_instructions.rs (1927行) をモジュール分割:
  - boxcall.rs : Box呼び出し処理
  - call.rs : 関数呼び出し処理
  - extern_call.rs : 外部関数処理
  - function_new.rs : FunctionBox生成
  - newbox.rs : Box生成処理
  - plugin_invoke.rs : プラグイン呼び出し
- VM実行をファイル分割で整理:
  - vm_state.rs : 状態管理
  - vm_exec.rs : 実行エンジン
  - vm_control_flow.rs : 制御フロー
  - vm_gc.rs : GC処理
- plugin_loader_v2もモジュール化

##  新機能実装
- FunctionBox呼び出しのVM/MIR統一進捗
- ラムダ式のFunctionBox変換テスト追加
- 関数値の直接呼び出し基盤整備

次ステップ: ANCPプロトタイプ実装開始(Week 1)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-04 03:41:02 +09:00
7455c9ec97 Phase 12.7: Nyash文法革命とANCP 90%圧縮技法の発見 - 文法改革完了とFunctionBox実装 2025-09-03 20:03:45 +09:00
6d79d7d3ac grammar(P0): add peek expression, continue statement, and field type annotations acceptance; add sample apps and interpreter path\n\n- tokenizer: add keywords (peek, continue), tokens (=> as FatArrow, :: as DoubleColon), keep >> as Arrow\n- parser: implement peek as expression (literal patterns only, else required), add continue; accept field 'name: Type' (discard type P0)\n- interpreter: evaluate PeekExpr; add Continue control flow handling\n- apps: add peek-demo, loop-continue-demo, adjust field-decl demo; use ConsoleBox instead of env.console for interpreter backend\n- docs: CURRENT_TASK updated earlier for Phase 12.7 P0\n\nNOTE: peek arms currently single-expression (no block expr yet); VM/MIR path does not lower PeekExpr yet; use --backend interpreter for demos 2025-09-03 15:26:15 +09:00
ceb22b6c18 gui: add EguiBox TypeBox plugin (Windows egui stub)\n\n- plugins: add nyash-egui-plugin with TypeBox (resolve/invoke_id), Windows path for real window via eframe; stub on other OS\n- apps: add apps/egui-hello sample (open→uiLabel→run→close)\n- loader: improve Windows DLL resolution (target triples: x86_64/aarch64 msvc) and lib→dll mapping\n- tests: expand TypeBox vs TLV diff tests up to FileBox; all green\n- docs: update CURRENT_TASK checklist (diff tests completed)\n- config: nyash.toml add EguiBox (type_id=70), plugin registry and methods 2025-09-03 13:58:52 +09:00
773256380d Phase 12: VM/JIT identical execution tests + host API slot routing
ChatGPT5による統一実行パス実装:
- VM/JIT同一実行テスト追加(Array/Map/String/Instance)
- host_api slot経由呼び出し(NYASH_JIT_HOST_BRIDGE=1)
- extern_registry拡張(console系メソッドslot登録)
- CI: vm-jit-identical.yml(STRICT/非STRICT両系テスト)
- InstanceBox getField/setField slot 1,2統一

技術的改善:
- JIT: ops_ext委譲による統一メソッド解決
- VM: vtable/PIC/名前ベースフォールバック階層
- host_bridge: TLV encode/decode BoxRef対応
- C ABI: nyrt_host_api.h外部公開ヘッダー

テスト追加:
- identical_exec_collections: Array/Map操作一致
- identical_exec_instance: ユーザー定義Box一致
- identical_exec_string: StringBox操作一致
- host_reverse_slot: 逆引きslot解決テスト

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 09:12:39 +09:00
0722b410a1 Phase 12: add wasm_v2 scaffold (unified vtable slots), expand host by-slot (Map/String), STRICT extern diagnostics, identical-exec console.log test, and CLAUDE_WASM_TASK handoff 2025-09-03 05:41:33 +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