Commit Graph

9 Commits

Author SHA1 Message Date
77d4fd72b3 phase: 20.49 COMPLETE; 20.50 Flow+String minimal reps; 20.51 selfhost v0/v1 minimal (Option A/B); hv1-inline binop/unop/copy; docs + run_all + CURRENT_TASK -> 21.0 2025-11-06 15:41:52 +09:00
b573c3e5b8 feat: LLVM_SYS_180_PREFIX環境変数削除完了!llvm-harness経路でRust LLVMバインディング不要化達成
🚀 Phase 15.5 MIR Call統一革命 - LLVM環境変数削除フェーズ完了

##  完了内容
- **条件分岐実装**: llvm-harness(デフォルト)はLLVM_SYS_180_PREFIX不要
- **後方互換性維持**: llvm-inkwell-legacy使用時はLLVM_SYS_180_PREFIX必要
- **全ツール統一**: 12個のビルドスクリプト・テストスクリプトを一括更新
- **ドキュメント更新**: ENV_VARS.mdでLLVM feature選択方法を明記

## 🛠️ 更新ファイル
- **コアビルド**: src/runner/build.rs, tools/build_llvm.sh, build_llvm.sh
- **スモークテスト**: tools/llvm_smoke.sh, tools/test/smoke/llvm/ir_phi_empty_check.sh
- **CI設定**: .github/workflows/min-gate.yml
- **Windows版**: build_llvm_wsl.sh, build_llvm_wsl_msvc.sh (cross-compilation)
- **開発ツール**: tools/build_compiler_exe.sh, tools/ny_mir_builder.sh
- **ドキュメント**: docs/development/runtime/ENV_VARS.md

##  技術的成果
- **環境変数削減**: LLVM_SYS_180_PREFIX → 条件付き使用のみ
- **Python LLVM統合**: llvmliteハーネス経路でRust LLVM依存完全除去
- **ビルド簡略化**: デフォルトでllvm-config-18のみ必要
- **動作確認**: tools/llvm_smoke.sh成功 (1648バイト.oファイル生成)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-24 03:28:24 +09:00
5c9213cd03 smokes: add curated LLVM runner; archive legacy smokes; PHI-off unified across Bridge/Builder; LLVM resolver tracing; minimal Throw lowering; config env getters; dev profile and root cleaner; docs updated; CI workflow runs curated LLVM (PHI-on/off) 2025-09-16 23:49:36 +09:00
b9f9e81c72 refactor(llvm): Major progress on codegen modularization by ChatGPT
Major changes:
- Removed 617 lines of duplicate/legacy code from mod.rs (lines 351-967)
- All BoxCall handling now properly delegated to instructions::lower_boxcall
- Updated CURRENT_TASK.md with new findings:
  - String concatenation issue (BinOp type mismatch)
  - Plugin return value smoke test added
  - Clear next steps for fixing return value display

Key improvements:
- Clean separation between dispatch (mod.rs) and implementation (instructions.rs)
- Legacy code marked as unreachable and ready for removal
- Better error visibility with modularized code structure
- llvm_smoke.sh updated with new plugin return value tests

Next steps:
1. Fix BinOp string concatenation type handling
2. Investigate MIR value_types for BoxCall returns
3. Further split lower_boxcall function (still 260+ lines)
2025-09-11 18:16:08 +09:00
1fd37bf14a refactor(llvm): Complete modularization of codegen.rs by Codex
- Split 2522-line codegen.rs into modular structure:
  - mod.rs (1330 lines) - main compilation flow and instruction dispatch
  - instructions.rs (1266 lines) - all MIR instruction implementations
  - types.rs (189 lines) - type conversion and classification helpers
  - helpers.rs retained for shared utilities

- Preserved all functionality including:
  - Plugin return value handling (BoxCall/ExternCall)
  - Handle-to-pointer conversions for proper value display
  - Type-aware return value processing based on MIR metadata
  - All optimization paths (ArrayBox fast-paths, string concat, etc.)

- Benefits:
  - Better code organization and maintainability
  - Easier to locate specific functionality
  - Reduced cognitive load when working on specific features
  - Cleaner separation of concerns

No functional changes - pure refactoring to improve code structure.
2025-09-11 17:51:43 +09:00
c014e78fb4 feat(llvm): Complete plugin system unification and environment variable elimination
🎉 Major Achievement: LLVM Plugin Environment Variable Problem Completely Resolved

