## 📚 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>
58 lines
1.9 KiB
Rust
58 lines
1.9 KiB
Rust
/*!
|
|
* Global Unified Box Registry
|
|
*
|
|
* Manages the global instance of UnifiedBoxRegistry
|
|
* Integrates all Box creation sources (builtin, user-defined, plugin)
|
|
*/
|
|
|
|
use crate::box_factory::UnifiedBoxRegistry;
|
|
use crate::box_factory::builtin::BuiltinBoxFactory;
|
|
#[cfg(feature = "plugins")]
|
|
use crate::box_factory::plugin::PluginBoxFactory;
|
|
use std::sync::{Arc, Mutex, OnceLock};
|
|
|
|
/// Global registry instance
|
|
static GLOBAL_REGISTRY: OnceLock<Arc<Mutex<UnifiedBoxRegistry>>> = OnceLock::new();
|
|
|
|
/// Initialize the global unified registry
|
|
pub fn init_global_unified_registry() {
|
|
GLOBAL_REGISTRY.get_or_init(|| {
|
|
let mut registry = UnifiedBoxRegistry::new();
|
|
// Builtins enabled only for wasm32, tests, or when feature "builtin-core" is set
|
|
#[cfg(any(test, target_arch = "wasm32", feature = "builtin-core"))]
|
|
{
|
|
registry.register(std::sync::Arc::new(BuiltinBoxFactory::new()));
|
|
}
|
|
|
|
// Register plugin Box factory (primary)
|
|
#[cfg(feature = "plugins")]
|
|
{
|
|
registry.register(Arc::new(PluginBoxFactory::new()));
|
|
}
|
|
|
|
// TODO: User-defined Box factory will be registered by interpreter
|
|
|
|
Arc::new(Mutex::new(registry))
|
|
});
|
|
}
|
|
|
|
/// Get the global unified registry
|
|
pub fn get_global_unified_registry() -> Arc<Mutex<UnifiedBoxRegistry>> {
|
|
init_global_unified_registry();
|
|
GLOBAL_REGISTRY.get().unwrap().clone()
|
|
}
|
|
|
|
/// Register a user-defined Box factory (called by interpreter)
|
|
pub fn register_user_defined_factory(factory: Arc<dyn crate::box_factory::BoxFactory>) {
|
|
let registry = get_global_unified_registry();
|
|
let mut registry_lock = registry.lock().unwrap();
|
|
|
|
// Insert at position 1 (after builtin, before plugin)
|
|
// This maintains priority: builtin > user > plugin
|
|
if registry_lock.factories.len() >= 2 {
|
|
registry_lock.factories.insert(1, factory);
|
|
} else {
|
|
registry_lock.register(factory);
|
|
}
|
|
}
|