From: Dmitry Selyutin Date: Tue, 30 Aug 2022 08:47:16 +0000 (+0300) Subject: selectable_int: support slicing by iterable X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b650b32b48b36dbcb92ac380f76f0ec698a42341;p=openpower-isa.git selectable_int: support slicing by iterable --- diff --git a/src/openpower/decoder/selectable_int.py b/src/openpower/decoder/selectable_int.py index 36d30689..55f5e6c8 100644 --- a/src/openpower/decoder/selectable_int.py +++ b/src/openpower/decoder/selectable_int.py @@ -385,7 +385,13 @@ class SelectableInt: log("getitem", stop, start, self.bits, hex(self.value), value) return SelectableInt(value, bits) else: - raise ValueError(value) + bits = [] + key = tuple(key) + for bit in key: + if not isinstance(bit, (int, SelectableInt)): + raise ValueError(key) + bits.append(self[bit]) + return selectconcat(*bits) def __setitem__(self, key, value): if isinstance(key, SelectableInt):