Classify read-only wrappers with dynamic delegated effects
This commit is contained in:
@@ -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 类型与效果元数据、调用前检查、签名类型强边、上下文原生函数、作用域语言函数工厂、显式能力声明入口、函数标记、根与非递归委托调用 |
|
||||
| [native.rs](native.rs) | NativeContext、CallArity/CallSignature 类型、Delegated/固定效果元数据、调用前检查、签名类型强边、上下文原生函数、作用域语言函数工厂、显式能力声明入口、函数标记、根与非递归委托调用 |
|
||||
| [changes.rs](changes.rs) | 合并变更批次、变更键与有界通知额度 |
|
||||
| [number.rs](number.rs) | Integer/Decimal/Rational/BinaryFloat/Complex 的无损表示和装箱载荷 |
|
||||
| [builtins.rs](builtins.rs) | String、Dict、Cell、Function、BaseException 载荷与 trace 边、语言函数标记 |
|
||||
|
||||
@@ -25,7 +25,11 @@ impl From<CallSignature> for Contract {
|
||||
parameters: value.parameters,
|
||||
variadic: value.variadic,
|
||||
returns: value.returns,
|
||||
effect: Some(value.effect),
|
||||
effect: if value.effect == CallEffect::Delegated {
|
||||
None
|
||||
} else {
|
||||
Some(value.effect)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -296,7 +300,7 @@ impl ObjectStore {
|
||||
let compatible = match expected {
|
||||
CallEffect::ReadOnly => actual == CallEffect::ReadOnly,
|
||||
CallEffect::Mutating => actual != CallEffect::External,
|
||||
CallEffect::External => true,
|
||||
CallEffect::External | CallEffect::Delegated => true,
|
||||
};
|
||||
if !compatible {
|
||||
return Err(invalid("override expands native effects"));
|
||||
|
||||
@@ -55,6 +55,9 @@ impl CallArity {
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum CallEffect {
|
||||
ReadOnly,
|
||||
/// The native body itself is read-only; delegated effects are dynamic and
|
||||
/// checked by the VM in the same execution/heap scope.
|
||||
Delegated,
|
||||
Mutating,
|
||||
External,
|
||||
}
|
||||
@@ -192,7 +195,9 @@ impl CallSignature {
|
||||
) -> Result<(), VmError> {
|
||||
self.validate(store)?;
|
||||
self.arity.check(name.into(), arguments.len())?;
|
||||
if store.is_read_only() && self.effect != CallEffect::ReadOnly {
|
||||
if store.is_read_only()
|
||||
&& !matches!(self.effect, CallEffect::ReadOnly | CallEffect::Delegated)
|
||||
{
|
||||
return Err(VmError::InvalidArgument(
|
||||
"native effect is forbidden during read-only execution",
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user