Phase 25.1a: selfhost builder hotfix (fn rename, docs)
This commit is contained in:
@ -82,11 +82,17 @@ pub extern "C" fn nyash_string_charcode_at_h_export(handle: i64, idx: i64) -> i6
|
||||
// Exported as: nyash.env.argv_get() -> i64 (ArrayBox handle)
|
||||
#[export_name = "nyash.env.argv_get"]
|
||||
pub extern "C" fn nyash_env_argv_get() -> i64 {
|
||||
use nyash_rust::{box_trait::{NyashBox, StringBox}, boxes::array::ArrayBox, runtime::host_handles as handles};
|
||||
use nyash_rust::{
|
||||
box_trait::{NyashBox, StringBox},
|
||||
boxes::array::ArrayBox,
|
||||
runtime::host_handles as handles,
|
||||
};
|
||||
let mut arr = ArrayBox::new();
|
||||
// Skip argv[0] (program name), collect the rest
|
||||
for (i, a) in std::env::args().enumerate() {
|
||||
if i == 0 { continue; }
|
||||
if i == 0 {
|
||||
continue;
|
||||
}
|
||||
let sb: Box<dyn NyashBox> = Box::new(StringBox::new(a));
|
||||
let _ = arr.push(sb);
|
||||
}
|
||||
|
||||
@ -82,7 +82,10 @@ impl BoxCore for IntArrayCore {
|
||||
|
||||
impl NyashBox for IntArrayCore {
|
||||
fn to_string_box(&self) -> StringBox {
|
||||
StringBox::new(&format!("IntArrayCore(len={})", self.data.read().unwrap().len()))
|
||||
StringBox::new(&format!(
|
||||
"IntArrayCore(len={})",
|
||||
self.data.read().unwrap().len()
|
||||
))
|
||||
}
|
||||
|
||||
fn equals(&self, other: &dyn NyashBox) -> BoolBox {
|
||||
|
||||
@ -3,10 +3,10 @@ pub mod birth;
|
||||
pub mod console;
|
||||
pub mod future;
|
||||
pub mod instance;
|
||||
pub mod intarray;
|
||||
pub mod invoke;
|
||||
pub mod invoke_core;
|
||||
pub mod map;
|
||||
pub mod intarray;
|
||||
pub mod semantics;
|
||||
pub mod string;
|
||||
|
||||
@ -15,9 +15,9 @@ pub use birth::*;
|
||||
pub use console::*;
|
||||
pub use future::*;
|
||||
pub use instance::*;
|
||||
pub use intarray::*;
|
||||
pub use invoke::*;
|
||||
pub use invoke_core::*;
|
||||
pub use map::*;
|
||||
pub use intarray::*;
|
||||
pub use semantics::*;
|
||||
pub use string::*;
|
||||
|
||||
@ -151,9 +151,11 @@ pub extern "C" fn nyash_string_length_si(s: *const i8, mode: i64) -> i64 {
|
||||
let cs = unsafe { CStr::from_ptr(s) };
|
||||
// Safe UTF-8 conversion; on failure, fall back to byte length scan
|
||||
if let Ok(st) = cs.to_str() {
|
||||
if mode == 1 { // char count
|
||||
if mode == 1 {
|
||||
// char count
|
||||
return st.chars().count() as i64;
|
||||
} else { // byte length
|
||||
} else {
|
||||
// byte length
|
||||
return st.as_bytes().len() as i64;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user