feat: expose validated class registration to VM hosts

This commit is contained in:
2026-10-21 02:40:18 +08:00
parent 2b5539cd06
commit 44a02c9fd6
4 changed files with 15 additions and 2 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
| 文件 | 职责 |
| --- | --- |
| [lib.rs](lib.rs) | VM 类型导出、objects 类型兼容重导出、宿主调用与字节码 rustdoc 示例 |
| [vm.rs](vm.rs) | Vm 拥有 ObjectStore 与错误位置记录;对象操作显式委托给 objects |
| [vm.rs](vm.rs) | Vm 拥有 ObjectStore 与错误位置记录;对象操作和宿主 new_class 注册显式委托给 objects |
| [frame.rs](frame.rs) | EndorFrame、栈条目、执行位置元数据、ExecutionLimits |
| [eval.rs](eval.rs) | execute/call、参数绑定、帧切换、取指分派、MakeFunction、结果根转移与失败清理 |
+11
View File
@@ -33,6 +33,17 @@ impl Vm {
self.objects.bootstrap_types()
}
/// Host registration uses the same validated class builder as source code.
pub fn new_class(
&mut self,
name: impl Into<String>,
base: ObjectRef,
fields: Vec<crate::ClassField>,
methods: std::collections::BTreeMap<String, ObjectRef>,
) -> Result<ObjectRef, VmError> {
self.objects.new_class(name, base, fields, methods)
}
pub fn new_type(
&mut self,
name: impl Into<String>,