@@ -275,6 +275,12 @@ class Predecessor(Result):
275275
276276 def __hash__ (self ) -> int :
277277 return id (self )
278+
279+ def __eq__ (self , other : object ) -> bool :
280+ if isinstance (other , Predecessor ):
281+ return self .block .is_structurally_equal (other .block ) and self .value == other .value
282+ else :
283+ return False
278284
279285 def is_subseteq (self , other : Result ) -> bool :
280286 if isinstance (other , Predecessor ):
@@ -313,6 +319,17 @@ def meet(self, other: Result) -> Result:
313319class Union (Result ):
314320
315321 predecessors : frozenset [Predecessor ]
322+
323+ def __hash__ (self ) -> int :
324+ return id (self )
325+
326+ def is_subseteq (self , other : Result ) -> bool :
327+ if isinstance (other , Union ):
328+ return self .predecessors .issubset (other .predecessors )
329+ elif isinstance (other , Predecessor ):
330+ return all (pred .is_subseteq (other ) for pred in self .predecessors )
331+ else :
332+ return super ().is_subseteq (other )
316333
317334 def join (self , other : Result ) -> Result :
318335 if isinstance (other , Union ):
@@ -321,6 +338,8 @@ def join(self, other: Result) -> Result:
321338 elif isinstance (other , Predecessor ):
322339 union_preds = self .predecessors .union ({other })
323340 return Union (predecessors = union_preds )
341+ else :
342+ return Unknown ()
324343
325344 def meet (self , other : Result ) -> Result :
326345 if isinstance (other , Union ):
@@ -329,4 +348,6 @@ def meet(self, other: Result) -> Result:
329348 elif isinstance (other , Predecessor ):
330349 common_preds = self .predecessors .intersection ({other })
331350 return Union (predecessors = common_preds )
351+ else :
352+ return self .bottom ()
332353
0 commit comments