Expose native implementation identity for verified host fast paths
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user