Expose native implementation identity for verified host fast paths

This commit is contained in:
2026-10-22 19:02:27 +08:00
parent ae821aea2e
commit e511e393d9
5 changed files with 54 additions and 3 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
| [object.rs](object.rs) | Value、CompareOp、ObjectPayload(含显式函数标记)、ObjectHeader、EndorObject、Record、可发布数量元数据的 NativeFunction |
| [types.rs](types.rs) | 托管名义类型、显式 Object/Type 引导、继承查询、受管方法表/接收者绑定、类字段、显式/类型化Trait定义、强类型签名边与声明约束、实例方法遮蔽检查和宿主缓存依赖名、原生构造委托、统一源码/原生/绑定方法参数区间和已知效果查询与能力验证、声明环境托管边、字段构造/写入检查与标记为校验读取的注解解析/匹配 |
| [contracts.rs](contracts.rs) | 方法参数逆变/返回协变、名义/能力/联合包含关系、祖先方法更新的后代检查、动态注解调用前复查、类型化能力替换/返回约束与临时递归验证集合 |
| [native.rs](native.rs) | NativeContext、CallArity/CallSignature 类型、Delegated/固定效果元数据、调用前检查、签名类型强边、上下文原生函数、作用域语言函数工厂、显式能力声明入口、函数标记、根与非递归委托调用 |
| [native.rs](native.rs) | NativeContext、CallArity/CallSignature 类型、Delegated/固定效果元数据、调用前检查、签名类型强边、上下文原生函数与具体实现借用查询、作用域语言函数工厂、显式能力声明入口、函数标记、根与非递归委托调用 |
| [effects.rs](effects.rs) | 非递归只读调用图证明、当前全局/闭包/绑定接收者解析、控制流栈事实合并,无执行或隐藏强根 |
| [changes.rs](changes.rs) | 合并变更批次、变更键与有界通知额度 |
| [number.rs](number.rs) | Integer/Decimal/Rational/BinaryFloat/Complex 的无损表示和装箱载荷 |
+9 -1
View File
@@ -222,7 +222,7 @@ impl CallSignature {
}
}
pub trait NativeCallable: fmt::Debug + Send + Sync + 'static {
pub trait NativeCallable: fmt::Debug + Send + Sync + std::any::Any {
/// Immutable resolved types; referenced definitions must be traced by the
/// payload. ContextNativeFunction snapshots and traces them automatically.
fn signature(&self) -> Option<CallSignature> {
@@ -453,6 +453,14 @@ pub struct ContextNativeFunction {
}
impl ContextNativeFunction {
/// Borrow the concrete host implementation for intrinsic dispatch checks.
/// Function identity or a mutable class-table slot alone is not proof that
/// its current payload still implements a host intrinsic.
pub fn implementation<T: NativeCallable>(&self) -> Option<&T> {
let implementation: &dyn std::any::Any = self.callable.as_ref();
implementation.downcast_ref()
}
pub fn new(
name: &'static str,
callable: impl NativeCallable,