feat(phase21.5/22.1): MirBuilder JsonFrag refactor + FileBox ring-1 + registry tests
Phase 21.5 (AOT/LLVM Optimization Prep) - FileBox ring-1 (core-ro) provider: priority=-100, always available, no panic path - src/runner/modes/common_util/provider_registry.rs: CoreRoFileProviderFactory - Auto-registers at startup, eliminates fallback panic structurally - StringBox fast path prototypes (length/size optimization) - Performance benchmarks (C/Python/Hako comparison baseline) Phase 22.1 (JsonFrag Unification) - JsonFrag.last_index_of_from() for backward search (VM fallback) - Replace hand-written lastIndexOf in lower_loop_sum_bc_box.hako - SentinelExtractorBox for Break/Continue pattern extraction MirBuilder Refactor (Box → JsonFrag Migration) - 20+ lower_*_box.hako: Box-heavy → JsonFrag text assembly - MirBuilderMinBox: lightweight using set for dev env - Registry-only fast path with [registry:*] tag observation - pattern_util_box.hako: enhanced pattern matching Dev Environment & Testing - Dev toggles: SMOKES_DEV_PREINCLUDE=1 (point-enable), HAKO_MIR_BUILDER_SKIP_LOOPS=1 - phase2160: registry opt-in tests (array/map get/set/push/len) - content verification - phase2034: rc-dependent → token grep (grep -F based validation) - run_quick.sh: fast smoke testing harness - ENV documentation: docs/ENV_VARS.md Test Results ✅ quick phase2034: ALL GREEN (MirBuilder internal patterns) ✅ registry phase2160: ALL GREEN (array/map get/set/push/len) ✅ rc-dependent tests → content token verification complete ✅ PREINCLUDE policy: default OFF, point-enable only where needed Technical Notes - No INCLUDE by default (maintain minimalism) - FAIL_FAST=0 in Bring-up contexts only (explicit dev toggles) - Tag-based route observation ([mirbuilder/min:*], [registry:*]) - MIR structure validation (not just rc parity) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -140,6 +140,35 @@ pub extern "C" fn nyash_string_lastindexof_ss(s: *const i8, needle: *const i8) -
|
||||
}
|
||||
}
|
||||
|
||||
// Exported as: nyash.string.length_si(i8* s, i64 mode) -> i64
|
||||
// mode: 0 = byte length (UTF-8 bytes), 1 = char length (Unicode scalar count)
|
||||
#[export_name = "nyash.string.length_si"]
|
||||
pub extern "C" fn nyash_string_length_si(s: *const i8, mode: i64) -> i64 {
|
||||
use std::ffi::CStr;
|
||||
if s.is_null() {
|
||||
return 0;
|
||||
}
|
||||
let cs = unsafe { CStr::from_ptr(s) };
|
||||
// Safe UTF-8 conversion; on failure, fall back to byte length scan
|
||||
if let Ok(st) = cs.to_str() {
|
||||
if mode == 1 { // char count
|
||||
return st.chars().count() as i64;
|
||||
} else { // byte length
|
||||
return st.as_bytes().len() as i64;
|
||||
}
|
||||
}
|
||||
// Fallback: manual byte scan to NUL
|
||||
let mut len: i64 = 0;
|
||||
unsafe {
|
||||
let mut p = s;
|
||||
while *p != 0 {
|
||||
len += 1;
|
||||
p = p.add(1);
|
||||
}
|
||||
}
|
||||
len
|
||||
}
|
||||
|
||||
// Exported as: nyash.string.to_i8p_h(i64 handle) -> i8*
|
||||
#[export_name = "nyash.string.to_i8p_h"]
|
||||
pub extern "C" fn nyash_string_to_i8p_h(handle: i64) -> *mut i8 {
|
||||
|
||||
Reference in New Issue
Block a user