From bd6cfb1e33d70e3951ceca793e5643cddf1a8ce1 Mon Sep 17 00:00:00 2001 From: Oleksandr Knyshuk Date: Tue, 5 Aug 2025 18:39:22 +0200 Subject: [PATCH] docs(eval): update `compile_if_else` docstring for JumpIfCatchable opcode Reflects control flow changes after cl/10288, documenting the new JumpIfCatchable instruction and updated branching logic for catchable defaults in conditional expressions. Change-Id: I6a6a6964b84ae42e35ccb84851c7993619516d0b Reviewed-on: https://cl.snix.dev/c/snix/+/30656 Tested-by: besadii Reviewed-by: Florian Klink Reviewed-by: Oleksandr Knyshuk Autosubmit: Oleksandr Knyshuk --- snix/eval/src/compiler/mod.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/snix/eval/src/compiler/mod.rs b/snix/eval/src/compiler/mod.rs index 0b978160b..db267ae17 100644 --- a/snix/eval/src/compiler/mod.rs +++ b/snix/eval/src/compiler/mod.rs @@ -906,14 +906,15 @@ impl Compiler<'_, '_> { /// Compile conditional expressions using jumping instructions in the VM. /// /// ```notrust - /// ┌────────────────────┐ - /// │ 0 [ conditional ] │ - /// │ 1 JUMP_IF_FALSE →┼─┐ - /// │ 2 [ main body ] │ │ Jump to else body if - /// ┌┼─3─← JUMP │ │ condition is false. - /// Jump over else body ││ 4 [ else body ]←┼─┘ - /// if condition is true.└┼─5─→ ... │ - /// └────────────────────┘ + /// ┌─────────────────────┐ + /// │ 0 [ conditional ] │ + /// │ 1 JUMP_IF_CATCH →┼───┐ Jump over else body + /// │ 2 JUMP_IF_FALSE →┼─┐ │ if condition is catchable. + /// │ 3 [ main body ] │ │ ← Jump to else body if + /// ┌┼─4─← JUMP │ │ ← condition is false. + /// Jump over else body ││ 5 [ else body ] ←┼─┘ │ + /// if condition is true.└┼─6─→ ... ←┼───┘ + /// └─────────────────────┘ /// ``` fn compile_if_else(&mut self, slot: LocalIdx, node: &ast::IfElse) { self.compile(slot, node.condition().unwrap());