feat(phase-21.8+25): Complete imports resolution + Ring0/Ring1 numeric ABI design

Phase 21.8 完了 (imports resolution):
-  using nyash.core.numeric.matrix_i64 as MatI64 完全対応
-  hakorune_emit_mir.sh で imports 抽出・MirBuilder に配線
-  MatI64/IntArrayCore の静的参照解決が安定動作
-  matmul_core ベンチ MIR 生成成功 (VM/LLVM 両対応)

Phase 25 設計完了 (Ring0/Ring1 + numeric ABI):
- 🎯 Ring0/Ring1 責務分離を明文化 (Rust Freeze Policy 具体化)
- 🎯 Call/ExternCall 明確な分離設計
  - Call: Ring1 Hako 関数 (numeric core 等)
  - ExternCall: Ring0 intrinsic (rt_mem_* 等の FFI のみ)
- 🎯 BoxCall → Call 変換方針確定 (AotPrep で実施)
- 🎯 MatI64.mul_naive を NyNumericMatI64.mul_naive に分離
  (System Hakorune subset で完全実装済み)

実装:
-  AotPrepNumericCoreBox 診断パス実装 (NYASH_AOT_NUMERIC_CORE=1)
-  numeric ABI ドキュメント整備 (NUMERIC_ABI.md)
-  System Hakorune subset 定義 (system-hakorune-subset.md)
-  IntArrayCore/MatI64 仕様固定 (lang/src/runtime/numeric/README.md)
-  ENV_VARS.md に NYASH_AOT_NUMERIC_CORE トグル追記

今後のタスク:
- BoxCall(MatI64) → Call(NyNumericMatI64) 変換実装 (opt-in)
- IntArrayCore の numeric core 整備
- matmul_core スモークテスト (NYASH_AOT_NUMERIC_CORE=0/1 両対応)

🎉 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-11-14 20:19:00 +09:00
parent 8c4d63bfbb
commit 864a94d013
11 changed files with 716 additions and 34 deletions

View File

@ -68,7 +68,7 @@ impl BoxCore for IntArrayCore {
}
fn fmt_box(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "IntArrayCore(len={})", self.data.len())
write!(f, "IntArrayCore(len={})", self.data.read().unwrap().len())
}
fn as_any(&self) -> &dyn Any {
@ -82,12 +82,12 @@ impl BoxCore for IntArrayCore {
impl NyashBox for IntArrayCore {
fn to_string_box(&self) -> StringBox {
StringBox::new(&format!("IntArrayCore(len={})", self.data.len()))
StringBox::new(&format!("IntArrayCore(len={})", self.data.read().unwrap().len()))
}
fn equals(&self, other: &dyn NyashBox) -> BoolBox {
if let Some(o) = other.as_any().downcast_ref::<IntArrayCore>() {
BoolBox::new(self.data == o.data)
BoolBox::new(*self.data.read().unwrap() == *o.data.read().unwrap())
} else {
BoolBox::new(false)
}
@ -115,19 +115,19 @@ fn get_core(handle: i64) -> Option<std::sync::Arc<dyn NyashBox>> {
handles::get(handle as u64)
}
#[export_name = \"nyash.intarray.new_h\"]
pub extern \"C\" fn nyash_intarray_new_h(len: i64) -> i64 {
#[export_name = "nyash.intarray.new_h"]
pub extern "C" fn nyash_intarray_new_h(len: i64) -> i64 {
let core = IntArrayCore::new(len);
let arc: std::sync::Arc<dyn NyashBox> = std::sync::Arc::new(core);
let h = handles::to_handle_arc(arc) as i64;
if std::env::var(\"NYASH_CLI_VERBOSE\").ok().as_deref() == Some(\"1\") {
eprintln!(\"[INTARRAY] new_h(len={}) -> handle={}\", len, h);
if std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") {
eprintln!("[INTARRAY] new_h(len={}) -> handle={}", len, h);
}
h
}
#[export_name = \"nyash.intarray.len_h\"]
pub extern \"C\" fn nyash_intarray_len_h(handle: i64) -> i64 {
#[export_name = "nyash.intarray.len_h"]
pub extern "C" fn nyash_intarray_len_h(handle: i64) -> i64 {
if let Some(obj) = get_core(handle) {
if let Some(core) = obj.as_any().downcast_ref::<IntArrayCore>() {
return core.len_i64();
@ -136,8 +136,8 @@ pub extern \"C\" fn nyash_intarray_len_h(handle: i64) -> i64 {
0
}
#[export_name = \"nyash.intarray.get_hi\"]
pub extern \"C\" fn nyash_intarray_get_hi(handle: i64, idx: i64) -> i64 {
#[export_name = "nyash.intarray.get_hi"]
pub extern "C" fn nyash_intarray_get_hi(handle: i64, idx: i64) -> i64 {
if let Some(obj) = get_core(handle) {
if let Some(core) = obj.as_any().downcast_ref::<IntArrayCore>() {
if let Some(v) = core.get_i64(idx) {
@ -148,8 +148,8 @@ pub extern \"C\" fn nyash_intarray_get_hi(handle: i64, idx: i64) -> i64 {
0
}
#[export_name = \"nyash.intarray.set_hii\"]
pub extern \"C\" fn nyash_intarray_set_hii(handle: i64, idx: i64, val: i64) -> i64 {
#[export_name = "nyash.intarray.set_hii"]
pub extern "C" fn nyash_intarray_set_hii(handle: i64, idx: i64, val: i64) -> i64 {
if let Some(obj) = get_core(handle) {
if let Some(core) = obj.as_any().downcast_ref::<IntArrayCore>() {
return if core.set_i64(idx, val) { 0 } else { 1 };