Phase 183 Implementation: - Added is_var_used_in_condition() helper for AST variable detection - Implemented LoopBodyLocal filtering in TrimLoopLowerer - Created 4 test files for P1/P2 patterns - Added 5 unit tests for variable detection Test Fixes: - Fixed test_is_outer_scope_variable_pinned (BasicBlockId import) - Fixed test_pattern2_accepts_loop_param_only (literal node usage) Refactoring: - Unified pattern detection documentation - Consolidated CarrierInfo initialization - Documented LoopScopeShape construction paths 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
53 lines
1.2 KiB
Rust
53 lines
1.2 KiB
Rust
// C‑ABI shim (PoC). These functions are no‑ops for 20.36/20.37.
|
||
// Kept tiny and isolated. Linkage names match include/nyrt.h.
|
||
|
||
#[no_mangle]
|
||
pub extern "C" fn nyrt_init() -> i32 {
|
||
0
|
||
}
|
||
|
||
#[no_mangle]
|
||
pub extern "C" fn nyrt_teardown() {}
|
||
|
||
#[no_mangle]
|
||
pub extern "C" fn nyrt_load_mir_json(_json_text: *const ::std::os::raw::c_char) -> u64 {
|
||
1
|
||
}
|
||
|
||
#[no_mangle]
|
||
pub extern "C" fn nyrt_exec_main(_module_handle: u64) -> i32 {
|
||
0
|
||
}
|
||
|
||
#[no_mangle]
|
||
pub extern "C" fn nyrt_hostcall(
|
||
_name: *const ::std::os::raw::c_char,
|
||
_method: *const ::std::os::raw::c_char,
|
||
_payload_json: *const ::std::os::raw::c_char,
|
||
_out_buf: *mut ::std::os::raw::c_char,
|
||
_out_buf_len: u32,
|
||
) -> i32 {
|
||
0
|
||
}
|
||
|
||
#[cfg(test)]
|
||
mod tests {
|
||
use super::*;
|
||
use std::ffi::CString;
|
||
|
||
#[test]
|
||
fn load_and_exec_noop_returns_zero() {
|
||
// init/teardown are no-ops but should stay callable
|
||
assert_eq!(nyrt_init(), 0);
|
||
|
||
let json = CString::new("{}").expect("CString");
|
||
let handle = nyrt_load_mir_json(json.as_ptr());
|
||
assert_eq!(handle, 1);
|
||
|
||
assert_eq!(nyrt_exec_main(handle), 0);
|
||
|
||
// ensure teardown does not panic even when called after exec
|
||
nyrt_teardown();
|
||
}
|
||
}
|