Validate method substitution before definition updates and execution
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
| [lib.rs](lib.rs) | VM 类型导出、objects 类型兼容重导出(含 ReadAccess/CallSignature/CallType/CallEffect)、宿主调用与字节码 rustdoc 示例 |
|
||||
| [vm.rs](vm.rs) | Vm 拥有 ObjectStore 与错误位置记录;对象操作和宿主 new_class 和显式Trait注册/关系查询显式委托给 objects;函数/字段检查统一开关、统一参数区间查询与函数类型配置 |
|
||||
| [frame.rs](frame.rs) | EndorFrame、栈条目、源码与原生委托返回契约执行根、执行位置元数据、ExecutionLimits |
|
||||
| [eval.rs](eval.rs) | execute/call、只读调用与依赖结果、参数绑定、原生实现前数量/类型/效果检查和委托返回检查、可选注解检查、源码类字段环境绑定、帧切换、取指分派、MakeFunction、结果根转移与失败清理 |
|
||||
| [eval.rs](eval.rs) | execute/call、只读调用与依赖结果、参数绑定、原生实现前数量/类型/效果检查和委托返回检查、可选注解/动态覆写兼容检查、源码类字段环境绑定、帧切换、取指分派、MakeFunction、结果根转移与失败清理 |
|
||||
|
||||
## 常见修改入口
|
||||
|
||||
|
||||
+25
-4
@@ -166,14 +166,29 @@ impl Vm {
|
||||
for value in arguments {
|
||||
self.validate_value(value)?;
|
||||
}
|
||||
let receiver = arguments
|
||||
.first()
|
||||
.or_else(|| {
|
||||
if required == 0 {
|
||||
data.defaults().first()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.and_then(|value| match value {
|
||||
Value::Object(receiver) => Some(*receiver),
|
||||
_ => None,
|
||||
});
|
||||
if self.source_type_checks
|
||||
&& let Some(receiver) = receiver
|
||||
{
|
||||
self.objects
|
||||
.check_method_override_call(function, receiver)?;
|
||||
}
|
||||
let mut return_type = None;
|
||||
if self.source_type_checks
|
||||
&& let Some(signature) = executable.source_signature()
|
||||
{
|
||||
let receiver = arguments.first().and_then(|value| match value {
|
||||
Value::Object(object) => Some(*object),
|
||||
_ => None,
|
||||
});
|
||||
for (index, expected_name) in signature.parameters.iter().enumerate() {
|
||||
let value = arguments
|
||||
.get(index)
|
||||
@@ -262,6 +277,12 @@ impl Vm {
|
||||
for argument in arguments {
|
||||
self.validate_value(argument)?;
|
||||
}
|
||||
if self.source_type_checks
|
||||
&& let Some(Value::Object(receiver)) = arguments.first()
|
||||
{
|
||||
self.objects
|
||||
.check_method_override_call(function, *receiver)?;
|
||||
}
|
||||
if let Some(arity) = self.objects.call_arity(function)?
|
||||
&& !arity.accepts(arguments.len())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user