Phase 12.7完了 + ChatGPT5によるVMリファクタリング

## 📚 Phase 12.7 ドキュメント整理
- ChatGPT5作成のANCP Token仕様書v1を整備
- フォルダ構造を機能別に再編成:
  - ancp-specs/ : ANCP圧縮技法仕様
  - grammar-specs/ : 文法改革仕様
  - implementation/ : 実装計画
  - ai-feedback/ : AIアドバイザーフィードバック
- 各フォルダにREADME.md作成で導線改善

## 🔧 ChatGPT5によるVMリファクタリング
- vm_instructions.rs (1927行) をモジュール分割:
  - boxcall.rs : Box呼び出し処理
  - call.rs : 関数呼び出し処理
  - extern_call.rs : 外部関数処理
  - function_new.rs : FunctionBox生成
  - newbox.rs : Box生成処理
  - plugin_invoke.rs : プラグイン呼び出し
- VM実行をファイル分割で整理:
  - vm_state.rs : 状態管理
  - vm_exec.rs : 実行エンジン
  - vm_control_flow.rs : 制御フロー
  - vm_gc.rs : GC処理
- plugin_loader_v2もモジュール化

##  新機能実装
- FunctionBox呼び出しのVM/MIR統一進捗
- ラムダ式のFunctionBox変換テスト追加
- 関数値の直接呼び出し基盤整備

次ステップ: ANCPプロトタイプ実装開始(Week 1)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm
2025-09-04 03:41:02 +09:00
parent 7455c9ec97
commit 6488b0542e
57 changed files with 3803 additions and 3871 deletions

View File

@ -0,0 +1,74 @@
/*!
* Builtin Box Factory
*
* Provides constructors for core builtin Box types so that the unified
* registry can create them without relying on plugins.
* Priority order in UnifiedBoxRegistry remains: builtin > user > plugin.
*/
use super::BoxFactory;
use crate::box_trait::{NyashBox, StringBox, IntegerBox, BoolBox};
use crate::interpreter::RuntimeError;
/// Factory for builtin Box types
pub struct BuiltinBoxFactory;
impl BuiltinBoxFactory {
pub fn new() -> Self { Self }
}
impl BoxFactory for BuiltinBoxFactory {
fn create_box(
&self,
name: &str,
args: &[Box<dyn NyashBox>],
) -> Result<Box<dyn NyashBox>, RuntimeError> {
match name {
// Primitive wrappers
"StringBox" => {
if let Some(arg0) = args.get(0) {
if let Some(sb) = arg0.as_any().downcast_ref::<StringBox>() {
return Ok(Box::new(StringBox::new(&sb.value)));
}
}
Ok(Box::new(StringBox::new("")))
}
"IntegerBox" => {
if let Some(arg0) = args.get(0) {
if let Some(ib) = arg0.as_any().downcast_ref::<IntegerBox>() {
return Ok(Box::new(IntegerBox::new(ib.value)));
}
}
Ok(Box::new(IntegerBox::new(0)))
}
"BoolBox" => {
if let Some(arg0) = args.get(0) {
if let Some(bb) = arg0.as_any().downcast_ref::<BoolBox>() {
return Ok(Box::new(BoolBox::new(bb.value)));
}
}
Ok(Box::new(BoolBox::new(false)))
}
// Collections and common boxes
"ArrayBox" => Ok(Box::new(crate::boxes::array::ArrayBox::new())),
"MapBox" => Ok(Box::new(crate::boxes::map_box::MapBox::new())),
"ConsoleBox" => Ok(Box::new(crate::boxes::console_box::ConsoleBox::new())),
"NullBox" => Ok(Box::new(crate::boxes::null_box::NullBox::new())),
// Leave other types to other factories (user/plugin)
_ => Err(RuntimeError::InvalidOperation { message: format!("Unknown Box type: {}", name) }),
}
}
fn box_types(&self) -> Vec<&str> {
vec![
// Primitive wrappers
"StringBox", "IntegerBox", "BoolBox",
// Collections/common
"ArrayBox", "MapBox", "ConsoleBox", "NullBox",
]
}
fn is_builtin_factory(&self) -> bool { true }
}

View File

@ -208,6 +208,7 @@ impl UnifiedBoxRegistry {
/// Re-export submodules
pub mod user_defined;
pub mod plugin;
pub mod builtin;
#[cfg(test)]
mod tests {