docs: clarify event failure cleanup and VM sequence contracts

This commit is contained in:
2026-11-12 20:53:49 +08:00
parent f0bfbc9fc1
commit 2d5138c7ad
3 changed files with 10 additions and 4 deletions
+3 -1
View File
@@ -5,6 +5,7 @@
//! source_layout/source_paint 用 repeat_call 循环推进出现位置,并用 collect_and_continue 收集单次源调用结果。
//! 本模块只生成驱动字节码和托管函数,不在 Rust 中自行解释语句,也不替调用方重置 VM 预算。
//! 原生调用返回 Invoke 后,VM 在既有帧循环中执行驱动,因此可挂起工作仍有明确的 owning VM。
//! build 串联的是普通调用序列,任一步报错便中断后续步骤;末项不是 finally,错误时临时根/检查点仍须由所属工作收尾路径释放。
use endor_core::{
CodeLayout, EndorCode, EndorCodeObject, Instruction, NativeContext, ObjectRef, Opcode, Value,
VmError,
@@ -63,7 +64,7 @@ pub fn repeat_call(
name: &'static str,
desktop: ObjectRef,
) -> Result<ObjectRef, VmError> {
// 回调返回 Bool;repeat_while 消费这个条件并决定是否跳回本帧开头。
// 内部 Advance 回调约定返回 Bool;repeat_while 生成的是 VM 真值条件跳转,不额外验证返回值必须是 Bool。
// 退出后显式返回 Nil,回调的继续条件不会泄露为驱动返回值。
let mut instructions = vec![
Instruction::new(Opcode::LoadConst, 0),
@@ -96,6 +97,7 @@ pub fn collect_and_continue(
desktop: ObjectRef,
) -> Result<ObjectRef, VmError> {
// 常量布局固定为 collector、function、各实参、true。
// function 或 collector 失败时不会装入最终 true,外层循环也不会自动跳过失败节点;本助手不捕获或重试源错误。
// 先把 collector 的调用前缀压栈,再执行 function,使其返回值直接成为 collector 的唯一实参。
// count 同时确定 Call 的显式参数数和 true 常量的池位置,不能把 collector 的一参计入它。
let count = arguments.len();