##  Completed Major Features:
1. **Plugin Implementation**  - nyash.plugin.invoke_* functions in nyrt library working
2. **Plugin Calls**  - Method calls working without environment variables
3. **Return Value Type Inference Fix**  - Added plugin method type inference to MIR builder
4. **by-id Unification Complete**  - Removed by-name fallback, unified to method_id system
5. **Environment Variable Elimination**  - Removed NYASH_LLVM_ALLOW_BY_NAME=1 requirement
6. **Simple Execution Achieved**  - ./target/release/nyash --backend llvm program.nyash

## 🔧 Technical Changes:

### Core Fixes:
- **src/mir/builder.rs**: Added plugin method return type inference
  - CounterBox.get() -> Integer
  - MathBox.sqrt() -> Float
  - FileBox.read() -> String
  - FileBox.exists() -> Bool

- **src/backend/llvm/compiler.rs**: Removed by-name fallback completely
  - Deleted NYASH_LLVM_ALLOW_BY_NAME environment variable check
  - Removed ~50 lines of fallback logic
  - Unified to method_id-based calls only

### Documentation Updates:
- **CLAUDE.md**: Updated all plugin examples to remove environment variables
- **README.md/README.ja.md**: Removed environment variable documentation
- **tools/llvm_smoke.sh**: Removed NYASH_LLVM_ALLOW_BY_NAME from all test scripts

### Performance & Maintainability:
- **Better Performance**: method_id calls more efficient than by-name lookups
- **Type Safety**: method_id system provides compile-time guarantees
- **Code Simplification**: Removed complex fallback logic
- **User Experience**: No environment variables to remember

## 🧪 Verification:
-  Plugin execution without environment variables
-  method_id injection working: [LLVM] method_id injected: 4-5 places
-  Type inference working: [BUILDER] Type inference: CounterBox get -> Integer
-  Compilation success with LLVM backend

## 🔍 Remaining Investigation:
Plugin return value display issue identified as separate runtime layer problem
(plugin methods execute and side effects work, but return values not displayed in print())

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-10 23:24:02 +09:00
10d6b3059a llvm: inline env.box.new_i64x arg conversion; add bitops tests/smoke; update CURRENT_TASK
- Inline-coerce env.box.new_i64x args to i64 handles (int passthrough, f64 via nyash.box.from_f64, i8* via nyash.box.from_i8_string). Removes closure that caused builder lifetime/borrow issues.
- Add unit test for bitwise/shift ops (VM=48; LLVM emit ok; compile_and_execute returns 48).
- Extend tools/llvm_smoke.sh with optional NYASH_LLVM_BITOPS_SMOKE gate; add apps/tests/ny-llvm-bitops (parser currently lacks &|^<<>> so E2E gated).
- Update CURRENT_TASK.md to reflect P1 progress and test strategy.

Build/test:
- LLVM build: LLVM_SYS_180_PREFIX=/usr/lib/llvm-18 cargo build --release --features llvm
- Unit: cargo test --no-run (env-dependent to run)
- Smoke (optional): NYASH_LLVM_BITOPS_SMOKE=1 ./tools/llvm_smoke.sh
2025-09-08 03:27:52 +09:00
11506cee3b Phase 11-12: LLVM backend initial, semantics layer, plugin unification
Major changes:
- LLVM backend initial implementation (compiler.rs, llvm mode)
- Semantics layer integration in interpreter (operators.rs)
- Phase 12 plugin architecture revision (3-layer system)
- Builtin box removal preparation
- MIR instruction set documentation (26→Core-15 migration)
- Cross-backend testing infrastructure
- Await/nowait syntax support

New features:
- LLVM AOT compilation support (--backend llvm)
- Semantics layer for interpreter→VM flow
- Tri-backend smoke tests
- Plugin-only registry mode

Bug fixes:
- Interpreter plugin box arithmetic operations
- Branch test returns incorrect values

Documentation:
- Phase 12 README.md updated with new plugin architecture
- Removed obsolete NYIR proposals
- Added LLVM test programs documentation

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-01 23:44:34 +09:00
fff9749f47 📚 Reorganize CLAUDE.md: slim down from 916 to 395 lines with proper doc links
- Keep essential information within 500 lines (now 395 lines)
- Maintain important syntax examples and development principles
- Move detailed information to appropriate docs files:
  - Development practices → docs/guides/development-practices.md
  - Testing guide → docs/guides/testing-guide.md
  - Claude issues → docs/tools/claude-issues.md
- Add proper links to all referenced documentation
- Balance between minimal entry point and practical usability
2025-08-31 06:22:48 +09:00