Skip to content

Commit

Permalink
VirtualVariable.likes no longer checks varid.
Browse files Browse the repository at this point in the history
  • Loading branch information
ltfish committed Sep 13, 2024
1 parent f7e1985 commit 52cf227
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions ailment/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -330,11 +329,23 @@ 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 = dict(self.src_and_vvars)
other_src_and_vvars = dict(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 (
self_vvar is None
and other_vvar is not None
or self_vvar is not None
and other_vvar is None
or not self_vvar.likes(other_vvar)
):
return False
return True
return False

def __repr__(self):
Expand Down

0 comments on commit 52cf227

Please sign in to comment.