Implemented elegant solution for MapBox as core box with plugin fallback:
1. Core-first Strategy:
- Removed MapBox type_id from nyash_box.toml
- MapBox now uses env.box.new fallback (core implementation)
- Consistent with self-hosting goals
2. Plugin Fallback Option:
- Added NYASH_LLVM_FORCE_PLUGIN_MAP=1 environment variable
- Allows forcing MapBox to plugin path when needed
- Preserves flexibility during transition
3. MIR Type Inference:
- Added MapBox method type inference (size/has/get)
- Ensures proper return type handling
4. Documentation:
- Added core vs plugin box explanation in nyrt
- Clarified the transition strategy
This aligns with Phase 15 goals where basic boxes will eventually
be implemented in Nyash itself for true self-hosting.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
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>
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>
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)
- BoxCall handling now properly delegated to instructions::lower_boxcall
- Removed duplicate code in mod.rs (lines 351+ were unreachable after continue)
- Clean separation between dispatch (mod.rs) and implementation (instructions.rs)
- Preparing for further BoxCall function breakdown
Work in progress - ChatGPT continuing refactoring efforts
- 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.
- Remove unnecessary 'mut' from variable declarations
- Clean up code in boxes/, interpreter/, mir/, backend/, and runtime/
- No functional changes, just cleaner code
- MIR interpreter now converts NyashBox to handles for console methods
- Added debug output to trace handle conversion
- Fixed plugin return values not being displayed
- Part of ongoing investigation into LLVM backend plugin issues
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
- 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>
- Split large compiler.rs into modular components
- Extract plugin signature loading to plugin_sigs.rs
- Extract box type ID loading to box_types.rs
- Preserve all PR #134 type information handling
- Update CURRENT_TASK.md with refactoring completion
- Add plugin host initialization for LLVM mode (fixes method_id injection)
- Add FileBox method_id injection test
- Enhance MIR14 stability test
- Add warning for Mock LLVM implementation
- Create build scripts for JIT/LLVM with proper settings (24 threads, timeout)
- Update CLAUDE.md with build instructions and FileBox test results
Note: FileBox file I/O still not working in LLVM execution (separate issue)
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- 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.
- Tokenizer: add tokens for << >> & | ^ (SHIFT_LEFT/RIGHT, BIT_AND/OR/XOR); keep ||, &&, |>
- Parser: precedence layers for bit ops (| ^ &) and shift (<< >>); remove >> Arrow production
- AST: add BitAnd/BitOr/BitXor/Shr with Display
- MIR builder: map bit ops and Shr to MIR BinaryOp
- Interpreter: implement integer-only bit ops and shifts, mask shift count to 0..63
Compatibility: legacy >> Arrow removed from parser; use |> for pipeline.
- Tokenizer: add SHIFT_LEFT for '<<' (before <= detection)
- Parser: introduce parse_shift() layer; left-associative; only '<<' handled in Phase 1
- AST: add BinaryOperator::Shl and display
- MIR builder: map Shl -> BinaryOp::Shl
- Interpreter: implement Shl in both execution paths (integer-only, type error otherwise)
No change to '>>' (legacy ARROW remains). No runtime gate yet for SHL as it does not collide with existing syntax.