Add explicit managed traits and inherited method arity contracts

This commit is contained in:
2026-10-21 21:34:46 +08:00
parent b7daabdaad
commit eb60212428
16 changed files with 454 additions and 16 deletions
+25
View File
@@ -14,6 +14,31 @@ pub struct Vm {
}
impl Vm {
pub fn new_trait(
&mut self,
name: impl Into<String>,
requirements: Vec<crate::MethodRequirement>,
) -> Result<ObjectRef, VmError> {
self.objects.new_trait(name, requirements)
}
pub fn implement_trait(
&mut self,
definition: ObjectRef,
capability: ObjectRef,
) -> Result<(), VmError> {
self.objects.implement_trait(definition, capability)
}
pub fn implements_trait(
&self,
definition: ObjectRef,
capability: ObjectRef,
) -> Result<bool, VmError> {
self.objects.implements_trait(definition, capability)
}
pub fn supports(&self, object: ObjectRef, capability: ObjectRef) -> Result<bool, VmError> {
self.objects.supports(object, capability)
}
pub fn define_method(
&mut self,
type_object: ObjectRef,