From: Dmitry Selyutin Date: Sat, 10 Jun 2023 19:37:30 +0000 (+0300) Subject: insndb/core: switch Fields to Dict class X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9572d06b76f1024ea71a4ba430fbf6df799d6a57;p=openpower-isa.git insndb/core: switch Fields to Dict class --- diff --git a/src/openpower/insndb/core.py b/src/openpower/insndb/core.py index 7ec4788f..d0425ff8 100644 --- a/src/openpower/insndb/core.py +++ b/src/openpower/insndb/core.py @@ -743,7 +743,7 @@ class Section(Dataclass): return dataclass(cls, record, typemap=typemap, keymap=keymap) -class Fields: +class Fields(Dict, datatype=type("Bits", (Tuple,), {}, datatype=int)): def __init__(self, items): if isinstance(items, dict): items = items.items() @@ -752,22 +752,16 @@ class Fields: (name, bitrange) = item return (name, tuple(bitrange.values())) - self.__mapping = dict(map(transform, items)) + mapping = dict(map(transform, items)) - return super().__init__() + return super().__init__(mapping) - def __repr__(self): - return repr(self.__mapping) + def __hash__(self): + return hash(tuple(sorted(self.items()))) def __iter__(self): yield from self.__mapping.items() - def __contains__(self, key): - return self.__mapping.__contains__(key) - - def __getitem__(self, key): - return self.__mapping.get(key, None) - class Operands: __GPR_PAIRS = (