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 3bac867
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 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,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):
Expand Down

0 comments on commit 3bac867

Please sign in to comment.