Phase 22.1 WIP: SSOT resolver + TLV infrastructure + Hako MIR builder setup
Setup infrastructure for Phase 22.1 (TLV C shim & Resolver SSOT):
Core changes:
- Add nyash_tlv, nyash_c_core, nyash_kernel_min_c crates (opt-in)
- Implement SSOT resolver bridge (src/using/ssot_bridge.rs)
- Add HAKO_USING_SSOT=1 / HAKO_USING_SSOT_HAKO=1 env support
- Add HAKO_TLV_SHIM=1 infrastructure (requires --features tlv-shim)
MIR builder improvements:
- Fix using/alias consistency in Hako MIR builder
- Add hako.mir.builder.internal.{prog_scan,pattern_util} to nyash.toml
- Normalize LLVM extern calls: nyash.console.* → nyash_console_*
Smoke tests:
- Add phase2211 tests (using_ssot_hako_parity_canary_vm.sh)
- Add phase2220, phase2230, phase2231 test structure
- Add phase2100 S3 backend selector tests
- Improve test_runner.sh with quiet/timeout controls
Documentation:
- Add docs/ENV_VARS.md (Phase 22.1 env vars reference)
- Add docs/development/runtime/C_CORE_ABI.md
- Update de-rust-roadmap.md with Phase 22.x details
Tools:
- Add tools/hakorune_emit_mir.sh (Hako-first MIR emission wrapper)
- Add tools/tlv_roundtrip_smoke.sh placeholder
- Improve ny_mir_builder.sh with better backend selection
Known issues (to be fixed):
- Parser infinite loop in static method parameter parsing
- Stage-B output contamination with "RC: 0" (needs NYASH_JSON_ONLY=1)
- phase2211/using_ssot_hako_parity_canary_vm.sh fork bomb (needs recursion guard)
Next steps: Fix parser infinite loop + Stage-B quiet mode for green tests
This commit is contained in:
13
crates/nyash_c_core/Cargo.toml
Normal file
13
crates/nyash_c_core/Cargo.toml
Normal file
@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "nyash-c-core"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
name = "nyash_c_core"
|
||||
path = "src/lib.rs"
|
||||
crate-type = ["rlib", "staticlib"]
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1.0"
|
||||
|
||||
8
crates/nyash_c_core/build.rs
Normal file
8
crates/nyash_c_core/build.rs
Normal file
@ -0,0 +1,8 @@
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=src/c_core.c");
|
||||
cc::Build::new()
|
||||
.file("src/c_core.c")
|
||||
.warnings(false)
|
||||
.compile("nyash_c_core_c");
|
||||
}
|
||||
|
||||
31
crates/nyash_c_core/src/c_core.c
Normal file
31
crates/nyash_c_core/src/c_core.c
Normal file
@ -0,0 +1,31 @@
|
||||
#include <stdint.h>
|
||||
|
||||
// Design-stage C core probe. Returns 0 on success.
|
||||
int ny_core_probe_invoke(const char* target, const char* method, int32_t argc) {
|
||||
// For now, just return success without doing anything.
|
||||
(void)target; (void)method; (void)argc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Design-stage: MapBox.set stub (no-op). Returns 0 on success.
|
||||
int ny_core_map_set(int32_t type_id, uint32_t instance_id, const char* key, const char* val) {
|
||||
(void)type_id; (void)instance_id; (void)key; (void)val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Design-stage: ArrayBox.push stub (no-op). Returns 0 on success.
|
||||
int ny_core_array_push(int32_t type_id, uint32_t instance_id, long long val) {
|
||||
(void)type_id; (void)instance_id; (void)val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Design-stage: ArrayBox.get/size stubs (no-op). Return 0 success.
|
||||
int ny_core_array_get(int32_t type_id, uint32_t instance_id, long long idx) {
|
||||
(void)type_id; (void)instance_id; (void)idx;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ny_core_array_len(int32_t type_id, uint32_t instance_id) {
|
||||
(void)type_id; (void)instance_id;
|
||||
return 0;
|
||||
}
|
||||
37
crates/nyash_c_core/src/lib.rs
Normal file
37
crates/nyash_c_core/src/lib.rs
Normal file
@ -0,0 +1,37 @@
|
||||
#[allow(non_camel_case_types)]
|
||||
type c_int = i32;
|
||||
|
||||
extern "C" {
|
||||
fn ny_core_probe_invoke(target: *const u8, method: *const u8, argc: c_int) -> c_int;
|
||||
fn ny_core_map_set(type_id: i32, instance_id: u32, key: *const u8, val: *const u8) -> c_int;
|
||||
fn ny_core_array_push(type_id: i32, instance_id: u32, val: i64) -> c_int;
|
||||
fn ny_core_array_get(type_id: i32, instance_id: u32, idx: i64) -> c_int;
|
||||
fn ny_core_array_len(type_id: i32, instance_id: u32) -> c_int;
|
||||
}
|
||||
|
||||
/// Safe wrapper for core probe invoke (design-stage)
|
||||
pub fn core_probe_invoke(target: &str, method: &str, argc: i32) -> i32 {
|
||||
let t = std::ffi::CString::new(target).unwrap_or_else(|_| std::ffi::CString::new("?").unwrap());
|
||||
let m = std::ffi::CString::new(method).unwrap_or_else(|_| std::ffi::CString::new("?").unwrap());
|
||||
unsafe { ny_core_probe_invoke(t.as_ptr() as *const u8, m.as_ptr() as *const u8, argc as c_int) as i32 }
|
||||
}
|
||||
|
||||
/// MapBox.set stub (design-stage): returns 0 on success
|
||||
pub fn core_map_set(type_id: i32, instance_id: u32, key: &str, val: &str) -> i32 {
|
||||
let k = std::ffi::CString::new(key).unwrap_or_else(|_| std::ffi::CString::new("").unwrap());
|
||||
let v = std::ffi::CString::new(val).unwrap_or_else(|_| std::ffi::CString::new("").unwrap());
|
||||
unsafe { ny_core_map_set(type_id as i32, instance_id as u32, k.as_ptr() as *const u8, v.as_ptr() as *const u8) as i32 }
|
||||
}
|
||||
|
||||
/// ArrayBox.push stub (design-stage): returns 0 on success
|
||||
pub fn core_array_push(type_id: i32, instance_id: u32, val: i64) -> i32 {
|
||||
unsafe { ny_core_array_push(type_id as i32, instance_id as u32, val as i64) as i32 }
|
||||
}
|
||||
|
||||
pub fn core_array_get(type_id: i32, instance_id: u32, idx: i64) -> i32 {
|
||||
unsafe { ny_core_array_get(type_id as i32, instance_id as u32, idx as i64) as i32 }
|
||||
}
|
||||
|
||||
pub fn core_array_len(type_id: i32, instance_id: u32) -> i32 {
|
||||
unsafe { ny_core_array_len(type_id as i32, instance_id as u32) as i32 }
|
||||
}
|
||||
Reference in New Issue
Block a user