From 116361d94073fb4628a5a4728a2a6acacefe606d Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 29 Oct 2024 13:46:17 +0100 Subject: Initial support for branching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- lib/xixanta/src/node.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/xixanta/src/node.rs') diff --git a/lib/xixanta/src/node.rs b/lib/xixanta/src/node.rs index f55ca11..a28d625 100644 --- a/lib/xixanta/src/node.rs +++ b/lib/xixanta/src/node.rs @@ -164,3 +164,17 @@ pub struct PNode { /// optional arguments. pub args: Option>, } + +impl PNode { + pub fn is_branch(&self) -> bool { + if self.node_type != NodeType::Instruction { + return false; + } + + let opcode = self.value.value.to_lowercase(); + matches!( + opcode.as_str(), + "bcc" | "bcs" | "beq" | "bmi" | "bne" | "bpl" | "bvc" | "bvs" + ) + } +} -- cgit v1.2.3