Source

mino-pypy / pypy / translator / backendopt / writeanalyze.py

Diff from to

pypy/translator/backendopt/writeanalyze.py

 top_set = object()
 empty_set = frozenset()
 
+
 class WriteAnalyzer(graphanalyze.GraphAnalyzer):
+    def bottom_result(self):
+        return empty_set
 
-    @staticmethod
-    def join_two_results(result1, result2):
-        if result1 is top_set:
+    def top_result(self):
+        return top_set
+
+    def is_top_result(self, result):
+        return result is top_set
+
+    def result_builder(self):
+        return set()
+
+    def add_to_result(self, result, other):
+        if other is top_set:
             return top_set
-        if result2 is top_set:
+        result.update(other)
+        return result
+
+    def finalize_builder(self, result):
+        if result is top_set:
+            return result
+        return frozenset(result)
+
+    def join_two_results(self, result1, result2):
+        if result1 is top_set or result2 is top_set:
             return top_set
         return result1.union(result2)
 
-    @staticmethod
-    def join_results(results):
-        result = set()
-        for res in results:
-            if res is top_set:
-                return top_set
-            result |= res
-        return frozenset(result)
-
-    @staticmethod
-    def bottom_result():
-        return empty_set
-
-    @staticmethod
-    def top_result():
-        return top_set
-
-    @staticmethod
-    def is_top_result(result):
-        return result is top_set
-
     def analyze_simple_operation(self, op, graphinfo):
         if op.opname in ("setfield", "oosetfield"):
             if graphinfo is None or not graphinfo.is_fresh_malloc(op.args[0]):