From 865f7542dfcdc041fa7fb2cfadb7f56f803ce0ae Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Thu, 22 Jun 2023 22:24:07 +0300 Subject: [PATCH] insndb/core: hide section opcode type --- src/openpower/insndb/core.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/openpower/insndb/core.py b/src/openpower/insndb/core.py index c5b586f9..6dd4c336 100644 --- a/src/openpower/insndb/core.py +++ b/src/openpower/insndb/core.py @@ -131,7 +131,7 @@ def dataclass(cls, record, keymap=None, typemap=None): @_functools.total_ordering -class Opcode(Dataclass): +class Opcode: class Integer(int): def __new__(cls, value): if isinstance(value, str): @@ -161,8 +161,18 @@ class Opcode(Dataclass): class Mask(Integer): pass - value: Value - mask: Mask + def __init__(self, value, mask): + self.__value = value + self.__mask = mask + return super().__init__() + + @property + def value(self): + return self.__value + + @property + def mask(self): + return self.__mask def __lt__(self, other): if not isinstance(other, Opcode): @@ -578,11 +588,14 @@ class Section(Dataclass): def __repr__(self): return (bin(self) if self else "None") + class Opcode(IntegerOpcode): + pass + csv: Path bitsel: BitSel suffix: Suffix mode: Mode - opcode: IntegerOpcode = None + opcode: Opcode = None priority: Priority = Priority.NORMAL def __lt__(self, other): @@ -3533,8 +3546,8 @@ class PPCDatabase: section.Mode.INTEGER: IntegerOpcode, section.Mode.PATTERN: PatternOpcode, }[section.mode] - factory = _functools.partial( - PPCRecord.CSV, opcode_cls=opcode_cls) + factory = _functools.partial(PPCRecord.CSV, + opcode_cls=opcode_cls) with open(path, "r", encoding="UTF-8") as stream: for insn in parse(stream, factory): for name in insn.names: -- 2.30.2