power_fields: support boolean checks
authorDmitry Selyutin <ghostmansd@gmail.com>
Sat, 17 Sep 2022 19:54:02 +0000 (22:54 +0300)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 17 Sep 2022 20:28:53 +0000 (21:28 +0100)
src/openpower/decoder/power_fields.py

index 7530e456f7ce2d97ca9fdae705d3ce263c046b4c..f69f78552651153beae12aa6e11e94e61f33775c 100644 (file)
@@ -71,6 +71,9 @@ class Reference:
     def __eq__(self, other):
         return self.__binary_operator(_operator.eq, other)
 
+    def __bool__(self):
+        return bool(int(self))
+
     def __int__(self):
         span = dict.fromkeys(self.__class__.span).keys()
         return int(_selectconcat(*(self.storage[bit] for bit in span)))