From ec8b709fa24c3386dae919cf0c33a51468efbae5 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Sun, 5 Jan 2025 08:57:26 +0100 Subject: Implement block bodies inside of the assembler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Following 1f8a6becc7cd ("parser: Implement block bodies"), the support for the new way of managing block bodies have also been added into the assembler. There are still some things to iron out, but they will be fixed in later commits. Signed-off-by: Miquel Sabaté Solà --- lib/xixanta/src/object.rs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'lib/xixanta/src/object.rs') diff --git a/lib/xixanta/src/object.rs b/lib/xixanta/src/object.rs index 41ec67e..c84f96f 100644 --- a/lib/xixanta/src/object.rs +++ b/lib/xixanta/src/object.rs @@ -331,10 +331,9 @@ impl Context { scope.push(object.clone()); } - /// Change the current context given a `node`. Returns a tuple which states: - /// 0. Whether the context has changed. - /// 1. Whether a caller can bundle nodes safely. - pub fn change_context(&mut self, node: &PNode) -> Result<(bool, bool), ContextError> { + /// Change the current context given a `node`. Returns true if the context + /// has changed. + pub fn change_context(&mut self, node: &PNode) -> Result { // The parser already guarantees that the control node is // from a function that we already know, so calling `unwrap` // is not dangerous. @@ -344,27 +343,24 @@ impl Context { // If the control function does not touch the context, leave early. if !control.touches_context { - return Ok((false, true)); + return Ok(false); } // And push/pop the context depending on the control being used. match node.node_type { - NodeType::Control(ControlType::StartMacro) => { - self.context_push(&node.left.clone().unwrap()); - Ok((true, false)) - } - NodeType::Control(ControlType::StartProc) + NodeType::Control(ControlType::StartMacro) + | NodeType::Control(ControlType::StartProc) | NodeType::Control(ControlType::StartScope) => { - self.context_push(&node.left.clone().unwrap()); - Ok((true, true)) + self.context_push(&node.left.as_ref().unwrap()); + Ok(true) } NodeType::Control(ControlType::EndMacro) | NodeType::Control(ControlType::EndProc) | NodeType::Control(ControlType::EndScope) => { self.context_pop(&node.value)?; - Ok((true, true)) + Ok(true) } - _ => Ok((false, true)), + _ => Ok(false), } } -- cgit v1.2.3