diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-01-05 08:57:26 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-01-05 08:57:26 +0100 |
| commit | ec8b709fa24c3386dae919cf0c33a51468efbae5 (patch) | |
| tree | 846b5354e75efb776eac66e5c781662c1800f01c /lib/xixanta/src/object.rs | |
| parent | 1f8a6becc7cdca285333d51b4548373974df7dd3 (diff) | |
| download | tools.nes-ec8b709fa24c3386dae919cf0c33a51468efbae5.tar.gz tools.nes-ec8b709fa24c3386dae919cf0c33a51468efbae5.zip | |
Implement block bodies inside of the assembler
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à <mikisabate@gmail.com>
Diffstat (limited to 'lib/xixanta/src/object.rs')
| -rw-r--r-- | lib/xixanta/src/object.rs | 24 |
1 files changed, 10 insertions, 14 deletions
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<bool, ContextError> { // 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), } } |
