From f2f00719724cf04bede94ad2fd52e4875f030663 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Sat, 17 Sep 2022 22:54:02 +0300 Subject: [PATCH] power_fields: support boolean checks --- src/openpower/decoder/power_fields.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/openpower/decoder/power_fields.py b/src/openpower/decoder/power_fields.py index 7530e456..f69f7855 100644 --- a/src/openpower/decoder/power_fields.py +++ b/src/openpower/decoder/power_fields.py @@ -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))) -- 2.30.2