From 903b57be042b9f3f0ad6f714d4dec0c1795f93c0 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 26 Aug 2022 18:38:20 +0300 Subject: docs(tvix/eval): add doc comment on `compiler::patch_jump` Change-Id: Ifdd7b99223d239d955ac7eeeae95db97eb742bf0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6276 Reviewed-by: grfn Tested-by: BuildkiteCI --- tvix/eval/src/compiler/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tvix') diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs index faf67135ed..a7e5ceb32a 100644 --- a/tvix/eval/src/compiler/mod.rs +++ b/tvix/eval/src/compiler/mod.rs @@ -859,6 +859,12 @@ impl Compiler { self.emit_constant(Value::String(ident.ident_token().unwrap().text().into())); } + /// Patch the jump instruction at the given index, setting its + /// jump offset from the placeholder to the current code position. + /// + /// This is required because the actual target offset of jumps is + /// not known at the time when the jump operation itself is + /// emitted. fn patch_jump(&mut self, idx: CodeIdx) { let offset = self.chunk().code.len() - 1 - idx.0; -- cgit 1.4.1