aot(core): EXE path green (return 7); migrate NyRT jit handles → runtime::host_handles; fix mir_call.py indent; workspace excludes for missing plugins; docs(phase-33) status update
This commit is contained in:
@ -244,6 +244,10 @@ members = [
|
|||||||
exclude = [
|
exclude = [
|
||||||
"plugins/nyash-file",
|
"plugins/nyash-file",
|
||||||
"plugins/nyash-test-multibox",
|
"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]
|
[profile.release]
|
||||||
|
|||||||
@ -10,10 +10,10 @@ pub(crate) fn nyrt_encode_from_legacy_at(_buf: &mut Vec<u8>, _pos: usize) {
|
|||||||
|
|
||||||
/// Simplified encoding for Plugin-First architecture (replaces legacy encoding)
|
/// Simplified encoding for Plugin-First architecture (replaces legacy encoding)
|
||||||
pub(crate) fn nyrt_encode_arg_or_legacy(buf: &mut Vec<u8>, val: i64, _pos: usize) {
|
pub(crate) fn nyrt_encode_arg_or_legacy(buf: &mut Vec<u8>, 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
|
// Handle direct values and plugin objects, bypass legacy VM fallback
|
||||||
if val > 0 {
|
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
|
if let Some(bufbox) = obj
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<nyash_rust::boxes::buffer::BufferBox>()
|
.downcast_ref::<nyash_rust::boxes::buffer::BufferBox>()
|
||||||
|
|||||||
@ -10,10 +10,10 @@ pub use plugin::*;
|
|||||||
// String.len_h(handle) -> i64
|
// String.len_h(handle) -> i64
|
||||||
#[export_name = "nyash.string.len_h"]
|
#[export_name = "nyash.string.len_h"]
|
||||||
pub extern "C" fn nyash_string_len_h(handle: i64) -> i64 {
|
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") {
|
if std::env::var("NYASH_JIT_TRACE_LEN").ok().as_deref() == Some("1") {
|
||||||
let present = if handle > 0 {
|
let present = if handle > 0 {
|
||||||
handles::get(handle).is_some()
|
handles::get(handle as u64).is_some()
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
@ -25,7 +25,7 @@ pub extern "C" fn nyash_string_len_h(handle: i64) -> i64 {
|
|||||||
if handle <= 0 {
|
if handle <= 0 {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if let Some(obj) = handles::get(handle) {
|
if let Some(obj) = handles::get(handle as u64) {
|
||||||
if let Some(sb) = obj
|
if let Some(sb) = obj
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<nyash_rust::box_trait::StringBox>()
|
.downcast_ref::<nyash_rust::box_trait::StringBox>()
|
||||||
@ -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)
|
// String.charCodeAt_h(handle, idx) -> i64 (byte-based; -1 if OOB)
|
||||||
#[export_name = "nyash.string.charCodeAt_h"]
|
#[export_name = "nyash.string.charCodeAt_h"]
|
||||||
pub extern "C" fn nyash_string_charcode_at_h_export(handle: i64, idx: i64) -> i64 {
|
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 {
|
if idx < 0 {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if handle <= 0 {
|
if handle <= 0 {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if let Some(obj) = handles::get(handle) {
|
if let Some(obj) = handles::get(handle as u64) {
|
||||||
if let Some(sb) = obj
|
if let Some(sb) = obj
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<nyash_rust::box_trait::StringBox>()
|
.downcast_ref::<nyash_rust::box_trait::StringBox>()
|
||||||
@ -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 {
|
pub extern "C" fn nyash_string_concat_hh_export(a_h: i64, b_h: i64) -> i64 {
|
||||||
use nyash_rust::{
|
use nyash_rust::{
|
||||||
box_trait::{NyashBox, StringBox},
|
box_trait::{NyashBox, StringBox},
|
||||||
jit::rt::handles,
|
runtime::host_handles as handles,
|
||||||
};
|
};
|
||||||
let to_s = |h: i64| -> String {
|
let to_s = |h: i64| -> String {
|
||||||
if h > 0 {
|
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;
|
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));
|
let s = format!("{}{}", to_s(a_h), to_s(b_h));
|
||||||
nyash_rust::runtime::global_hooks::gc_alloc(s.len() as u64);
|
nyash_rust::runtime::global_hooks::gc_alloc(s.len() as u64);
|
||||||
let arc: std::sync::Arc<dyn NyashBox> = std::sync::Arc::new(StringBox::new(s));
|
let arc: std::sync::Arc<dyn NyashBox> = 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);
|
eprintln!("[TRACE] concat_hh -> {}", h);
|
||||||
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)
|
// String.eq_hh(lhs_h, rhs_h) -> i64 (0/1)
|
||||||
#[export_name = "nyash.string.eq_hh"]
|
#[export_name = "nyash.string.eq_hh"]
|
||||||
pub extern "C" fn nyash_string_eq_hh_export(a_h: i64, b_h: i64) -> i64 {
|
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 {
|
let to_s = |h: i64| -> String {
|
||||||
if h > 0 {
|
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;
|
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
|
// String.substring_hii(handle, start, end) -> handle
|
||||||
#[export_name = "nyash.string.substring_hii"]
|
#[export_name = "nyash.string.substring_hii"]
|
||||||
pub extern "C" fn nyash_string_substring_hii_export(h: i64, start: i64, end: i64) -> i64 {
|
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 {
|
if h <= 0 {
|
||||||
return 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::<StringBox>() {
|
if let Some(sb) = obj.as_any().downcast_ref::<StringBox>() {
|
||||||
sb.value.clone()
|
sb.value.clone()
|
||||||
} else {
|
} 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 sub = s.get(st_u.min(s.len())..en_u.min(s.len())).unwrap_or("");
|
||||||
let arc: std::sync::Arc<dyn NyashBox> = std::sync::Arc::new(StringBox::new(sub.to_string()));
|
let arc: std::sync::Arc<dyn NyashBox> = std::sync::Arc::new(StringBox::new(sub.to_string()));
|
||||||
nyash_rust::runtime::global_hooks::gc_alloc(sub.len() as u64);
|
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);
|
eprintln!("[TRACE] substring_hii -> {}", nh);
|
||||||
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
|
// String.lastIndexOf_hh(haystack_h, needle_h) -> i64
|
||||||
#[export_name = "nyash.string.lastIndexOf_hh"]
|
#[export_name = "nyash.string.lastIndexOf_hh"]
|
||||||
pub extern "C" fn nyash_string_lastindexof_hh_export(h: i64, n: i64) -> i64 {
|
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 {
|
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::<StringBox>() {
|
if let Some(sb) = o.as_any().downcast_ref::<StringBox>() {
|
||||||
sb.value.clone()
|
sb.value.clone()
|
||||||
} else {
|
} else {
|
||||||
@ -159,7 +159,7 @@ pub extern "C" fn nyash_string_lastindexof_hh_export(h: i64, n: i64) -> i64 {
|
|||||||
String::new()
|
String::new()
|
||||||
};
|
};
|
||||||
let nee = if n > 0 {
|
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::<StringBox>() {
|
if let Some(sb) = o.as_any().downcast_ref::<StringBox>() {
|
||||||
sb.value.clone()
|
sb.value.clone()
|
||||||
} else {
|
} 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 {
|
pub extern "C" fn nyash_box_from_i8_string(ptr: *const i8) -> i64 {
|
||||||
use nyash_rust::{
|
use nyash_rust::{
|
||||||
box_trait::{NyashBox, StringBox},
|
box_trait::{NyashBox, StringBox},
|
||||||
jit::rt::handles,
|
runtime::host_handles as handles,
|
||||||
};
|
};
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
if ptr.is_null() {
|
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<dyn NyashBox> = std::sync::Arc::new(StringBox::new(s.clone()));
|
let arc: std::sync::Arc<dyn NyashBox> = std::sync::Arc::new(StringBox::new(s.clone()));
|
||||||
nyash_rust::runtime::global_hooks::gc_alloc(s.len() as u64);
|
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);
|
eprintln!("[TRACE] from_i8_string -> {}", h);
|
||||||
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
|
// Helper: build a FloatBox and return a handle
|
||||||
#[export_name = "nyash.box.from_f64"]
|
#[export_name = "nyash.box.from_f64"]
|
||||||
pub extern "C" fn nyash_box_from_f64(val: f64) -> i64 {
|
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<dyn NyashBox> = std::sync::Arc::new(FloatBox::new(val));
|
let arc: std::sync::Arc<dyn NyashBox> = std::sync::Arc::new(FloatBox::new(val));
|
||||||
nyash_rust::runtime::global_hooks::gc_alloc(8);
|
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
|
// 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 {
|
pub extern "C" fn nyash_box_from_i64(val: i64) -> i64 {
|
||||||
use nyash_rust::{
|
use nyash_rust::{
|
||||||
box_trait::{IntegerBox, NyashBox},
|
box_trait::{IntegerBox, NyashBox},
|
||||||
jit::rt::handles,
|
runtime::host_handles as handles,
|
||||||
};
|
};
|
||||||
let arc: std::sync::Arc<dyn NyashBox> = std::sync::Arc::new(IntegerBox::new(val));
|
let arc: std::sync::Arc<dyn NyashBox> = std::sync::Arc::new(IntegerBox::new(val));
|
||||||
nyash_rust::runtime::global_hooks::gc_alloc(8);
|
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)
|
// 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"]
|
#[export_name = "nyash.env.box.new"]
|
||||||
pub extern "C" fn nyash_env_box_new(type_name: *const i8) -> i64 {
|
pub extern "C" fn nyash_env_box_new(type_name: *const i8) -> i64 {
|
||||||
use nyash_rust::{
|
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;
|
use std::ffi::CStr;
|
||||||
if type_name.is_null() {
|
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" {
|
if ty == "MapBox" {
|
||||||
use nyash_rust::boxes::map_box::MapBox;
|
use nyash_rust::boxes::map_box::MapBox;
|
||||||
let arc: std::sync::Arc<dyn NyashBox> = std::sync::Arc::new(MapBox::new());
|
let arc: std::sync::Arc<dyn NyashBox> = std::sync::Arc::new(MapBox::new());
|
||||||
return handles::to_handle(arc) as i64;
|
return handles::to_handle_arc(arc) as i64;
|
||||||
}
|
}
|
||||||
if ty == "ArrayBox" {
|
if ty == "ArrayBox" {
|
||||||
use nyash_rust::boxes::array::ArrayBox;
|
use nyash_rust::boxes::array::ArrayBox;
|
||||||
let arc: std::sync::Arc<dyn NyashBox> = std::sync::Arc::new(ArrayBox::new());
|
let arc: std::sync::Arc<dyn NyashBox> = 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") {
|
if std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") {
|
||||||
eprintln!("nyrt: env.box.new ArrayBox -> handle={}", h);
|
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, &[]) {
|
match reg.create_box(ty, &[]) {
|
||||||
Ok(b) => {
|
Ok(b) => {
|
||||||
let arc: std::sync::Arc<dyn NyashBox> = b.into();
|
let arc: std::sync::Arc<dyn NyashBox> = b.into();
|
||||||
handles::to_handle(arc) as i64
|
handles::to_handle_arc(arc) as i64
|
||||||
}
|
}
|
||||||
Err(_) => 0,
|
Err(_) => 0,
|
||||||
}
|
}
|
||||||
@ -282,8 +283,7 @@ pub extern "C" fn nyash_env_box_new_i64x(
|
|||||||
) -> i64 {
|
) -> i64 {
|
||||||
use nyash_rust::{
|
use nyash_rust::{
|
||||||
box_trait::{IntegerBox, NyashBox},
|
box_trait::{IntegerBox, NyashBox},
|
||||||
jit::rt::handles,
|
runtime::{host_handles as handles, box_registry::get_global_registry},
|
||||||
runtime::box_registry::get_global_registry,
|
|
||||||
};
|
};
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
if type_name.is_null() {
|
if type_name.is_null() {
|
||||||
@ -298,7 +298,7 @@ pub extern "C" fn nyash_env_box_new_i64x(
|
|||||||
let mut argv: Vec<Box<dyn NyashBox>> = Vec::new();
|
let mut argv: Vec<Box<dyn NyashBox>> = Vec::new();
|
||||||
let push_val = |dst: &mut Vec<Box<dyn NyashBox>>, v: i64| {
|
let push_val = |dst: &mut Vec<Box<dyn NyashBox>>, v: i64| {
|
||||||
if v > 0 {
|
if v > 0 {
|
||||||
if let Some(obj) = handles::get(v) {
|
if let Some(obj) = handles::get(v as u64) {
|
||||||
dst.push(obj.share_box());
|
dst.push(obj.share_box());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ pub extern "C" fn nyash_env_box_new_i64x(
|
|||||||
match reg.create_box(ty, &argv) {
|
match reg.create_box(ty, &argv) {
|
||||||
Ok(b) => {
|
Ok(b) => {
|
||||||
let arc: std::sync::Arc<dyn NyashBox> = b.into();
|
let arc: std::sync::Arc<dyn NyashBox> = b.into();
|
||||||
handles::to_handle(arc) as i64
|
handles::to_handle_arc(arc) as i64
|
||||||
}
|
}
|
||||||
Err(_) => 0,
|
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)
|
// String.lt_hh(lhs_h, rhs_h) -> i64 (0/1)
|
||||||
#[export_name = "nyash.string.lt_hh"]
|
#[export_name = "nyash.string.lt_hh"]
|
||||||
pub extern "C" fn nyash_string_lt_hh_export(a_h: i64, b_h: i64) -> i64 {
|
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 {
|
let to_s = |h: i64| -> String {
|
||||||
if h > 0 {
|
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;
|
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)
|
// Any.length_h(handle) -> i64 (Array/String/Map)
|
||||||
#[export_name = "nyash.any.length_h"]
|
#[export_name = "nyash.any.length_h"]
|
||||||
pub extern "C" fn nyash_any_length_h_export(handle: i64) -> i64 {
|
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") {
|
if std::env::var("NYASH_JIT_TRACE_LEN").ok().as_deref() == Some("1") {
|
||||||
let present = if handle > 0 {
|
let present = if handle > 0 {
|
||||||
handles::get(handle).is_some()
|
handles::get(handle as u64).is_some()
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
@ -365,7 +365,7 @@ pub extern "C" fn nyash_any_length_h_export(handle: i64) -> i64 {
|
|||||||
if handle <= 0 {
|
if handle <= 0 {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if let Some(obj) = handles::get(handle) {
|
if let Some(obj) = handles::get(handle as u64) {
|
||||||
if let Some(arr) = obj
|
if let Some(arr) = obj
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<nyash_rust::boxes::array::ArrayBox>()
|
.downcast_ref::<nyash_rust::boxes::array::ArrayBox>()
|
||||||
@ -403,11 +403,11 @@ pub extern "C" fn nyash_any_length_h_export(handle: i64) -> i64 {
|
|||||||
// Any.is_empty_h(handle) -> i64 (0/1)
|
// Any.is_empty_h(handle) -> i64 (0/1)
|
||||||
#[export_name = "nyash.any.is_empty_h"]
|
#[export_name = "nyash.any.is_empty_h"]
|
||||||
pub extern "C" fn nyash_any_is_empty_h_export(handle: i64) -> i64 {
|
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 {
|
if handle <= 0 {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if let Some(obj) = handles::get(handle) {
|
if let Some(obj) = handles::get(handle as u64) {
|
||||||
if let Some(arr) = obj
|
if let Some(arr) = obj
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<nyash_rust::boxes::array::ArrayBox>()
|
.downcast_ref::<nyash_rust::boxes::array::ArrayBox>()
|
||||||
@ -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(host_g) = get_global_plugin_host().read() {
|
||||||
if let Ok(b) = host_g.create_box(&name, &[]) {
|
if let Ok(b) = host_g.create_box(&name, &[]) {
|
||||||
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> = std::sync::Arc::from(b);
|
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> = 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;
|
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 {
|
pub extern "C" fn nyash_string_from_u64x2_export(lo: i64, hi: i64, len: i64) -> i64 {
|
||||||
use nyash_rust::{
|
use nyash_rust::{
|
||||||
box_trait::{NyashBox, StringBox},
|
box_trait::{NyashBox, StringBox},
|
||||||
jit::rt::handles,
|
runtime::host_handles as handles,
|
||||||
};
|
};
|
||||||
let l = if len < 0 {
|
let l = if len < 0 {
|
||||||
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 s = String::from_utf8_lossy(&bytes).to_string();
|
||||||
let arc: std::sync::Arc<dyn NyashBox> = std::sync::Arc::new(StringBox::new(s.clone()));
|
let arc: std::sync::Arc<dyn NyashBox> = std::sync::Arc::new(StringBox::new(s.clone()));
|
||||||
nyash_rust::runtime::global_hooks::gc_alloc(s.len() as u64);
|
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
|
// ✂️ 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(host_g) = nyash_rust::runtime::get_global_plugin_host().read() {
|
||||||
if let Ok(b) = host_g.create_box("StringBox", &[]) {
|
if let Ok(b) = host_g.create_box("StringBox", &[]) {
|
||||||
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> = std::sync::Arc::from(b);
|
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> = 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);
|
nyash_rust::runtime::global_hooks::gc_alloc(0);
|
||||||
return h as i64;
|
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(host_g) = nyash_rust::runtime::get_global_plugin_host().read() {
|
||||||
if let Ok(b) = host_g.create_box("IntegerBox", &[]) {
|
if let Ok(b) = host_g.create_box("IntegerBox", &[]) {
|
||||||
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> = std::sync::Arc::from(b);
|
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> = 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);
|
nyash_rust::runtime::global_hooks::gc_alloc(0);
|
||||||
return h as i64;
|
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(host_g) = nyash_rust::runtime::get_global_plugin_host().read() {
|
||||||
if let Ok(b) = host_g.create_box("ConsoleBox", &[]) {
|
if let Ok(b) = host_g.create_box("ConsoleBox", &[]) {
|
||||||
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> = std::sync::Arc::from(b);
|
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> = 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);
|
nyash_rust::runtime::global_hooks::gc_alloc(0);
|
||||||
return h as i64;
|
return h as i64;
|
||||||
}
|
}
|
||||||
@ -587,7 +587,7 @@ pub extern "C" fn nyash_array_birth_h_export() -> i64 {
|
|||||||
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> =
|
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> =
|
||||||
std::sync::Arc::new(nyash_rust::boxes::array::ArrayBox::new());
|
std::sync::Arc::new(nyash_rust::boxes::array::ArrayBox::new());
|
||||||
nyash_rust::runtime::global_hooks::gc_alloc(0);
|
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
|
// 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<dyn nyash_rust::box_trait::NyashBox> =
|
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> =
|
||||||
std::sync::Arc::new(nyash_rust::boxes::map_box::MapBox::new());
|
std::sync::Arc::new(nyash_rust::boxes::map_box::MapBox::new());
|
||||||
nyash_rust::runtime::global_hooks::gc_alloc(0);
|
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) ----
|
// ---- Process entry (driver) ----
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
@ -777,8 +777,7 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use nyash_rust::{
|
use nyash_rust::{
|
||||||
box_trait::{NyashBox, StringBox},
|
box_trait::{NyashBox, StringBox},
|
||||||
jit::rt::handles,
|
runtime::{host_handles as handles, plugin_loader_v2::make_plugin_box_v2},
|
||||||
runtime::plugin_loader_v2::make_plugin_box_v2,
|
|
||||||
};
|
};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
@ -849,16 +848,16 @@ mod tests {
|
|||||||
fn decode_i32_and_string_returns() {
|
fn decode_i32_and_string_returns() {
|
||||||
let pb = make_plugin_box_v2("Dummy".into(), 1, 1, fake_i32);
|
let pb = make_plugin_box_v2("Dummy".into(), 1, 1, fake_i32);
|
||||||
let arc: Arc<dyn NyashBox> = Arc::new(pb);
|
let arc: Arc<dyn NyashBox> = 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);
|
let val = nyash_plugin_invoke3_tagged_i64(1, 0, 0, handle, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||||
assert_eq!(val, 123);
|
assert_eq!(val, 123);
|
||||||
|
|
||||||
let pb = make_plugin_box_v2("Dummy".into(), 1, 2, fake_str);
|
let pb = make_plugin_box_v2("Dummy".into(), 1, 2, fake_str);
|
||||||
let arc: Arc<dyn NyashBox> = Arc::new(pb);
|
let arc: Arc<dyn NyashBox> = 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);
|
let h = nyash_plugin_invoke3_tagged_i64(1, 0, 0, handle, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||||
assert!(h > 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::<StringBox>().unwrap();
|
let sb = obj.as_any().downcast_ref::<StringBox>().unwrap();
|
||||||
assert_eq!(sb.value, "hi");
|
assert_eq!(sb.value, "hi");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,14 +2,14 @@
|
|||||||
// Exported as: nyash_array_get_h(i64 handle, i64 idx) -> i64
|
// Exported as: nyash_array_get_h(i64 handle, i64 idx) -> i64
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn nyash_array_get_h(handle: i64, idx: i64) -> i64 {
|
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") {
|
if std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") {
|
||||||
eprintln!("[ARR] get_h(handle={}, idx={})", handle, idx);
|
eprintln!("[ARR] get_h(handle={}, idx={})", handle, idx);
|
||||||
}
|
}
|
||||||
if handle <= 0 || idx < 0 {
|
if handle <= 0 || idx < 0 {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if let Some(obj) = handles::get(handle) {
|
if let Some(obj) = handles::get(handle as u64) {
|
||||||
if let Some(arr) = obj
|
if let Some(arr) = obj
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<nyash_rust::boxes::array::ArrayBox>()
|
.downcast_ref::<nyash_rust::boxes::array::ArrayBox>()
|
||||||
@ -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
|
// Exported as: nyash_array_set_h(i64 handle, i64 idx, i64 val) -> i64
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn nyash_array_set_h(handle: i64, idx: i64, val: i64) -> i64 {
|
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") {
|
if std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") {
|
||||||
eprintln!("[ARR] set_h(handle={}, idx={}, val={})", handle, idx, val);
|
eprintln!("[ARR] set_h(handle={}, idx={}, val={})", handle, idx, val);
|
||||||
}
|
}
|
||||||
if handle <= 0 || idx < 0 {
|
if handle <= 0 || idx < 0 {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if let Some(obj) = handles::get(handle) {
|
if let Some(obj) = handles::get(handle as u64) {
|
||||||
if let Some(arr) = obj
|
if let Some(arr) = obj
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<nyash_rust::boxes::array::ArrayBox>()
|
.downcast_ref::<nyash_rust::boxes::array::ArrayBox>()
|
||||||
@ -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 {
|
pub extern "C" fn nyash_array_push_h(handle: i64, val: i64) -> i64 {
|
||||||
use nyash_rust::{
|
use nyash_rust::{
|
||||||
box_trait::{IntegerBox, NyashBox},
|
box_trait::{IntegerBox, NyashBox},
|
||||||
jit::rt::handles,
|
runtime::host_handles as handles,
|
||||||
};
|
};
|
||||||
if std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") {
|
if std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") {
|
||||||
eprintln!("[ARR] push_h(handle={}, val={})", handle, val);
|
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 {
|
if handle <= 0 {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if let Some(obj) = handles::get(handle) {
|
if let Some(obj) = handles::get(handle as u64) {
|
||||||
if let Some(arr) = obj
|
if let Some(arr) = obj
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<nyash_rust::boxes::array::ArrayBox>()
|
.downcast_ref::<nyash_rust::boxes::array::ArrayBox>()
|
||||||
{
|
{
|
||||||
// If val is handle, try to use it; otherwise treat as integer
|
// If val is handle, try to use it; otherwise treat as integer
|
||||||
let vbox: Box<dyn NyashBox> = if val > 0 {
|
let vbox: Box<dyn NyashBox> = if val > 0 {
|
||||||
if let Some(o) = handles::get(val) {
|
if let Some(o) = handles::get(val as u64) {
|
||||||
o.clone_box()
|
o.clone_box()
|
||||||
} else {
|
} else {
|
||||||
Box::new(IntegerBox::new(val))
|
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
|
// Exported as: nyash_array_length_h(i64 handle) -> i64
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn nyash_array_length_h(handle: i64) -> i64 {
|
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 {
|
if handle <= 0 {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if let Some(obj) = handles::get(handle) {
|
if let Some(obj) = handles::get(handle as u64) {
|
||||||
if let Some(arr) = obj
|
if let Some(arr) = obj
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<nyash_rust::boxes::array::ArrayBox>()
|
.downcast_ref::<nyash_rust::boxes::array::ArrayBox>()
|
||||||
|
|||||||
@ -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, &[]) {
|
if let Ok(b) = host_g.create_box(&meta.box_type, &[]) {
|
||||||
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> =
|
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> =
|
||||||
std::sync::Arc::from(b);
|
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") {
|
if std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") {
|
||||||
println!(
|
println!(
|
||||||
"nyrt: birth_h {} (type_id={}) -> handle={}",
|
"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 method_id: u32 = 0; // birth
|
||||||
let instance_id: u32 = 0; // static
|
let instance_id: u32 = 0; // static
|
||||||
// Build TLV args
|
// 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 nargs = argc.max(0) as usize;
|
||||||
let mut buf = nyash_rust::runtime::plugin_ffi_common::encode_tlv_header(nargs as u16);
|
let mut buf = nyash_rust::runtime::plugin_ffi_common::encode_tlv_header(nargs as u16);
|
||||||
let mut encode_handle = |h: i64| {
|
let mut encode_handle = |h: i64| {
|
||||||
if h > 0 {
|
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::<PluginBoxV2>() {
|
if let Some(p) = obj.as_any().downcast_ref::<PluginBoxV2>() {
|
||||||
let host = nyash_rust::runtime::get_global_plugin_host();
|
let host = nyash_rust::runtime::get_global_plugin_host();
|
||||||
if let Ok(hg) = host.read() {
|
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,
|
invoke_fn,
|
||||||
);
|
);
|
||||||
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> = std::sync::Arc::new(pb);
|
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> = 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") {
|
if std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") {
|
||||||
println!(
|
println!(
|
||||||
"nyrt: birth_i64 {} (type_id={}) argc={} -> handle={}",
|
"nyrt: birth_i64 {} (type_id={}) argc={} -> handle={}",
|
||||||
|
|||||||
@ -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
|
// Exported as: nyash.console.log_handle(i64 handle) -> i64
|
||||||
#[export_name = "nyash.console.log_handle"]
|
#[export_name = "nyash.console.log_handle"]
|
||||||
pub extern "C" fn nyash_console_log_handle(handle: i64) -> i64 {
|
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);
|
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;
|
let s = obj.to_string_box().value;
|
||||||
println!("{}", s);
|
println!("{}", s);
|
||||||
} else {
|
} else {
|
||||||
@ -36,7 +36,7 @@ pub extern "C" fn nyash_console_warn_handle(handle: i64) -> i64 {
|
|||||||
return 0;
|
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;
|
let s = obj.to_string_box().value;
|
||||||
eprintln!("WARN: {}", s);
|
eprintln!("WARN: {}", s);
|
||||||
} else {
|
} else {
|
||||||
@ -52,7 +52,7 @@ pub extern "C" fn nyash_console_error_handle(handle: i64) -> i64 {
|
|||||||
return 0;
|
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;
|
let s = obj.to_string_box().value;
|
||||||
eprintln!("ERROR: {}", s);
|
eprintln!("ERROR: {}", s);
|
||||||
} else {
|
} else {
|
||||||
@ -68,7 +68,7 @@ pub extern "C" fn nyash_debug_trace_handle(handle: i64) -> i64 {
|
|||||||
return 0;
|
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;
|
let s = obj.to_string_box().value;
|
||||||
eprintln!("TRACE: {}", s);
|
eprintln!("TRACE: {}", s);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -21,7 +21,7 @@ pub extern "C" fn nyash_future_spawn_method_h(
|
|||||||
let mut invoke: Option<
|
let mut invoke: Option<
|
||||||
unsafe extern "C" fn(u32, u32, u32, *const u8, usize, *mut u8, *mut usize) -> i32,
|
unsafe extern "C" fn(u32, u32, u32, *const u8, usize, *mut u8, *mut usize) -> i32,
|
||||||
> = None;
|
> = 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::<PluginBoxV2>() {
|
if let Some(p) = obj.as_any().downcast_ref::<PluginBoxV2>() {
|
||||||
instance_id = p.instance_id();
|
instance_id = p.instance_id();
|
||||||
real_type_id = p.inner.type_id;
|
real_type_id = p.inner.type_id;
|
||||||
@ -56,7 +56,7 @@ pub extern "C" fn nyash_future_spawn_method_h(
|
|||||||
}
|
}
|
||||||
8 => {
|
8 => {
|
||||||
if v > 0 {
|
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::<PluginBoxV2>() {
|
if let Some(p) = obj.as_any().downcast_ref::<PluginBoxV2>() {
|
||||||
// Try common coercions: String/Integer to TLV primitives
|
// Try common coercions: String/Integer to TLV primitives
|
||||||
let host = nyash_rust::runtime::get_global_plugin_host();
|
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
|
// Prepare FutureBox and register handle
|
||||||
let fut_box = std::sync::Arc::new(nyash_rust::boxes::future::FutureBox::new());
|
let fut_box = std::sync::Arc::new(nyash_rust::boxes::future::FutureBox::new());
|
||||||
let handle =
|
let handle =
|
||||||
nyash_rust::jit::rt::handles::to_handle(fut_box.clone() as std::sync::Arc<dyn NyashBox>);
|
nyash_rust::runtime::host_handles::to_handle_arc(fut_box.clone() as std::sync::Arc<dyn NyashBox>);
|
||||||
// Copy data for async task
|
// Copy data for async task
|
||||||
let cap: usize = 512;
|
let cap: usize = 512;
|
||||||
let tlv = buf.clone();
|
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
|
// Resolve receiver invoke and type id/name
|
||||||
let (instance_id, real_type_id, invoke) =
|
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::<PluginBoxV2>() {
|
if let Some(p) = obj.as_any().downcast_ref::<PluginBoxV2>() {
|
||||||
(p.instance_id(), p.inner.type_id, Some(p.inner.invoke_fn))
|
(p.instance_id(), p.inner.type_id, Some(p.inner.invoke_fn))
|
||||||
} else {
|
} 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)
|
// Determine method name string (from a1 handle→StringBox, or a1 as C string pointer, or legacy VM args)
|
||||||
let mut method_name: Option<String> = None;
|
let mut method_name: Option<String> = None;
|
||||||
if a1 > 0 {
|
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::<PluginBoxV2>() {
|
if let Some(p) = obj.as_any().downcast_ref::<PluginBoxV2>() {
|
||||||
if p.box_type == "StringBox" {
|
if p.box_type == "StringBox" {
|
||||||
// Limit the lifetime of the read guard to this inner block by avoiding an outer binding
|
// 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<u8>, val: i64, pos: usize| {
|
let mut encode_arg_into = |dst: &mut Vec<u8>, val: i64, pos: usize| {
|
||||||
let mut appended = false;
|
let mut appended = false;
|
||||||
if val > 0 {
|
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::<PluginBoxV2>() {
|
if let Some(p) = obj.as_any().downcast_ref::<PluginBoxV2>() {
|
||||||
let host = nyash_rust::runtime::get_global_plugin_host();
|
let host = nyash_rust::runtime::get_global_plugin_host();
|
||||||
if let Ok(hg) = host.read() {
|
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
|
// Create Future and schedule async invoke
|
||||||
let fut_box = std::sync::Arc::new(nyash_rust::boxes::future::FutureBox::new());
|
let fut_box = std::sync::Arc::new(nyash_rust::boxes::future::FutureBox::new());
|
||||||
let handle =
|
let handle =
|
||||||
nyash_rust::jit::rt::handles::to_handle(fut_box.clone() as std::sync::Arc<dyn NyashBox>);
|
nyash_rust::runtime::host_handles::to_handle_arc(fut_box.clone() as std::sync::Arc<dyn NyashBox>);
|
||||||
let tlv = buf.clone();
|
let tlv = buf.clone();
|
||||||
nyash_rust::runtime::global_hooks::spawn_task(
|
nyash_rust::runtime::global_hooks::spawn_task(
|
||||||
"nyash.future.spawn_instance3_i64",
|
"nyash.future.spawn_instance3_i64",
|
||||||
|
|||||||
@ -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 name = unsafe { std::ffi::CStr::from_ptr(name) };
|
||||||
let Ok(field) = name.to_str() else { return 0 };
|
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
|
if let Some(inst) = obj
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<nyash_rust::instance_v2::InstanceBox>()
|
.downcast_ref::<nyash_rust::instance_v2::InstanceBox>()
|
||||||
@ -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) {
|
if let Some(shared) = inst.get_field(field) {
|
||||||
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> =
|
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> =
|
||||||
std::sync::Arc::from(shared);
|
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;
|
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 name = unsafe { std::ffi::CStr::from_ptr(name) };
|
||||||
let Ok(field) = name.to_str() else { return 0 };
|
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
|
if let Some(inst) = obj
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<nyash_rust::instance_v2::InstanceBox>()
|
.downcast_ref::<nyash_rust::instance_v2::InstanceBox>()
|
||||||
{
|
{
|
||||||
if val_h > 0 {
|
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 shared: nyash_rust::box_trait::SharedNyashBox = std::sync::Arc::clone(&val);
|
||||||
let _ = inst.set_field(field, shared);
|
let _ = inst.set_field(field, shared);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -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,
|
unsafe extern "C" fn(u32, u32, u32, *const u8, usize, *mut u8, *mut usize) -> i32,
|
||||||
> = None;
|
> = None;
|
||||||
if a0 > 0 {
|
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::<PluginBoxV2>() {
|
if let Some(p) = obj.as_any().downcast_ref::<PluginBoxV2>() {
|
||||||
instance_id = p.instance_id();
|
instance_id = p.instance_id();
|
||||||
invoke = Some(p.inner.invoke_fn);
|
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,
|
unsafe extern "C" fn(u32, u32, u32, *const u8, usize, *mut u8, *mut usize) -> i32,
|
||||||
> = None;
|
> = None;
|
||||||
if a0 > 0 {
|
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::<PluginBoxV2>() {
|
if let Some(p) = obj.as_any().downcast_ref::<PluginBoxV2>() {
|
||||||
instance_id = p.instance_id();
|
instance_id = p.instance_id();
|
||||||
type_id = p.inner.type_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,
|
unsafe extern "C" fn(u32, u32, u32, *const u8, usize, *mut u8, *mut usize) -> i32,
|
||||||
> = None;
|
> = None;
|
||||||
if recv_handle > 0 {
|
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::<PluginBoxV2>() {
|
if let Some(p) = obj.as_any().downcast_ref::<PluginBoxV2>() {
|
||||||
instance_id = p.instance_id();
|
instance_id = p.instance_id();
|
||||||
type_id = p.inner.type_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<dyn nyash_rust::box_trait::NyashBox> =
|
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> =
|
||||||
std::sync::Arc::new(pb);
|
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;
|
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,
|
unsafe extern "C" fn(u32, u32, u32, *const u8, usize, *mut u8, *mut usize) -> i32,
|
||||||
> = None;
|
> = None;
|
||||||
if a0 > 0 {
|
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::<PluginBoxV2>() {
|
if let Some(p) = obj.as_any().downcast_ref::<PluginBoxV2>() {
|
||||||
instance_id = p.instance_id();
|
instance_id = p.instance_id();
|
||||||
real_type_id = p.inner.type_id;
|
real_type_id = p.inner.type_id;
|
||||||
@ -425,7 +425,7 @@ pub extern "C" fn nyash_plugin_invoke3_tagged_i64(
|
|||||||
}
|
}
|
||||||
8 => {
|
8 => {
|
||||||
if val > 0 {
|
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::<PluginBoxV2>() {
|
if let Some(p) = obj.as_any().downcast_ref::<PluginBoxV2>() {
|
||||||
nyash_rust::runtime::plugin_ffi_common::encode::plugin_handle(
|
nyash_rust::runtime::plugin_ffi_common::encode::plugin_handle(
|
||||||
&mut buf,
|
&mut buf,
|
||||||
@ -503,7 +503,7 @@ pub extern "C" fn nyash_plugin_invoke_tagged_v_i64(
|
|||||||
let mut invoke: Option<
|
let mut invoke: Option<
|
||||||
unsafe extern "C" fn(u32, u32, u32, *const u8, usize, *mut u8, *mut usize) -> i32,
|
unsafe extern "C" fn(u32, u32, u32, *const u8, usize, *mut u8, *mut usize) -> i32,
|
||||||
> = None;
|
> = 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::<PluginBoxV2>() {
|
if let Some(p) = obj.as_any().downcast_ref::<PluginBoxV2>() {
|
||||||
instance_id = p.instance_id();
|
instance_id = p.instance_id();
|
||||||
real_type_id = p.inner.type_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);
|
nyash_rust::runtime::plugin_ffi_common::encode::f64(&mut buf, f);
|
||||||
}
|
}
|
||||||
8 => {
|
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::<PluginBoxV2>() {
|
if let Some(p) = obj.as_any().downcast_ref::<PluginBoxV2>() {
|
||||||
nyash_rust::runtime::plugin_ffi_common::encode::plugin_handle(
|
nyash_rust::runtime::plugin_ffi_common::encode::plugin_handle(
|
||||||
&mut buf,
|
&mut buf,
|
||||||
|
|||||||
@ -15,7 +15,7 @@ pub struct Receiver {
|
|||||||
pub fn resolve_receiver_for_a0(a0: i64) -> Option<Receiver> {
|
pub fn resolve_receiver_for_a0(a0: i64) -> Option<Receiver> {
|
||||||
// 1) Handle registry (preferred)
|
// 1) Handle registry (preferred)
|
||||||
if a0 > 0 {
|
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::<PluginBoxV2>() {
|
if let Some(p) = obj.as_any().downcast_ref::<PluginBoxV2>() {
|
||||||
return Some(Receiver {
|
return Some(Receiver {
|
||||||
instance_id: p.instance_id(),
|
instance_id: p.instance_id(),
|
||||||
@ -113,7 +113,7 @@ pub fn decode_entry_to_i64(
|
|||||||
use nyash_rust::box_trait::{NyashBox, StringBox};
|
use nyash_rust::box_trait::{NyashBox, StringBox};
|
||||||
let s = nyash_rust::runtime::plugin_ffi_common::decode::string(payload);
|
let s = nyash_rust::runtime::plugin_ffi_common::decode::string(payload);
|
||||||
let arc: std::sync::Arc<dyn NyashBox> = std::sync::Arc::new(StringBox::new(s));
|
let arc: std::sync::Arc<dyn NyashBox> = 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)
|
Some(h as i64)
|
||||||
}
|
}
|
||||||
8 => {
|
8 => {
|
||||||
@ -139,7 +139,7 @@ pub fn decode_entry_to_i64(
|
|||||||
);
|
);
|
||||||
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> =
|
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> =
|
||||||
std::sync::Arc::new(pb);
|
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);
|
return Some(h as i64);
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
|
|||||||
@ -3,14 +3,14 @@
|
|||||||
// size: (handle) -> i64
|
// size: (handle) -> i64
|
||||||
#[export_name = "nyash.map.size_h"]
|
#[export_name = "nyash.map.size_h"]
|
||||||
pub extern "C" fn nyash_map_size_h(handle: i64) -> i64 {
|
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") {
|
if std::env::var("NYASH_LLVM_MAP_DEBUG").ok().as_deref() == Some("1") {
|
||||||
eprintln!("[MAP] size_h(handle={})", handle);
|
eprintln!("[MAP] size_h(handle={})", handle);
|
||||||
}
|
}
|
||||||
if handle <= 0 {
|
if handle <= 0 {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if let Some(obj) = handles::get(handle) {
|
if let Some(obj) = handles::get(handle as u64) {
|
||||||
if let Some(map) = obj
|
if let Some(map) = obj
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<nyash_rust::boxes::map_box::MapBox>()
|
.downcast_ref::<nyash_rust::boxes::map_box::MapBox>()
|
||||||
@ -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 {
|
pub extern "C" fn nyash_map_get_h(handle: i64, key: i64) -> i64 {
|
||||||
use nyash_rust::{
|
use nyash_rust::{
|
||||||
box_trait::{IntegerBox, NyashBox},
|
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") {
|
if std::env::var("NYASH_LLVM_MAP_DEBUG").ok().as_deref() == Some("1") {
|
||||||
eprintln!("[MAP] get_h(handle={}, key={})", handle, key);
|
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 {
|
if handle <= 0 {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if let Some(obj) = handles::get(handle) {
|
if let Some(obj) = handles::get(handle as u64) {
|
||||||
if let Some(map) = obj
|
if let Some(map) = obj
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<nyash_rust::boxes::map_box::MapBox>()
|
.downcast_ref::<nyash_rust::boxes::map_box::MapBox>()
|
||||||
@ -51,7 +51,7 @@ pub extern "C" fn nyash_map_get_h(handle: i64, key: i64) -> i64 {
|
|||||||
let kbox: Box<dyn NyashBox> = Box::new(IntegerBox::new(key));
|
let kbox: Box<dyn NyashBox> = Box::new(IntegerBox::new(key));
|
||||||
let v = map.get(kbox);
|
let v = map.get(kbox);
|
||||||
let arc: std::sync::Arc<dyn NyashBox> = std::sync::Arc::from(v);
|
let arc: std::sync::Arc<dyn NyashBox> = 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") {
|
if std::env::var("NYASH_LLVM_MAP_DEBUG").ok().as_deref() == Some("1") {
|
||||||
eprintln!("[MAP] get_h => handle {}", h);
|
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 {
|
pub extern "C" fn nyash_map_get_hh(handle: i64, key_any: i64) -> i64 {
|
||||||
use nyash_rust::{
|
use nyash_rust::{
|
||||||
box_trait::{IntegerBox, NyashBox},
|
box_trait::{IntegerBox, NyashBox},
|
||||||
jit::rt::handles,
|
runtime::host_handles as handles,
|
||||||
};
|
};
|
||||||
if handle <= 0 {
|
if handle <= 0 {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if let Some(obj) = handles::get(handle) {
|
if let Some(obj) = handles::get(handle as u64) {
|
||||||
if let Some(map) = obj
|
if let Some(map) = obj
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<nyash_rust::boxes::map_box::MapBox>()
|
.downcast_ref::<nyash_rust::boxes::map_box::MapBox>()
|
||||||
{
|
{
|
||||||
let key_box: Box<dyn NyashBox> = if key_any > 0 {
|
let key_box: Box<dyn NyashBox> = 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()
|
k.clone_box()
|
||||||
} else {
|
} else {
|
||||||
Box::new(IntegerBox::new(key_any))
|
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 v = map.get(key_box);
|
||||||
let arc: std::sync::Arc<dyn NyashBox> = std::sync::Arc::from(v);
|
let arc: std::sync::Arc<dyn NyashBox> = std::sync::Arc::from(v);
|
||||||
let h = handles::to_handle(arc);
|
let h = handles::to_handle_arc(arc) as u64;
|
||||||
return h as i64;
|
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 {
|
pub extern "C" fn nyash_map_set_h(handle: i64, key: i64, val: i64) -> i64 {
|
||||||
use nyash_rust::{
|
use nyash_rust::{
|
||||||
box_trait::{IntegerBox, NyashBox},
|
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") {
|
if std::env::var("NYASH_LLVM_MAP_DEBUG").ok().as_deref() == Some("1") {
|
||||||
eprintln!("[MAP] set_h(handle={}, key={}, val={})", handle, key, val);
|
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 {
|
if handle <= 0 {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if let Some(obj) = handles::get(handle) {
|
if let Some(obj) = handles::get(handle as u64) {
|
||||||
if let Some(map) = obj
|
if let Some(map) = obj
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<nyash_rust::boxes::map_box::MapBox>()
|
.downcast_ref::<nyash_rust::boxes::map_box::MapBox>()
|
||||||
{
|
{
|
||||||
let kbox: Box<dyn NyashBox> = Box::new(IntegerBox::new(key));
|
let kbox: Box<dyn NyashBox> = Box::new(IntegerBox::new(key));
|
||||||
let vbox: Box<dyn NyashBox> = if val > 0 {
|
let vbox: Box<dyn NyashBox> = if val > 0 {
|
||||||
if let Some(o) = handles::get(val) {
|
if let Some(o) = handles::get(val as u64) {
|
||||||
o.clone_box()
|
o.clone_box()
|
||||||
} else {
|
} else {
|
||||||
Box::new(IntegerBox::new(val))
|
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 {
|
pub extern "C" fn nyash_map_set_hh(handle: i64, key_any: i64, val_any: i64) -> i64 {
|
||||||
use nyash_rust::{
|
use nyash_rust::{
|
||||||
box_trait::{IntegerBox, NyashBox},
|
box_trait::{IntegerBox, NyashBox},
|
||||||
jit::rt::handles,
|
runtime::host_handles as handles,
|
||||||
};
|
};
|
||||||
if handle <= 0 {
|
if handle <= 0 {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if let Some(obj) = handles::get(handle) {
|
if let Some(obj) = handles::get(handle as u64) {
|
||||||
if let Some(map) = obj
|
if let Some(map) = obj
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<nyash_rust::boxes::map_box::MapBox>()
|
.downcast_ref::<nyash_rust::boxes::map_box::MapBox>()
|
||||||
{
|
{
|
||||||
let kbox: Box<dyn NyashBox> = if key_any > 0 {
|
let kbox: Box<dyn NyashBox> = 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()
|
k.clone_box()
|
||||||
} else {
|
} else {
|
||||||
Box::new(IntegerBox::new(key_any))
|
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))
|
Box::new(IntegerBox::new(key_any))
|
||||||
};
|
};
|
||||||
let vbox: Box<dyn NyashBox> = if val_any > 0 {
|
let vbox: Box<dyn NyashBox> = 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()
|
v.clone_box()
|
||||||
} else {
|
} else {
|
||||||
Box::new(IntegerBox::new(val_any))
|
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 {
|
pub extern "C" fn nyash_map_has_hh(handle: i64, key_any: i64) -> i64 {
|
||||||
use nyash_rust::{
|
use nyash_rust::{
|
||||||
box_trait::{BoolBox, IntegerBox, NyashBox},
|
box_trait::{BoolBox, IntegerBox, NyashBox},
|
||||||
jit::rt::handles,
|
runtime::host_handles as handles,
|
||||||
};
|
};
|
||||||
if handle <= 0 {
|
if handle <= 0 {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if let Some(obj) = handles::get(handle) {
|
if let Some(obj) = handles::get(handle as u64) {
|
||||||
if let Some(map) = obj
|
if let Some(map) = obj
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<nyash_rust::boxes::map_box::MapBox>()
|
.downcast_ref::<nyash_rust::boxes::map_box::MapBox>()
|
||||||
{
|
{
|
||||||
let kbox: Box<dyn NyashBox> = if key_any > 0 {
|
let kbox: Box<dyn NyashBox> = 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()
|
k.clone_box()
|
||||||
} else {
|
} else {
|
||||||
Box::new(IntegerBox::new(key_any))
|
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)
|
// has_h: (map_handle, key_i64) -> i64 (0/1)
|
||||||
#[export_name = "nyash.map.has_h"]
|
#[export_name = "nyash.map.has_h"]
|
||||||
pub extern "C" fn nyash_map_has_h(handle: i64, key: i64) -> i64 {
|
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 {
|
if handle <= 0 {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if let Some(obj) = handles::get(handle) {
|
if let Some(obj) = handles::get(handle as u64) {
|
||||||
if let Some(map) = obj
|
if let Some(map) = obj
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<nyash_rust::boxes::map_box::MapBox>()
|
.downcast_ref::<nyash_rust::boxes::map_box::MapBox>()
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
// Exported as: nyash.semantics.add_hh(i64 lhs_handle, i64 rhs_handle) -> i64 (NyashBox handle)
|
// Exported as: nyash.semantics.add_hh(i64 lhs_handle, i64 rhs_handle) -> i64 (NyashBox handle)
|
||||||
#[export_name = "nyash.semantics.add_hh"]
|
#[export_name = "nyash.semantics.add_hh"]
|
||||||
pub extern "C" fn nyash_semantics_add_hh_export(lhs_h: i64, rhs_h: i64) -> i64 {
|
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::{
|
use nyash_rust::{
|
||||||
box_trait::{IntegerBox, StringBox},
|
box_trait::{IntegerBox, StringBox},
|
||||||
runtime::semantics,
|
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 {
|
if lhs_h <= 0 || rhs_h <= 0 {
|
||||||
return 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
|
obj
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
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
|
obj
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
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 s = format!("{}{}", ls, rs);
|
||||||
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> =
|
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> =
|
||||||
std::sync::Arc::new(StringBox::new(s));
|
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)) = (
|
if let (Some(li), Some(ri)) = (
|
||||||
semantics::coerce_to_i64(lhs.as_ref()),
|
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<dyn nyash_rust::box_trait::NyashBox> =
|
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> =
|
||||||
std::sync::Arc::new(IntegerBox::new(li + ri));
|
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
|
// Fallback: stringify both and concat to preserve total order
|
||||||
let ls = lhs.to_string_box().value;
|
let ls = lhs.to_string_box().value;
|
||||||
let rs = rhs.to_string_box().value;
|
let rs = rhs.to_string_box().value;
|
||||||
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> =
|
let arc: std::sync::Arc<dyn nyash_rust::box_trait::NyashBox> =
|
||||||
std::sync::Arc::new(StringBox::new(format!("{}{}", ls, rs)));
|
std::sync::Arc::new(StringBox::new(format!("{}{}", ls, rs)));
|
||||||
handles::to_handle(arc) as i64
|
handles::to_handle_arc(arc) as i64
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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*
|
// Exported as: nyash.string.to_i8p_h(i64 handle) -> i8*
|
||||||
#[export_name = "nyash.string.to_i8p_h"]
|
#[export_name = "nyash.string.to_i8p_h"]
|
||||||
pub extern "C" fn nyash_string_to_i8p_h(handle: i64) -> *mut i8 {
|
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 {
|
if handle <= 0 {
|
||||||
// return "0" for consistency with existing fallback behavior
|
// return "0" for consistency with existing fallback behavior
|
||||||
let s = handle.to_string();
|
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;
|
let raw = Box::into_raw(boxed) as *mut u8;
|
||||||
return raw as *mut i8;
|
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 s = obj.to_string_box().value;
|
||||||
let mut bytes = s.into_bytes();
|
let mut bytes = s.into_bytes();
|
||||||
bytes.push(0);
|
bytes.push(0);
|
||||||
|
|||||||
@ -65,5 +65,13 @@
|
|||||||
- C) 代替ルートの準備(任意)
|
- C) 代替ルートの準備(任意)
|
||||||
- アーカイバ経路の helper(`.o + libnyash_kernel.a → exe`)を復帰し、ハーネス依存を迂回可能にする。
|
- アーカイバ経路の 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)で保全し、段階的に進める。
|
- main は docs 復元のみコミット済み。AOT 関連の差分は phase33 ブランチ(または stash)で保全し、段階的に進める。
|
||||||
|
|||||||
@ -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
|
# 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:
|
if not use_unified:
|
||||||
# Fall back to legacy dispatching
|
# Fall back to legacy dispatching
|
||||||
return lower_legacy_call(owner, builder, mir_call, dst_vid, vmap, resolver)
|
return lower_legacy_call(owner, builder, mir_call, dst_vid, vmap, resolver)
|
||||||
|
|||||||
Reference in New Issue
Block a user