restore(lang/compiler): bring back lang/src/compiler from e917d400; add Hako index canaries and docs; implement Rust-side index operator (Array/Map get/set) with Fail‑Fast diagnostics
- restore: lang/src/compiler/** (parser/emit/builder/pipeline_v2) from e917d400 - docs: docs/development/selfhosting/index-operator-hako.md - smokes(hako): tools/smokes/v2/profiles/quick/core/index_operator_hako.sh (opt-in) - smokes(vm): adjust index_operator_vm.sh for semicolon gate + stable error text - rust/parser: allow IndexExpr and assignment LHS=Index; postfix parse LBRACK chain - rust/builder: lower arr/map index to BoxCall get/set; annotate array/map literals; Fail‑Fast for unsupported types - CURRENT_TASK: mark Rust side done; add Hako tasks checklist Note: files disappeared likely due to branch FF to a lineage without lang/src/compiler; no explicit delete commit found. Added anchor checks and suggested CI guard in follow-up.
This commit is contained in:
@ -234,7 +234,7 @@ pub extern "C" fn nyash_box_from_i64(val: i64) -> i64 {
|
||||
pub extern "C" fn nyash_env_box_new(type_name: *const i8) -> i64 {
|
||||
use nyash_rust::{
|
||||
box_trait::NyashBox,
|
||||
runtime::{host_handles as handles, box_registry::get_global_registry},
|
||||
runtime::{box_registry::get_global_registry, host_handles as handles},
|
||||
};
|
||||
use std::ffi::CStr;
|
||||
if type_name.is_null() {
|
||||
@ -283,7 +283,7 @@ pub extern "C" fn nyash_env_box_new_i64x(
|
||||
) -> i64 {
|
||||
use nyash_rust::{
|
||||
box_trait::{IntegerBox, NyashBox},
|
||||
runtime::{host_handles as handles, box_registry::get_global_registry},
|
||||
runtime::{box_registry::get_global_registry, host_handles as handles},
|
||||
};
|
||||
use std::ffi::CStr;
|
||||
if type_name.is_null() {
|
||||
@ -353,7 +353,7 @@ pub extern "C" fn nyash_any_length_h_export(handle: i64) -> i64 {
|
||||
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 as u64).is_some()
|
||||
handles::get(handle as u64).is_some()
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
@ -112,8 +112,9 @@ 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::runtime::host_handles::to_handle_arc(fut_box.clone() as std::sync::Arc<dyn NyashBox>);
|
||||
let handle = nyash_rust::runtime::host_handles::to_handle_arc(
|
||||
fut_box.clone() as std::sync::Arc<dyn NyashBox>
|
||||
);
|
||||
// Copy data for async task
|
||||
let cap: usize = 512;
|
||||
let tlv = buf.clone();
|
||||
@ -245,7 +246,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::runtime::host_handles::get(a0 as u64) {
|
||||
if let Some(obj) = nyash_rust::runtime::host_handles::get(a0 as u64) {
|
||||
if let Some(p) = obj.as_any().downcast_ref::<PluginBoxV2>() {
|
||||
(p.instance_id(), p.inner.type_id, Some(p.inner.invoke_fn))
|
||||
} else {
|
||||
@ -265,7 +266,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<String> = None;
|
||||
if a1 > 0 {
|
||||
if let Some(obj) = nyash_rust::runtime::host_handles::get(a1 as u64) {
|
||||
if let Some(obj) = nyash_rust::runtime::host_handles::get(a1 as u64) {
|
||||
if let Some(p) = obj.as_any().downcast_ref::<PluginBoxV2>() {
|
||||
if p.box_type == "StringBox" {
|
||||
// Limit the lifetime of the read guard to this inner block by avoiding an outer binding
|
||||
@ -388,8 +389,9 @@ 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::runtime::host_handles::to_handle_arc(fut_box.clone() as std::sync::Arc<dyn NyashBox>);
|
||||
let handle = nyash_rust::runtime::host_handles::to_handle_arc(
|
||||
fut_box.clone() as std::sync::Arc<dyn NyashBox>
|
||||
);
|
||||
let tlv = buf.clone();
|
||||
nyash_rust::runtime::global_hooks::spawn_task(
|
||||
"nyash.future.spawn_instance3_i64",
|
||||
|
||||
@ -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::runtime::host_handles::get(a0 as u64) {
|
||||
if let Some(obj) = nyash_rust::runtime::host_handles::get(a0 as u64) {
|
||||
if let Some(p) = obj.as_any().downcast_ref::<PluginBoxV2>() {
|
||||
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::runtime::host_handles::get(a0 as u64) {
|
||||
if let Some(obj) = nyash_rust::runtime::host_handles::get(a0 as u64) {
|
||||
if let Some(p) = obj.as_any().downcast_ref::<PluginBoxV2>() {
|
||||
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::runtime::host_handles::get(recv_handle as u64) {
|
||||
if let Some(obj) = nyash_rust::runtime::host_handles::get(recv_handle as u64) {
|
||||
if let Some(p) = obj.as_any().downcast_ref::<PluginBoxV2>() {
|
||||
instance_id = p.instance_id();
|
||||
type_id = p.inner.type_id;
|
||||
@ -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::runtime::host_handles::get(a0 as u64) {
|
||||
if let Some(obj) = nyash_rust::runtime::host_handles::get(a0 as u64) {
|
||||
if let Some(p) = obj.as_any().downcast_ref::<PluginBoxV2>() {
|
||||
instance_id = p.instance_id();
|
||||
real_type_id = p.inner.type_id;
|
||||
|
||||
@ -15,7 +15,7 @@ pub struct Receiver {
|
||||
pub fn resolve_receiver_for_a0(a0: i64) -> Option<Receiver> {
|
||||
// 1) Handle registry (preferred)
|
||||
if a0 > 0 {
|
||||
if let Some(obj) = nyash_rust::runtime::host_handles::get(a0 as u64) {
|
||||
if let Some(obj) = nyash_rust::runtime::host_handles::get(a0 as u64) {
|
||||
if let Some(p) = obj.as_any().downcast_ref::<PluginBoxV2>() {
|
||||
return Some(Receiver {
|
||||
instance_id: p.instance_id(),
|
||||
|
||||
Reference in New Issue
Block a user