From 3bac8672e761288101283ecbe115204a279087b9 Mon Sep 17 00:00:00 2001 From: Fish Date: Fri, 13 Sep 2024 01:34:52 -0700 Subject: [PATCH] VirtualVariable.likes no longer checks varid. --- ailment/expression.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ailment/expression.py b/ailment/expression.py index 05ccfda..612db06 100644 --- a/ailment/expression.py +++ b/ailment/expression.py @@ -265,7 +265,6 @@ def stack_offset(self) -> int | None: def likes(self, atom): return ( isinstance(atom, VirtualVariable) - and self.varid == atom.varid and self.bits == atom.bits and self.category == atom.category and self.oident == atom.oident @@ -330,11 +329,17 @@ def verbose_op(self) -> str: def likes(self, atom) -> bool: if isinstance(atom, Phi) and self.bits == atom.bits: - self_src_and_vvarids = {(src, vvar.varid if vvar is not None else None) for src, vvar in self.src_and_vvars} - other_src_and_vvarids = { - (src, vvar.varid if vvar is not None else None) for src, vvar in atom.src_and_vvars - } - return self_src_and_vvarids == other_src_and_vvarids + if len(self.src_and_vvars) != len(atom.src_and_vvars): + return False + self_src_and_vvars = {src: vvar for src, vvar in self.src_and_vvars} + other_src_and_vvars = {src: vvar for src, vvar in atom.src_and_vvars} + for src, self_vvar in self_src_and_vvars.items(): + if src not in other_src_and_vvars: + return False + other_vvar = other_src_and_vvars[src] + if not self_vvar.likes(other_vvar): + return False + return True return False def __repr__(self):