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>
This commit is contained in:
16
src/backend/llvm/compiler/codegen/instructions/string_ops.rs
Normal file
16
src/backend/llvm/compiler/codegen/instructions/string_ops.rs
Normal file
@ -0,0 +1,16 @@
|
||||
use inkwell::values::{IntValue, PointerValue};
|
||||
|
||||
/// Lightweight newtypes for string representations used in lowering.
|
||||
/// StrHandle crosses basic blocks; StrPtr is created at call sites within the same block.
|
||||
pub struct StrHandle<'ctx>(pub IntValue<'ctx>);
|
||||
pub struct StrPtr<'ctx>(pub PointerValue<'ctx>);
|
||||
|
||||
impl<'ctx> StrHandle<'ctx> {
|
||||
#[inline]
|
||||
pub fn as_i64(&self) -> IntValue<'ctx> { self.0 }
|
||||
}
|
||||
|
||||
impl<'ctx> From<PointerValue<'ctx>> for StrPtr<'ctx> {
|
||||
fn from(p: PointerValue<'ctx>) -> Self { Self(p) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user