@@ -51,6 +51,11 @@ def is_subseteq(self, other: Result) -> bool:
5151 def __hash__ (self ) -> int :
5252 return id (self )
5353
54+ def is_structurally_equal (
55+ self , other : ir .Attribute , context : dict | None = None
56+ ) -> bool :
57+ return isinstance (other , Unknown )
58+
5459
5560@final
5661@dataclass
@@ -63,6 +68,11 @@ def is_subseteq(self, other: Result) -> bool:
6368 def __hash__ (self ) -> int :
6469 return id (self )
6570
71+ def is_structurally_equal (
72+ self , other : ir .Attribute , context : dict | None = None
73+ ) -> bool :
74+ return isinstance (other , Bottom )
75+
6676
6777@final
6878@dataclass
@@ -85,6 +95,15 @@ def __hash__(self) -> int:
8595 # the data is guaranteed to be unique.
8696 return id (self )
8797
98+ def is_structurally_equal (
99+ self , other : ir .Attribute , context : dict | None = None
100+ ) -> bool :
101+ if not isinstance (other , Value ):
102+ return False
103+ if isinstance (self .data , ir .Attribute ) and isinstance (other .data , ir .Attribute ):
104+ return self .data .is_structurally_equal (other .data , context = context )
105+ return self .data .is_structurally_equal (other .data , context = context )
106+
88107
89108@dataclass
90109class PartialConst (Result ):
@@ -158,6 +177,18 @@ def is_subseteq_Value(self, other: Value) -> bool:
158177 def __hash__ (self ) -> int :
159178 return hash (self .data )
160179
180+ def is_structurally_equal (
181+ self , other : ir .Attribute , context : dict | None = None
182+ ) -> bool :
183+ if not isinstance (other , PartialTuple ):
184+ return False
185+ if len (self .data ) != len (other .data ):
186+ return False
187+ return all (
188+ x .is_structurally_equal (y , context = context )
189+ for x , y in zip (self .data , other .data )
190+ )
191+
161192
162193@final
163194@dataclass
@@ -230,3 +261,17 @@ def meet(self, other: Result) -> Result:
230261 tuple (x .meet (y ) for x , y in zip (self .captured , other .captured )),
231262 self .argnames ,
232263 )
264+
265+ def is_structurally_equal (
266+ self , other : ir .Attribute , context : dict | None = None
267+ ) -> bool :
268+ return (
269+ isinstance (other , PartialLambda )
270+ and self .code .is_structurally_equal (other .code , context = context )
271+ and self .argnames == other .argnames
272+ and len (self .captured ) == len (other .captured )
273+ and all (
274+ x .is_structurally_equal (y , context = context )
275+ for x , y in zip (self .captured , other .captured )
276+ )
277+ )
0 commit comments