From f3c6b02fb2f2957b9b896c34d05abe75263c3f60 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Sun, 5 Jan 2025 16:34:52 +0100 Subject: Store a reference for macros instead of an index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is not safe to store a node index for macros since the list of nodes that is passed down during assembly might change depending on whether an inner block is being evaluated. Hence, the previous implementation would break on a simple macro call inside of a .proc. This also raised some concerns on the design around the API, since the lifetime of references for internal assembler data needed an explicit lifetime now, and as a side-effect functions like `assemble` had to be moved out of the inner impl Assembler. This is in retrospect also a better design choice. Fixes: ec8b709fa24c ("Implement block bodies inside of the assembler"). Signed-off-by: Miquel Sabaté Solà --- lib/xixanta/src/object.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/xixanta/src/object.rs') diff --git a/lib/xixanta/src/object.rs b/lib/xixanta/src/object.rs index c84f96f..506e632 100644 --- a/lib/xixanta/src/object.rs +++ b/lib/xixanta/src/object.rs @@ -351,7 +351,7 @@ impl Context { NodeType::Control(ControlType::StartMacro) | NodeType::Control(ControlType::StartProc) | NodeType::Control(ControlType::StartScope) => { - self.context_push(&node.left.as_ref().unwrap()); + self.context_push(node.left.as_ref().unwrap()); Ok(true) } NodeType::Control(ControlType::EndMacro) -- cgit v1.2.3