From 1b8082182ea982ee87f5d86489845b8c2a839f13 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sun, 15 Aug 2021 22:52:58 +0100 Subject: [PATCH] allow constructor of SelectableInt to pass in (and copy) another SelectableInt --- src/openpower/decoder/selectable_int.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/openpower/decoder/selectable_int.py b/src/openpower/decoder/selectable_int.py index 5e2c0fe8..34ea0155 100644 --- a/src/openpower/decoder/selectable_int.py +++ b/src/openpower/decoder/selectable_int.py @@ -170,6 +170,7 @@ class FieldSelectableIntTestCase(unittest.TestCase): fs[0:2] = 0b10 self.assertEqual(fs.get_range(), 0b1011) + class SelectableInt: """SelectableInt - a class that behaves exactly like python int @@ -182,8 +183,9 @@ class SelectableInt: including negative start/end points. """ - def __init__(self, value, bits): + def __init__(self, value, bits=None): if isinstance(value, SelectableInt): + bits = value.bits value = value.value mask = (1 << bits) - 1 self.value = value & mask -- 2.30.2