diff --git a/Cargo.toml b/Cargo.toml index 033a8277..fc80cd0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -244,6 +244,10 @@ members = [ exclude = [ "plugins/nyash-file", "plugins/nyash-test-multibox", + # Exclude placeholder/missing crates to keep workspace buildable + "plugins/nyash-aot-plugin", + "plugins/nyash-mirjsonbuildermin-plugin", + "plugins/nyash-set-plugin", ] [profile.release] diff --git a/crates/nyash_kernel/src/encode.rs b/crates/nyash_kernel/src/encode.rs index cd398277..a4c74148 100644 --- a/crates/nyash_kernel/src/encode.rs +++ b/crates/nyash_kernel/src/encode.rs @@ -10,10 +10,10 @@ pub(crate) fn nyrt_encode_from_legacy_at(_buf: &mut Vec, _pos: usize) { /// Simplified encoding for Plugin-First architecture (replaces legacy encoding) pub(crate) fn nyrt_encode_arg_or_legacy(buf: &mut Vec, val: i64, _pos: usize) { - use nyash_rust::jit::rt::handles; + use nyash_rust::runtime::host_handles; // Handle direct values and plugin objects, bypass legacy VM fallback if val > 0 { - if let Some(obj) = handles::get(val) { + if let Some(obj) = host_handles::get(val as u64) { if let Some(bufbox) = obj .as_any() .downcast_ref::() diff --git a/crates/nyash_kernel/src/lib.rs b/crates/nyash_kernel/src/lib.rs index 4ee5967c..fe8aecc9 100644 --- a/crates/nyash_kernel/src/lib.rs +++ b/crates/nyash_kernel/src/lib.rs @@ -10,10 +10,10 @@ pub use plugin::*; // String.len_h(handle) -> i64 #[export_name = "nyash.string.len_h"] pub extern "C" fn nyash_string_len_h(handle: i64) -> i64 { - use nyash_rust::jit::rt::handles; + use nyash_rust::runtime::host_handles as handles; if std::env::var("NYASH_JIT_TRACE_LEN").ok().as_deref() == Some("1") { let present = if handle > 0 { - handles::get(handle).is_some() + handles::get(handle as u64).is_some() } else { false }; @@ -25,7 +25,7 @@ pub extern "C" fn nyash_string_len_h(handle: i64) -> i64 { if handle <= 0 { return 0; } - if let Some(obj) = handles::get(handle) { + if let Some(obj) = handles::get(handle as u64) { if let Some(sb) = obj .as_any() .downcast_ref::() @@ -39,14 +39,14 @@ pub extern "C" fn nyash_string_len_h(handle: i64) -> i64 { // String.charCodeAt_h(handle, idx) -> i64 (byte-based; -1 if OOB) #[export_name = "nyash.string.charCodeAt_h"] pub extern "C" fn nyash_string_charcode_at_h_export(handle: i64, idx: i64) -> i64 { - use nyash_rust::jit::rt::handles; + use nyash_rust::runtime::host_handles as handles; if idx < 0 { return -1; } if handle <= 0 { return -1; } - if let Some(obj) = handles::get(handle) { + if let Some(obj) = handles::get(handle as u64) { if let Some(sb) = obj .as_any() .downcast_ref::() @@ -67,11 +67,11 @@ pub extern "C" fn nyash_string_charcode_at_h_export(handle: i64, idx: i64) -> i6 pub extern "C" fn nyash_string_concat_hh_export(a_h: i64, b_h: i64) -> i64 { use nyash_rust::{ box_trait::{NyashBox, StringBox}, - jit::rt::handles, + runtime::host_handles as handles, }; let to_s = |h: i64| -> String { if h > 0 { - if let Some(o) = handles::get(h) { + if let Some(o) = handles::get(h as u64) { return o.to_string_box().value; } } @@ -80,7 +80,7 @@ pub extern "C" fn nyash_string_concat_hh_export(a_h: i64, b_h: i64) -> i64 { let s = format!("{}{}", to_s(a_h), to_s(b_h)); nyash_rust::runtime::global_hooks::gc_alloc(s.len() as u64); let arc: std::sync::Arc = std::sync::Arc::new(StringBox::new(s)); - let h = handles::to_handle(arc) as i64; + let h = handles::to_handle_arc(arc) as i64; eprintln!("[TRACE] concat_hh -> {}", h); h } @@ -88,10 +88,10 @@ pub extern "C" fn nyash_string_concat_hh_export(a_h: i64, b_h: i64) -> i64 { // String.eq_hh(lhs_h, rhs_h) -> i64 (0/1) #[export_name = "nyash.string.eq_hh"] pub extern "C" fn nyash_string_eq_hh_export(a_h: i64, b_h: i64) -> i64 { - use nyash_rust::jit::rt::handles; + use nyash_rust::runtime::host_handles as handles; let to_s = |h: i64| -> String { if h > 0 { - if let Some(o) = handles::get(h) { + if let Some(o) = handles::get(h as u64) { return o.to_string_box().value; } } @@ -107,11 +107,11 @@ pub extern "C" fn nyash_string_eq_hh_export(a_h: i64, b_h: i64) -> i64 { // String.substring_hii(handle, start, end) -> handle #[export_name = "nyash.string.substring_hii"] pub extern "C" fn nyash_string_substring_hii_export(h: i64, start: i64, end: i64) -> i64 { - use nyash_rust::{box_trait::NyashBox, box_trait::StringBox, jit::rt::handles}; + use nyash_rust::{box_trait::NyashBox, box_trait::StringBox, runtime::host_handles as handles}; if h <= 0 { return 0; } - let s = if let Some(obj) = handles::get(h) { + let s = if let Some(obj) = handles::get(h as u64) { if let Some(sb) = obj.as_any().downcast_ref::() { sb.value.clone() } else { @@ -136,7 +136,7 @@ pub extern "C" fn nyash_string_substring_hii_export(h: i64, start: i64, end: i64 let sub = s.get(st_u.min(s.len())..en_u.min(s.len())).unwrap_or(""); let arc: std::sync::Arc = std::sync::Arc::new(StringBox::new(sub.to_string())); nyash_rust::runtime::global_hooks::gc_alloc(sub.len() as u64); - let nh = handles::to_handle(arc) as i64; + let nh = handles::to_handle_arc(arc) as i64; eprintln!("[TRACE] substring_hii -> {}", nh); nh } @@ -144,9 +144,9 @@ pub extern "C" fn nyash_string_substring_hii_export(h: i64, start: i64, end: i64 // String.lastIndexOf_hh(haystack_h, needle_h) -> i64 #[export_name = "nyash.string.lastIndexOf_hh"] pub extern "C" fn nyash_string_lastindexof_hh_export(h: i64, n: i64) -> i64 { - use nyash_rust::{box_trait::StringBox, jit::rt::handles}; + use nyash_rust::{box_trait::StringBox, runtime::host_handles as handles}; let hay = if h > 0 { - if let Some(o) = handles::get(h) { + if let Some(o) = handles::get(h as u64) { if let Some(sb) = o.as_any().downcast_ref::() { sb.value.clone() } else { @@ -159,7 +159,7 @@ pub extern "C" fn nyash_string_lastindexof_hh_export(h: i64, n: i64) -> i64 { String::new() }; let nee = if n > 0 { - if let Some(o) = handles::get(n) { + if let Some(o) = handles::get(n as u64) { if let Some(sb) = o.as_any().downcast_ref::() { sb.value.clone() } else { @@ -187,7 +187,7 @@ pub extern "C" fn nyash_string_lastindexof_hh_export(h: i64, n: i64) -> i64 { pub extern "C" fn nyash_box_from_i8_string(ptr: *const i8) -> i64 { use nyash_rust::{ box_trait::{NyashBox, StringBox}, - jit::rt::handles, + runtime::host_handles as handles, }; use std::ffi::CStr; if ptr.is_null() { @@ -200,7 +200,7 @@ pub extern "C" fn nyash_box_from_i8_string(ptr: *const i8) -> i64 { }; let arc: std::sync::Arc = std::sync::Arc::new(StringBox::new(s.clone())); nyash_rust::runtime::global_hooks::gc_alloc(s.len() as u64); - let h = handles::to_handle(arc) as i64; + let h = handles::to_handle_arc(arc) as i64; eprintln!("[TRACE] from_i8_string -> {}", h); h } @@ -209,10 +209,10 @@ pub extern "C" fn nyash_box_from_i8_string(ptr: *const i8) -> i64 { // Helper: build a FloatBox and return a handle #[export_name = "nyash.box.from_f64"] pub extern "C" fn nyash_box_from_f64(val: f64) -> i64 { - use nyash_rust::{box_trait::NyashBox, boxes::FloatBox, jit::rt::handles}; + use nyash_rust::{box_trait::NyashBox, boxes::FloatBox, runtime::host_handles as handles}; let arc: std::sync::Arc = std::sync::Arc::new(FloatBox::new(val)); nyash_rust::runtime::global_hooks::gc_alloc(8); - handles::to_handle(arc) as i64 + handles::to_handle_arc(arc) as i64 } // box.from_i64(val) -> handle @@ -221,11 +221,11 @@ pub extern "C" fn nyash_box_from_f64(val: f64) -> i64 { pub extern "C" fn nyash_box_from_i64(val: i64) -> i64 { use nyash_rust::{ box_trait::{IntegerBox, NyashBox}, - jit::rt::handles, + runtime::host_handles as handles, }; let arc: std::sync::Arc = std::sync::Arc::new(IntegerBox::new(val)); nyash_rust::runtime::global_hooks::gc_alloc(8); - handles::to_handle(arc) as i64 + handles::to_handle_arc(arc) as i64 } // env.box.new(type_name: *const i8) -> handle (i64) @@ -233,7 +233,8 @@ pub extern "C" fn nyash_box_from_i64(val: i64) -> i64 { #[export_name = "nyash.env.box.new"] pub extern "C" fn nyash_env_box_new(type_name: *const i8) -> i64 { use nyash_rust::{ - box_trait::NyashBox, jit::rt::handles, runtime::box_registry::get_global_registry, + box_trait::NyashBox, + runtime::{host_handles as handles, box_registry::get_global_registry}, }; use std::ffi::CStr; if type_name.is_null() { @@ -248,12 +249,12 @@ pub extern "C" fn nyash_env_box_new(type_name: *const i8) -> i64 { if ty == "MapBox" { use nyash_rust::boxes::map_box::MapBox; let arc: std::sync::Arc = std::sync::Arc::new(MapBox::new()); - return handles::to_handle(arc) as i64; + return handles::to_handle_arc(arc) as i64; } if ty == "ArrayBox" { use nyash_rust::boxes::array::ArrayBox; let arc: std::sync::Arc = std::sync::Arc::new(ArrayBox::new()); - let h = handles::to_handle(arc) as i64; + let h = handles::to_handle_arc(arc) as i64; if std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") { eprintln!("nyrt: env.box.new ArrayBox -> handle={}", h); } @@ -263,7 +264,7 @@ pub extern "C" fn nyash_env_box_new(type_name: *const i8) -> i64 { match reg.create_box(ty, &[]) { Ok(b) => { let arc: std::sync::Arc = b.into(); - handles::to_handle(arc) as i64 + handles::to_handle_arc(arc) as i64 } Err(_) => 0, } @@ -282,8 +283,7 @@ pub extern "C" fn nyash_env_box_new_i64x( ) -> i64 { use nyash_rust::{ box_trait::{IntegerBox, NyashBox}, - jit::rt::handles, - runtime::box_registry::get_global_registry, + runtime::{host_handles as handles, box_registry::get_global_registry}, }; use std::ffi::CStr; if type_name.is_null() { @@ -298,7 +298,7 @@ pub extern "C" fn nyash_env_box_new_i64x( let mut argv: Vec> = Vec::new(); let push_val = |dst: &mut Vec>, v: i64| { if v > 0 { - if let Some(obj) = handles::get(v) { + if let Some(obj) = handles::get(v as u64) { dst.push(obj.share_box()); return; } @@ -322,7 +322,7 @@ pub extern "C" fn nyash_env_box_new_i64x( match reg.create_box(ty, &argv) { Ok(b) => { let arc: std::sync::Arc = b.into(); - handles::to_handle(arc) as i64 + handles::to_handle_arc(arc) as i64 } Err(_) => 0, } @@ -331,10 +331,10 @@ pub extern "C" fn nyash_env_box_new_i64x( // String.lt_hh(lhs_h, rhs_h) -> i64 (0/1) #[export_name = "nyash.string.lt_hh"] pub extern "C" fn nyash_string_lt_hh_export(a_h: i64, b_h: i64) -> i64 { - use nyash_rust::jit::rt::handles; + use nyash_rust::runtime::host_handles as handles; let to_s = |h: i64| -> String { if h > 0 { - if let Some(o) = handles::get(h) { + if let Some(o) = handles::get(h as u64) { return o.to_string_box().value; } } @@ -350,10 +350,10 @@ pub extern "C" fn nyash_string_lt_hh_export(a_h: i64, b_h: i64) -> i64 { // Any.length_h(handle) -> i64 (Array/String/Map) #[export_name = "nyash.any.length_h"] pub extern "C" fn nyash_any_length_h_export(handle: i64) -> i64 { - use nyash_rust::jit::rt::handles; + use nyash_rust::runtime::host_handles as handles; if std::env::var("NYASH_JIT_TRACE_LEN").ok().as_deref() == Some("1") { let present = if handle > 0 { - handles::get(handle).is_some() + handles::get(handle as u64).is_some() } else { false }; @@ -365,7 +365,7 @@ pub extern "C" fn nyash_any_length_h_export(handle: i64) -> i64 { if handle <= 0 { return 0; } - if let Some(obj) = handles::get(handle) { + if let Some(obj) = handles::get(handle as u64) { if let Some(arr) = obj .as_any() .downcast_ref::() @@ -403,11 +403,11 @@ pub extern "C" fn nyash_any_length_h_export(handle: i64) -> i64 { // Any.is_empty_h(handle) -> i64 (0/1) #[export_name = "nyash.any.is_empty_h"] pub extern "C" fn nyash_any_is_empty_h_export(handle: i64) -> i64 { - use nyash_rust::jit::rt::handles; + use nyash_rust::runtime::host_handles as handles; if handle <= 0 { return 1; } - if let Some(obj) = handles::get(handle) { + if let Some(obj) = handles::get(handle as u64) { if let Some(arr) = obj .as_any() .downcast_ref::() @@ -462,7 +462,7 @@ pub extern "C" fn nyash_instance_birth_name_u64x2_export(lo: i64, hi: i64, len: if let Ok(host_g) = get_global_plugin_host().read() { if let Ok(b) = host_g.create_box(&name, &[]) { let arc: std::sync::Arc = std::sync::Arc::from(b); - let h = nyash_rust::jit::rt::handles::to_handle(arc); + let h = nyash_rust::runtime::host_handles::to_handle_arc(arc) as u64; return h as i64; } } @@ -475,7 +475,7 @@ pub extern "C" fn nyash_instance_birth_name_u64x2_export(lo: i64, hi: i64, len: pub extern "C" fn nyash_string_from_u64x2_export(lo: i64, hi: i64, len: i64) -> i64 { use nyash_rust::{ box_trait::{NyashBox, StringBox}, - jit::rt::handles, + runtime::host_handles as handles, }; let l = if len < 0 { 0 @@ -494,7 +494,7 @@ pub extern "C" fn nyash_string_from_u64x2_export(lo: i64, hi: i64, len: i64) -> let s = String::from_utf8_lossy(&bytes).to_string(); let arc: std::sync::Arc = std::sync::Arc::new(StringBox::new(s.clone())); nyash_rust::runtime::global_hooks::gc_alloc(s.len() as u64); - handles::to_handle(arc) as i64 + handles::to_handle_arc(arc) as i64 } // ✂️ REMOVED: Legacy VM argument processing - replaced by Plugin-First architecture @@ -547,7 +547,7 @@ pub extern "C" fn nyash_string_birth_h_export() -> i64 { if let Ok(host_g) = nyash_rust::runtime::get_global_plugin_host().read() { if let Ok(b) = host_g.create_box("StringBox", &[]) { let arc: std::sync::Arc = std::sync::Arc::from(b); - let h = nyash_rust::jit::rt::handles::to_handle(arc); + let h = nyash_rust::runtime::host_handles::to_handle_arc(arc) as u64; nyash_rust::runtime::global_hooks::gc_alloc(0); return h as i64; } @@ -560,7 +560,7 @@ pub extern "C" fn nyash_integer_birth_h_export() -> i64 { if let Ok(host_g) = nyash_rust::runtime::get_global_plugin_host().read() { if let Ok(b) = host_g.create_box("IntegerBox", &[]) { let arc: std::sync::Arc = std::sync::Arc::from(b); - let h = nyash_rust::jit::rt::handles::to_handle(arc); + let h = nyash_rust::runtime::host_handles::to_handle_arc(arc) as u64; nyash_rust::runtime::global_hooks::gc_alloc(0); return h as i64; } @@ -573,7 +573,7 @@ pub extern "C" fn nyash_console_birth_h_export() -> i64 { if let Ok(host_g) = nyash_rust::runtime::get_global_plugin_host().read() { if let Ok(b) = host_g.create_box("ConsoleBox", &[]) { let arc: std::sync::Arc = std::sync::Arc::from(b); - let h = nyash_rust::jit::rt::handles::to_handle(arc); + let h = nyash_rust::runtime::host_handles::to_handle_arc(arc) as u64; nyash_rust::runtime::global_hooks::gc_alloc(0); return h as i64; } @@ -587,7 +587,7 @@ pub extern "C" fn nyash_array_birth_h_export() -> i64 { let arc: std::sync::Arc = std::sync::Arc::new(nyash_rust::boxes::array::ArrayBox::new()); nyash_rust::runtime::global_hooks::gc_alloc(0); - nyash_rust::jit::rt::handles::to_handle(arc) as i64 + nyash_rust::runtime::host_handles::to_handle_arc(arc) as i64 } // MapBox birth shim for AOT/JIT handle-based creation @@ -596,7 +596,7 @@ pub extern "C" fn nyash_map_birth_h_export() -> i64 { let arc: std::sync::Arc = std::sync::Arc::new(nyash_rust::boxes::map_box::MapBox::new()); nyash_rust::runtime::global_hooks::gc_alloc(0); - nyash_rust::jit::rt::handles::to_handle(arc) as i64 + nyash_rust::runtime::host_handles::to_handle_arc(arc) as i64 } // ---- Process entry (driver) ---- #[cfg(not(test))] @@ -777,8 +777,7 @@ mod tests { use super::*; use nyash_rust::{ box_trait::{NyashBox, StringBox}, - jit::rt::handles, - runtime::plugin_loader_v2::make_plugin_box_v2, + runtime::{host_handles as handles, plugin_loader_v2::make_plugin_box_v2}, }; use std::sync::Arc; @@ -849,16 +848,16 @@ mod tests { fn decode_i32_and_string_returns() { let pb = make_plugin_box_v2("Dummy".into(), 1, 1, fake_i32); let arc: Arc = Arc::new(pb); - let handle = handles::to_handle(arc) as i64; + let handle = handles::to_handle_arc(arc) as i64; let val = nyash_plugin_invoke3_tagged_i64(1, 0, 0, handle, 0, 0, 0, 0, 0, 0, 0, 0); assert_eq!(val, 123); let pb = make_plugin_box_v2("Dummy".into(), 1, 2, fake_str); let arc: Arc = Arc::new(pb); - let handle = handles::to_handle(arc) as i64; + let handle = handles::to_handle_arc(arc) as i64; let h = nyash_plugin_invoke3_tagged_i64(1, 0, 0, handle, 0, 0, 0, 0, 0, 0, 0, 0); assert!(h > 0); - let obj = handles::get(h).unwrap(); + let obj = handles::get(h as u64).unwrap(); let sb = obj.as_any().downcast_ref::().unwrap(); assert_eq!(sb.value, "hi"); } diff --git a/crates/nyash_kernel/src/plugin/array.rs b/crates/nyash_kernel/src/plugin/array.rs index 80590a0c..8c766ce8 100644 --- a/crates/nyash_kernel/src/plugin/array.rs +++ b/crates/nyash_kernel/src/plugin/array.rs @@ -2,14 +2,14 @@ // Exported as: nyash_array_get_h(i64 handle, i64 idx) -> i64 #[no_mangle] pub extern "C" fn nyash_array_get_h(handle: i64, idx: i64) -> i64 { - use nyash_rust::{box_trait::IntegerBox, jit::rt::handles}; + use nyash_rust::{box_trait::IntegerBox, runtime::host_handles as handles}; if std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") { eprintln!("[ARR] get_h(handle={}, idx={})", handle, idx); } if handle <= 0 || idx < 0 { return 0; } - if let Some(obj) = handles::get(handle) { + if let Some(obj) = handles::get(handle as u64) { if let Some(arr) = obj .as_any() .downcast_ref::() @@ -29,14 +29,14 @@ pub extern "C" fn nyash_array_get_h(handle: i64, idx: i64) -> i64 { // Exported as: nyash_array_set_h(i64 handle, i64 idx, i64 val) -> i64 #[no_mangle] pub extern "C" fn nyash_array_set_h(handle: i64, idx: i64, val: i64) -> i64 { - use nyash_rust::{box_trait::IntegerBox, jit::rt::handles}; + use nyash_rust::{box_trait::IntegerBox, runtime::host_handles as handles}; if std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") { eprintln!("[ARR] set_h(handle={}, idx={}, val={})", handle, idx, val); } if handle <= 0 || idx < 0 { return 0; } - if let Some(obj) = handles::get(handle) { + if let Some(obj) = handles::get(handle as u64) { if let Some(arr) = obj .as_any() .downcast_ref::() @@ -67,7 +67,7 @@ pub extern "C" fn nyash_array_set_h(handle: i64, idx: i64, val: i64) -> i64 { pub extern "C" fn nyash_array_push_h(handle: i64, val: i64) -> i64 { use nyash_rust::{ box_trait::{IntegerBox, NyashBox}, - jit::rt::handles, + runtime::host_handles as handles, }; if std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") { eprintln!("[ARR] push_h(handle={}, val={})", handle, val); @@ -75,14 +75,14 @@ pub extern "C" fn nyash_array_push_h(handle: i64, val: i64) -> i64 { if handle <= 0 { return 0; } - if let Some(obj) = handles::get(handle) { + if let Some(obj) = handles::get(handle as u64) { if let Some(arr) = obj .as_any() .downcast_ref::() { // If val is handle, try to use it; otherwise treat as integer let vbox: Box = if val > 0 { - if let Some(o) = handles::get(val) { + if let Some(o) = handles::get(val as u64) { o.clone_box() } else { Box::new(IntegerBox::new(val)) @@ -104,11 +104,11 @@ pub extern "C" fn nyash_array_push_h(handle: i64, val: i64) -> i64 { // Exported as: nyash_array_length_h(i64 handle) -> i64 #[no_mangle] pub extern "C" fn nyash_array_length_h(handle: i64) -> i64 { - use nyash_rust::jit::rt::handles; + use nyash_rust::runtime::host_handles as handles; if handle <= 0 { return 0; } - if let Some(obj) = handles::get(handle) { + if let Some(obj) = handles::get(handle as u64) { if let Some(arr) = obj .as_any() .downcast_ref::() diff --git a/crates/nyash_kernel/src/plugin/birth.rs b/crates/nyash_kernel/src/plugin/birth.rs index 8b94f6a2..fa2e4ab2 100644 --- a/crates/nyash_kernel/src/plugin/birth.rs +++ b/crates/nyash_kernel/src/plugin/birth.rs @@ -14,7 +14,7 @@ pub extern "C" fn nyash_box_birth_h_export(type_id: i64) -> i64 { if let Ok(b) = host_g.create_box(&meta.box_type, &[]) { let arc: std::sync::Arc = std::sync::Arc::from(b); - let h = nyash_rust::jit::rt::handles::to_handle(arc); + let h = nyash_rust::runtime::host_handles::to_handle_arc(arc) as u64; if std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") { println!( "nyrt: birth_h {} (type_id={}) -> handle={}", @@ -58,12 +58,12 @@ pub extern "C" fn nyash_box_birth_i64_export(type_id: i64, argc: i64, a1: i64, a let method_id: u32 = 0; // birth let instance_id: u32 = 0; // static // Build TLV args - use nyash_rust::jit::rt::handles; + use nyash_rust::runtime::host_handles as handles; let nargs = argc.max(0) as usize; let mut buf = nyash_rust::runtime::plugin_ffi_common::encode_tlv_header(nargs as u16); let mut encode_handle = |h: i64| { if h > 0 { - if let Some(obj) = handles::get(h) { + if let Some(obj) = handles::get(h as u64) { if let Some(p) = obj.as_any().downcast_ref::() { let host = nyash_rust::runtime::get_global_plugin_host(); if let Ok(hg) = host.read() { @@ -159,7 +159,7 @@ pub extern "C" fn nyash_box_birth_i64_export(type_id: i64, argc: i64, a1: i64, a invoke_fn, ); let arc: std::sync::Arc = std::sync::Arc::new(pb); - let h = nyash_rust::jit::rt::handles::to_handle(arc); + let h = nyash_rust::runtime::host_handles::to_handle_arc(arc) as u64; if std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") { println!( "nyrt: birth_i64 {} (type_id={}) argc={} -> handle={}", diff --git a/crates/nyash_kernel/src/plugin/console.rs b/crates/nyash_kernel/src/plugin/console.rs index b4516d5c..db0de2dd 100644 --- a/crates/nyash_kernel/src/plugin/console.rs +++ b/crates/nyash_kernel/src/plugin/console.rs @@ -17,9 +17,9 @@ pub extern "C" fn nyash_console_log_export(ptr: *const i8) -> i64 { // Exported as: nyash.console.log_handle(i64 handle) -> i64 #[export_name = "nyash.console.log_handle"] pub extern "C" fn nyash_console_log_handle(handle: i64) -> i64 { - use nyash_rust::jit::rt::handles; + use nyash_rust::runtime::host_handles as handles; eprintln!("DEBUG: handle={}", handle); - if let Some(obj) = handles::get(handle) { + if let Some(obj) = handles::get(handle as u64) { let s = obj.to_string_box().value; println!("{}", s); } else { @@ -36,7 +36,7 @@ pub extern "C" fn nyash_console_warn_handle(handle: i64) -> i64 { return 0; } - if let Some(obj) = nyash_rust::jit::rt::handles::get(handle) { + if let Some(obj) = nyash_rust::runtime::host_handles::get(handle as u64) { let s = obj.to_string_box().value; eprintln!("WARN: {}", s); } else { @@ -52,7 +52,7 @@ pub extern "C" fn nyash_console_error_handle(handle: i64) -> i64 { return 0; } - if let Some(obj) = nyash_rust::jit::rt::handles::get(handle) { + if let Some(obj) = nyash_rust::runtime::host_handles::get(handle as u64) { let s = obj.to_string_box().value; eprintln!("ERROR: {}", s); } else { @@ -68,7 +68,7 @@ pub extern "C" fn nyash_debug_trace_handle(handle: i64) -> i64 { return 0; } - if let Some(obj) = nyash_rust::jit::rt::handles::get(handle) { + if let Some(obj) = nyash_rust::runtime::host_handles::get(handle as u64) { let s = obj.to_string_box().value; eprintln!("TRACE: {}", s); } else { diff --git a/crates/nyash_kernel/src/plugin/future.rs b/crates/nyash_kernel/src/plugin/future.rs index fa74a9ca..ea265d92 100644 --- a/crates/nyash_kernel/src/plugin/future.rs +++ b/crates/nyash_kernel/src/plugin/future.rs @@ -21,7 +21,7 @@ pub extern "C" fn nyash_future_spawn_method_h( let mut invoke: Option< unsafe extern "C" fn(u32, u32, u32, *const u8, usize, *mut u8, *mut usize) -> i32, > = None; - if let Some(obj) = nyash_rust::jit::rt::handles::get(recv_h) { + if let Some(obj) = nyash_rust::runtime::host_handles::get(recv_h as u64) { if let Some(p) = obj.as_any().downcast_ref::() { instance_id = p.instance_id(); real_type_id = p.inner.type_id; @@ -56,7 +56,7 @@ pub extern "C" fn nyash_future_spawn_method_h( } 8 => { if v > 0 { - if let Some(obj) = nyash_rust::jit::rt::handles::get(v) { + if let Some(obj) = nyash_rust::runtime::host_handles::get(v as u64) { if let Some(p) = obj.as_any().downcast_ref::() { // Try common coercions: String/Integer to TLV primitives let host = nyash_rust::runtime::get_global_plugin_host(); @@ -113,7 +113,7 @@ pub extern "C" fn nyash_future_spawn_method_h( // Prepare FutureBox and register handle let fut_box = std::sync::Arc::new(nyash_rust::boxes::future::FutureBox::new()); let handle = - nyash_rust::jit::rt::handles::to_handle(fut_box.clone() as std::sync::Arc); + nyash_rust::runtime::host_handles::to_handle_arc(fut_box.clone() as std::sync::Arc); // Copy data for async task let cap: usize = 512; let tlv = buf.clone(); @@ -245,7 +245,7 @@ pub extern "C" fn nyash_future_spawn_instance3_i64(a0: i64, a1: i64, a2: i64, ar } // Resolve receiver invoke and type id/name let (instance_id, real_type_id, invoke) = - if let Some(obj) = nyash_rust::jit::rt::handles::get(a0) { + if let Some(obj) = nyash_rust::runtime::host_handles::get(a0 as u64) { if let Some(p) = obj.as_any().downcast_ref::() { (p.instance_id(), p.inner.type_id, Some(p.inner.invoke_fn)) } else { @@ -265,7 +265,7 @@ pub extern "C" fn nyash_future_spawn_instance3_i64(a0: i64, a1: i64, a2: i64, ar // Determine method name string (from a1 handle→StringBox, or a1 as C string pointer, or legacy VM args) let mut method_name: Option = None; if a1 > 0 { - if let Some(obj) = nyash_rust::jit::rt::handles::get(a1) { + if let Some(obj) = nyash_rust::runtime::host_handles::get(a1 as u64) { if let Some(p) = obj.as_any().downcast_ref::() { if p.box_type == "StringBox" { // Limit the lifetime of the read guard to this inner block by avoiding an outer binding @@ -324,7 +324,7 @@ pub extern "C" fn nyash_future_spawn_instance3_i64(a0: i64, a1: i64, a2: i64, ar let mut encode_arg_into = |dst: &mut Vec, val: i64, pos: usize| { let mut appended = false; if val > 0 { - if let Some(obj) = nyash_rust::jit::rt::handles::get(val) { + if let Some(obj) = nyash_rust::runtime::host_handles::get(val as u64) { if let Some(p) = obj.as_any().downcast_ref::() { let host = nyash_rust::runtime::get_global_plugin_host(); if let Ok(hg) = host.read() { @@ -389,7 +389,7 @@ pub extern "C" fn nyash_future_spawn_instance3_i64(a0: i64, a1: i64, a2: i64, ar // Create Future and schedule async invoke let fut_box = std::sync::Arc::new(nyash_rust::boxes::future::FutureBox::new()); let handle = - nyash_rust::jit::rt::handles::to_handle(fut_box.clone() as std::sync::Arc); + nyash_rust::runtime::host_handles::to_handle_arc(fut_box.clone() as std::sync::Arc); let tlv = buf.clone(); nyash_rust::runtime::global_hooks::spawn_task( "nyash.future.spawn_instance3_i64", diff --git a/crates/nyash_kernel/src/plugin/instance.rs b/crates/nyash_kernel/src/plugin/instance.rs index 5e51dbdf..9511201b 100644 --- a/crates/nyash_kernel/src/plugin/instance.rs +++ b/crates/nyash_kernel/src/plugin/instance.rs @@ -7,7 +7,7 @@ pub extern "C" fn nyash_instance_get_field_h(handle: i64, name: *const i8) -> i6 } let name = unsafe { std::ffi::CStr::from_ptr(name) }; let Ok(field) = name.to_str() else { return 0 }; - if let Some(obj) = nyash_rust::jit::rt::handles::get(handle) { + if let Some(obj) = nyash_rust::runtime::host_handles::get(handle as u64) { if let Some(inst) = obj .as_any() .downcast_ref::() @@ -15,7 +15,7 @@ pub extern "C" fn nyash_instance_get_field_h(handle: i64, name: *const i8) -> i6 if let Some(shared) = inst.get_field(field) { let arc: std::sync::Arc = std::sync::Arc::from(shared); - let h = nyash_rust::jit::rt::handles::to_handle(arc); + let h = nyash_rust::runtime::host_handles::to_handle_arc(arc) as u64; return h as i64; } } @@ -31,13 +31,13 @@ pub extern "C" fn nyash_instance_set_field_h(handle: i64, name: *const i8, val_h } let name = unsafe { std::ffi::CStr::from_ptr(name) }; let Ok(field) = name.to_str() else { return 0 }; - if let Some(obj) = nyash_rust::jit::rt::handles::get(handle) { + if let Some(obj) = nyash_rust::runtime::host_handles::get(handle as u64) { if let Some(inst) = obj .as_any() .downcast_ref::() { if val_h > 0 { - if let Some(val) = nyash_rust::jit::rt::handles::get(val_h) { + if let Some(val) = nyash_rust::runtime::host_handles::get(val_h as u64) { let shared: nyash_rust::box_trait::SharedNyashBox = std::sync::Arc::clone(&val); let _ = inst.set_field(field, shared); return 0; diff --git a/crates/nyash_kernel/src/plugin/invoke.rs b/crates/nyash_kernel/src/plugin/invoke.rs index 5ef54632..4d4e9f40 100644 --- a/crates/nyash_kernel/src/plugin/invoke.rs +++ b/crates/nyash_kernel/src/plugin/invoke.rs @@ -77,7 +77,7 @@ pub extern "C" fn nyash_plugin_invoke3_f64( unsafe extern "C" fn(u32, u32, u32, *const u8, usize, *mut u8, *mut usize) -> i32, > = None; if a0 > 0 { - if let Some(obj) = nyash_rust::jit::rt::handles::get(a0) { + if let Some(obj) = nyash_rust::runtime::host_handles::get(a0 as u64) { if let Some(p) = obj.as_any().downcast_ref::() { instance_id = p.instance_id(); invoke = Some(p.inner.invoke_fn); @@ -160,7 +160,7 @@ fn nyash_plugin_invoke_name_common_i64(method: &str, argc: i64, a0: i64, a1: i64 unsafe extern "C" fn(u32, u32, u32, *const u8, usize, *mut u8, *mut usize) -> i32, > = None; if a0 > 0 { - if let Some(obj) = nyash_rust::jit::rt::handles::get(a0) { + if let Some(obj) = nyash_rust::runtime::host_handles::get(a0 as u64) { if let Some(p) = obj.as_any().downcast_ref::() { instance_id = p.instance_id(); type_id = p.inner.type_id; @@ -263,7 +263,7 @@ pub extern "C" fn nyash_plugin_invoke_by_name_i64( unsafe extern "C" fn(u32, u32, u32, *const u8, usize, *mut u8, *mut usize) -> i32, > = None; if recv_handle > 0 { - if let Some(obj) = nyash_rust::jit::rt::handles::get(recv_handle) { + if let Some(obj) = nyash_rust::runtime::host_handles::get(recv_handle as u64) { if let Some(p) = obj.as_any().downcast_ref::() { instance_id = p.instance_id(); type_id = p.inner.type_id; @@ -356,7 +356,7 @@ pub extern "C" fn nyash_plugin_invoke_by_name_i64( ); let arc: std::sync::Arc = std::sync::Arc::new(pb); - let h = nyash_rust::jit::rt::handles::to_handle(arc); + let h = nyash_rust::runtime::host_handles::to_handle_arc(arc) as u64; return h as i64; } } @@ -401,7 +401,7 @@ pub extern "C" fn nyash_plugin_invoke3_tagged_i64( unsafe extern "C" fn(u32, u32, u32, *const u8, usize, *mut u8, *mut usize) -> i32, > = None; if a0 > 0 { - if let Some(obj) = nyash_rust::jit::rt::handles::get(a0) { + if let Some(obj) = nyash_rust::runtime::host_handles::get(a0 as u64) { if let Some(p) = obj.as_any().downcast_ref::() { instance_id = p.instance_id(); real_type_id = p.inner.type_id; @@ -425,7 +425,7 @@ pub extern "C" fn nyash_plugin_invoke3_tagged_i64( } 8 => { if val > 0 { - if let Some(obj) = nyash_rust::jit::rt::handles::get(val) { + if let Some(obj) = nyash_rust::runtime::host_handles::get(val as u64) { if let Some(p) = obj.as_any().downcast_ref::() { nyash_rust::runtime::plugin_ffi_common::encode::plugin_handle( &mut buf, @@ -503,7 +503,7 @@ pub extern "C" fn nyash_plugin_invoke_tagged_v_i64( let mut invoke: Option< unsafe extern "C" fn(u32, u32, u32, *const u8, usize, *mut u8, *mut usize) -> i32, > = None; - if let Some(obj) = nyash_rust::jit::rt::handles::get(recv_h) { + if let Some(obj) = nyash_rust::runtime::host_handles::get(recv_h as u64) { if let Some(p) = obj.as_any().downcast_ref::() { instance_id = p.instance_id(); real_type_id = p.inner.type_id; @@ -534,7 +534,7 @@ pub extern "C" fn nyash_plugin_invoke_tagged_v_i64( nyash_rust::runtime::plugin_ffi_common::encode::f64(&mut buf, f); } 8 => { - if let Some(obj) = nyash_rust::jit::rt::handles::get(vals[i]) { + if let Some(obj) = nyash_rust::runtime::host_handles::get(vals[i] as u64) { if let Some(p) = obj.as_any().downcast_ref::() { nyash_rust::runtime::plugin_ffi_common::encode::plugin_handle( &mut buf, diff --git a/crates/nyash_kernel/src/plugin/invoke_core.rs b/crates/nyash_kernel/src/plugin/invoke_core.rs index 061198c8..0412f174 100644 --- a/crates/nyash_kernel/src/plugin/invoke_core.rs +++ b/crates/nyash_kernel/src/plugin/invoke_core.rs @@ -15,7 +15,7 @@ pub struct Receiver { pub fn resolve_receiver_for_a0(a0: i64) -> Option { // 1) Handle registry (preferred) if a0 > 0 { - if let Some(obj) = nyash_rust::jit::rt::handles::get(a0) { + if let Some(obj) = nyash_rust::runtime::host_handles::get(a0 as u64) { if let Some(p) = obj.as_any().downcast_ref::() { return Some(Receiver { instance_id: p.instance_id(), @@ -113,7 +113,7 @@ pub fn decode_entry_to_i64( use nyash_rust::box_trait::{NyashBox, StringBox}; let s = nyash_rust::runtime::plugin_ffi_common::decode::string(payload); let arc: std::sync::Arc = std::sync::Arc::new(StringBox::new(s)); - let h = nyash_rust::jit::rt::handles::to_handle(arc); + let h = nyash_rust::runtime::host_handles::to_handle_arc(arc) as u64; Some(h as i64) } 8 => { @@ -139,7 +139,7 @@ pub fn decode_entry_to_i64( ); let arc: std::sync::Arc = std::sync::Arc::new(pb); - let h = nyash_rust::jit::rt::handles::to_handle(arc); + let h = nyash_rust::runtime::host_handles::to_handle_arc(arc) as u64; return Some(h as i64); } None diff --git a/crates/nyash_kernel/src/plugin/map.rs b/crates/nyash_kernel/src/plugin/map.rs index 9f0a84c0..93b8b074 100644 --- a/crates/nyash_kernel/src/plugin/map.rs +++ b/crates/nyash_kernel/src/plugin/map.rs @@ -3,14 +3,14 @@ // size: (handle) -> i64 #[export_name = "nyash.map.size_h"] pub extern "C" fn nyash_map_size_h(handle: i64) -> i64 { - use nyash_rust::jit::rt::handles; + use nyash_rust::runtime::host_handles as handles; if std::env::var("NYASH_LLVM_MAP_DEBUG").ok().as_deref() == Some("1") { eprintln!("[MAP] size_h(handle={})", handle); } if handle <= 0 { return 0; } - if let Some(obj) = handles::get(handle) { + if let Some(obj) = handles::get(handle as u64) { if let Some(map) = obj .as_any() .downcast_ref::() @@ -35,7 +35,7 @@ pub extern "C" fn nyash_map_size_h(handle: i64) -> i64 { pub extern "C" fn nyash_map_get_h(handle: i64, key: i64) -> i64 { use nyash_rust::{ box_trait::{IntegerBox, NyashBox}, - jit::rt::handles, + runtime::host_handles as handles, }; if std::env::var("NYASH_LLVM_MAP_DEBUG").ok().as_deref() == Some("1") { eprintln!("[MAP] get_h(handle={}, key={})", handle, key); @@ -43,7 +43,7 @@ pub extern "C" fn nyash_map_get_h(handle: i64, key: i64) -> i64 { if handle <= 0 { return 0; } - if let Some(obj) = handles::get(handle) { + if let Some(obj) = handles::get(handle as u64) { if let Some(map) = obj .as_any() .downcast_ref::() @@ -51,7 +51,7 @@ pub extern "C" fn nyash_map_get_h(handle: i64, key: i64) -> i64 { let kbox: Box = Box::new(IntegerBox::new(key)); let v = map.get(kbox); let arc: std::sync::Arc = std::sync::Arc::from(v); - let h = handles::to_handle(arc); + let h = handles::to_handle_arc(arc) as u64; if std::env::var("NYASH_LLVM_MAP_DEBUG").ok().as_deref() == Some("1") { eprintln!("[MAP] get_h => handle {}", h); } @@ -66,18 +66,18 @@ pub extern "C" fn nyash_map_get_h(handle: i64, key: i64) -> i64 { pub extern "C" fn nyash_map_get_hh(handle: i64, key_any: i64) -> i64 { use nyash_rust::{ box_trait::{IntegerBox, NyashBox}, - jit::rt::handles, + runtime::host_handles as handles, }; if handle <= 0 { return 0; } - if let Some(obj) = handles::get(handle) { + if let Some(obj) = handles::get(handle as u64) { if let Some(map) = obj .as_any() .downcast_ref::() { let key_box: Box = if key_any > 0 { - if let Some(k) = handles::get(key_any) { + if let Some(k) = handles::get(key_any as u64) { k.clone_box() } else { Box::new(IntegerBox::new(key_any)) @@ -87,7 +87,7 @@ pub extern "C" fn nyash_map_get_hh(handle: i64, key_any: i64) -> i64 { }; let v = map.get(key_box); let arc: std::sync::Arc = std::sync::Arc::from(v); - let h = handles::to_handle(arc); + let h = handles::to_handle_arc(arc) as u64; return h as i64; } } @@ -99,7 +99,7 @@ pub extern "C" fn nyash_map_get_hh(handle: i64, key_any: i64) -> i64 { pub extern "C" fn nyash_map_set_h(handle: i64, key: i64, val: i64) -> i64 { use nyash_rust::{ box_trait::{IntegerBox, NyashBox}, - jit::rt::handles, + runtime::host_handles as handles, }; if std::env::var("NYASH_LLVM_MAP_DEBUG").ok().as_deref() == Some("1") { eprintln!("[MAP] set_h(handle={}, key={}, val={})", handle, key, val); @@ -107,14 +107,14 @@ pub extern "C" fn nyash_map_set_h(handle: i64, key: i64, val: i64) -> i64 { if handle <= 0 { return 0; } - if let Some(obj) = handles::get(handle) { + if let Some(obj) = handles::get(handle as u64) { if let Some(map) = obj .as_any() .downcast_ref::() { let kbox: Box = Box::new(IntegerBox::new(key)); let vbox: Box = if val > 0 { - if let Some(o) = handles::get(val) { + if let Some(o) = handles::get(val as u64) { o.clone_box() } else { Box::new(IntegerBox::new(val)) @@ -143,18 +143,18 @@ pub extern "C" fn nyash_map_set_h(handle: i64, key: i64, val: i64) -> i64 { pub extern "C" fn nyash_map_set_hh(handle: i64, key_any: i64, val_any: i64) -> i64 { use nyash_rust::{ box_trait::{IntegerBox, NyashBox}, - jit::rt::handles, + runtime::host_handles as handles, }; if handle <= 0 { return 0; } - if let Some(obj) = handles::get(handle) { + if let Some(obj) = handles::get(handle as u64) { if let Some(map) = obj .as_any() .downcast_ref::() { let kbox: Box = if key_any > 0 { - if let Some(k) = handles::get(key_any) { + if let Some(k) = handles::get(key_any as u64) { k.clone_box() } else { Box::new(IntegerBox::new(key_any)) @@ -163,7 +163,7 @@ pub extern "C" fn nyash_map_set_hh(handle: i64, key_any: i64, val_any: i64) -> i Box::new(IntegerBox::new(key_any)) }; let vbox: Box = if val_any > 0 { - if let Some(v) = handles::get(val_any) { + if let Some(v) = handles::get(val_any as u64) { v.clone_box() } else { Box::new(IntegerBox::new(val_any)) @@ -183,18 +183,18 @@ pub extern "C" fn nyash_map_set_hh(handle: i64, key_any: i64, val_any: i64) -> i pub extern "C" fn nyash_map_has_hh(handle: i64, key_any: i64) -> i64 { use nyash_rust::{ box_trait::{BoolBox, IntegerBox, NyashBox}, - jit::rt::handles, + runtime::host_handles as handles, }; if handle <= 0 { return 0; } - if let Some(obj) = handles::get(handle) { + if let Some(obj) = handles::get(handle as u64) { if let Some(map) = obj .as_any() .downcast_ref::() { let kbox: Box = if key_any > 0 { - if let Some(k) = handles::get(key_any) { + if let Some(k) = handles::get(key_any as u64) { k.clone_box() } else { Box::new(IntegerBox::new(key_any)) @@ -214,11 +214,11 @@ pub extern "C" fn nyash_map_has_hh(handle: i64, key_any: i64) -> i64 { // has_h: (map_handle, key_i64) -> i64 (0/1) #[export_name = "nyash.map.has_h"] pub extern "C" fn nyash_map_has_h(handle: i64, key: i64) -> i64 { - use nyash_rust::{box_trait::IntegerBox, jit::rt::handles}; + use nyash_rust::{box_trait::IntegerBox, runtime::host_handles as handles}; if handle <= 0 { return 0; } - if let Some(obj) = handles::get(handle) { + if let Some(obj) = handles::get(handle as u64) { if let Some(map) = obj .as_any() .downcast_ref::() diff --git a/crates/nyash_kernel/src/plugin/semantics.rs b/crates/nyash_kernel/src/plugin/semantics.rs index 76ed11fc..ca2903a7 100644 --- a/crates/nyash_kernel/src/plugin/semantics.rs +++ b/crates/nyash_kernel/src/plugin/semantics.rs @@ -2,7 +2,7 @@ // Exported as: nyash.semantics.add_hh(i64 lhs_handle, i64 rhs_handle) -> i64 (NyashBox handle) #[export_name = "nyash.semantics.add_hh"] pub extern "C" fn nyash_semantics_add_hh_export(lhs_h: i64, rhs_h: i64) -> i64 { - use nyash_rust::jit::rt::handles; + use nyash_rust::runtime::host_handles as handles; use nyash_rust::{ box_trait::{IntegerBox, StringBox}, runtime::semantics, @@ -10,12 +10,12 @@ pub extern "C" fn nyash_semantics_add_hh_export(lhs_h: i64, rhs_h: i64) -> i64 { if lhs_h <= 0 || rhs_h <= 0 { return 0; } - let lhs = if let Some(obj) = handles::get(lhs_h) { + let lhs = if let Some(obj) = handles::get(lhs_h as u64) { obj } else { return 0; }; - let rhs = if let Some(obj) = handles::get(rhs_h) { + let rhs = if let Some(obj) = handles::get(rhs_h as u64) { obj } else { return 0; @@ -28,7 +28,7 @@ pub extern "C" fn nyash_semantics_add_hh_export(lhs_h: i64, rhs_h: i64) -> i64 { let s = format!("{}{}", ls, rs); let arc: std::sync::Arc = std::sync::Arc::new(StringBox::new(s)); - return handles::to_handle(arc) as i64; + return handles::to_handle_arc(arc) as i64; } if let (Some(li), Some(ri)) = ( semantics::coerce_to_i64(lhs.as_ref()), @@ -36,12 +36,12 @@ pub extern "C" fn nyash_semantics_add_hh_export(lhs_h: i64, rhs_h: i64) -> i64 { ) { let arc: std::sync::Arc = std::sync::Arc::new(IntegerBox::new(li + ri)); - return handles::to_handle(arc) as i64; + return handles::to_handle_arc(arc) as i64; } // Fallback: stringify both and concat to preserve total order let ls = lhs.to_string_box().value; let rs = rhs.to_string_box().value; let arc: std::sync::Arc = std::sync::Arc::new(StringBox::new(format!("{}{}", ls, rs))); - handles::to_handle(arc) as i64 + handles::to_handle_arc(arc) as i64 } diff --git a/crates/nyash_kernel/src/plugin/string.rs b/crates/nyash_kernel/src/plugin/string.rs index 07a1d2e6..9dc8f077 100644 --- a/crates/nyash_kernel/src/plugin/string.rs +++ b/crates/nyash_kernel/src/plugin/string.rs @@ -143,7 +143,7 @@ pub extern "C" fn nyash_string_lastindexof_ss(s: *const i8, needle: *const i8) - // 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 { - use nyash_rust::jit::rt::handles; + use nyash_rust::runtime::host_handles as handles; if handle <= 0 { // return "0" for consistency with existing fallback behavior let s = handle.to_string(); @@ -153,7 +153,7 @@ pub extern "C" fn nyash_string_to_i8p_h(handle: i64) -> *mut i8 { let raw = Box::into_raw(boxed) as *mut u8; return raw as *mut i8; } - if let Some(obj) = handles::get(handle) { + if let Some(obj) = handles::get(handle as u64) { let s = obj.to_string_box().value; let mut bytes = s.into_bytes(); bytes.push(0); diff --git a/docs/private/roadmap/phases/phase-33/README.md b/docs/private/roadmap/phases/phase-33/README.md index fdacd944..56ba8b2b 100644 --- a/docs/private/roadmap/phases/phase-33/README.md +++ b/docs/private/roadmap/phases/phase-33/README.md @@ -65,5 +65,13 @@ - C) 代替ルートの準備(任意) - アーカイバ経路の helper(`.o + libnyash_kernel.a → exe`)を復帰し、ハーネス依存を迂回可能にする。 +進捗メモ(2025-10-31夕方) +- ✅ A) ハーネス修正済(`mir_call.py` indentation fix) +- ✅ B) Workspace exclude 適用済(欠損プラグインを除外) +- ⏳ NyRT(host_handles) へ移行中 + - `encode.rs` / `plugin/{array,map,console,future,instance,invoke,invoke_core,string}` などは `jit::rt::handles` から `runtime::host_handles` へ置換済み。 + - 残TODO: `crates/nyash_kernel/src/lib.rs` 全域と `plugin/semantics.rs` の `to_handle/get` を host_handles に揃え、`i64→u64` キャストを整理する。 +- 🧱 libnyash_kernel.a が未生成なため EXE リンクは保留。上記残TODO完了後に return 7 カナリアで確認する。 + 運用メモ - main は docs 復元のみコミット済み。AOT 関連の差分は phase33 ブランチ(または stash)で保全し、段階的に進める。 diff --git a/src/llvm_py/instructions/mir_call.py b/src/llvm_py/instructions/mir_call.py index f063be30..9bc85604 100644 --- a/src/llvm_py/instructions/mir_call.py +++ b/src/llvm_py/instructions/mir_call.py @@ -22,7 +22,7 @@ def lower_mir_call(owner, builder: ir.IRBuilder, mir_call: Dict[str, Any], dst_v """ # Check if unified call is enabled -use_unified = os.getenv("NYASH_MIR_UNIFIED_CALL", "1").lower() not in ("0", "false", "off") + use_unified = os.getenv("NYASH_MIR_UNIFIED_CALL", "1").lower() not in ("0", "false", "off") if not use_unified: # Fall back to legacy dispatching return lower_legacy_call(owner, builder, mir_call, dst_vid, vmap, resolver)