2025-08-19 16:43:13 +09:00
|
|
|
/*!
|
|
|
|
|
* Global Unified Box Registry
|
2025-09-17 07:43:07 +09:00
|
|
|
*
|
2025-08-19 16:43:13 +09:00
|
|
|
* Manages the global instance of UnifiedBoxRegistry
|
|
|
|
|
* Integrates all Box creation sources (builtin, user-defined, plugin)
|
|
|
|
|
*/
|
|
|
|
|
|
2025-09-04 03:41:02 +09:00
|
|
|
use crate::box_factory::builtin::BuiltinBoxFactory;
|
2025-08-20 05:57:18 +09:00
|
|
|
#[cfg(feature = "plugins")]
|
|
|
|
|
use crate::box_factory::plugin::PluginBoxFactory;
|
2025-11-18 18:56:35 +09:00
|
|
|
use crate::box_factory::UnifiedBoxRegistry;
|
2025-08-19 16:43:13 +09:00
|
|
|
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(|| {
|
2025-09-24 11:43:11 +09:00
|
|
|
// Phase 15.5: Use environment variable policy (StrictPluginFirst for "Everything is Plugin")
|
|
|
|
|
let mut registry = UnifiedBoxRegistry::with_env_policy();
|
🎉 Phase 11.8/12.7: MIR Core-13 完全実装 + 糖衣構文ドキュメント更新
主要な変更:
- MIR Core-13命令セット確定(Load/Store削除の革命的設計)
- Const, BinOp, Compare(値・計算)
- Jump, Branch, Return, Phi(制御)
- Call, BoxCall, ExternCall(呼び出し)
- TypeOp, Safepoint, Barrier(メタ)
- Phase 12.7糖衣構文ドキュメント整理(超圧縮重視、可逆変換保証)
- MIRビルダーのモジュール分割完了
- vtableテストスイート拡充
- AI協調開発ツール追加(並列リファクタリング支援)
詳細:
- src/mir/instruction_introspection.rs: core13_instruction_names()追加
- MIRビルダー分割: decls.rs, exprs_*.rs, fields.rs
- plugin_loader_v2: errors.rs, host_bridge.rs分離
- 論文用データ: mir13-final.md作成
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-04 11:34:15 +09:00
|
|
|
// Default: enable builtins unless building with feature "plugins-only"
|
|
|
|
|
#[cfg(not(feature = "plugins-only"))]
|
2025-09-04 03:41:02 +09:00
|
|
|
{
|
|
|
|
|
registry.register(std::sync::Arc::new(BuiltinBoxFactory::new()));
|
|
|
|
|
}
|
2025-09-17 07:43:07 +09:00
|
|
|
|
2025-08-30 08:54:15 +09:00
|
|
|
// Register plugin Box factory (primary)
|
2025-08-20 05:57:18 +09:00
|
|
|
#[cfg(feature = "plugins")]
|
|
|
|
|
{
|
|
|
|
|
registry.register(Arc::new(PluginBoxFactory::new()));
|
|
|
|
|
}
|
2025-09-17 07:43:07 +09:00
|
|
|
|
2025-08-19 16:43:13 +09:00
|
|
|
// TODO: User-defined Box factory will be registered by interpreter
|
2025-09-17 07:43:07 +09:00
|
|
|
|
2025-09-24 11:43:11 +09:00
|
|
|
// Phase 15.5: FactoryPolicy determines actual priority order
|
|
|
|
|
// StrictPluginFirst: plugins > user > builtin (SOLVES StringBox/IntegerBox issue)
|
|
|
|
|
// BuiltinFirst: builtin > user > plugin (legacy default)
|
|
|
|
|
|
2025-08-19 16:43:13 +09:00
|
|
|
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)
|
2025-08-19 16:56:44 +09:00
|
|
|
pub fn register_user_defined_factory(factory: Arc<dyn crate::box_factory::BoxFactory>) {
|
2025-08-19 16:43:13 +09:00
|
|
|
let registry = get_global_unified_registry();
|
|
|
|
|
let mut registry_lock = registry.lock().unwrap();
|
2025-09-17 07:43:07 +09:00
|
|
|
|
2025-11-17 03:19:03 +09:00
|
|
|
// Phase 25.1b: delegate to policy-aware register() so that
|
|
|
|
|
// type_cache is rebuilt and user-defined Box types (HakoCli など)
|
|
|
|
|
// are correctly advertised to the registry. Priorityは
|
|
|
|
|
// FactoryPolicy + factory_type に従って決まる。
|
|
|
|
|
registry_lock.register(factory);
|
2025-08-20 05:57:18 +09:00
|
|
|
}
|