From 5828dbeb875826285f7334519611e7578a745cd8 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Mon, 13 Jun 2022 15:58:58 -0400 Subject: Function.get_variable_by_name --- python/function.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'python/function.py') diff --git a/python/function.py b/python/function.py index 2ebc5a0c..619b21f9 100644 --- a/python/function.py +++ b/python/function.py @@ -1004,6 +1004,13 @@ class Function: finally: core.BNFreeVariableNameAndTypeList(v, count.value) + def get_variable_by_name(self, name: str) -> Optional['variable.Variable']: + """Get a specific variable or None if it doesn't exist""" + for v in self.vars: + if v.name == name: + return v + return None + @property def indirect_branches(self) -> List['variable.IndirectBranchInfo']: """List of indirect branches (read-only)""" -- cgit v1.3.1