From: Dmitry Selyutin Date: Sat, 10 Jun 2023 18:35:50 +0000 (+0300) Subject: insndb/db: support tree command sketch X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ec0c019d91dc2f8a278f6f7d5fb7a5dcb5762e2b;p=openpower-isa.git insndb/db: support tree command sketch --- diff --git a/src/openpower/insndb/db.py b/src/openpower/insndb/db.py index 6cd5d1c0..fb9ee05c 100644 --- a/src/openpower/insndb/db.py +++ b/src/openpower/insndb/db.py @@ -39,6 +39,20 @@ class SVP64Instruction(Instruction): return self +class TreeVisitor(Visitor): + def __init__(self): + self.__depth = 0 + return super().__init__() + + @contextlib.contextmanager + def __call__(self, node): + with super().__call__(node) as node: + print((" " * (self.__depth * 4)), repr(node)) + self.__depth += 1 + yield node + self.__depth -= 1 + + class ListVisitor(Visitor): @visitormethod(Record) def Record(self, node): @@ -98,6 +112,10 @@ class ExtrasVisitor(SVP64InstructionVisitor): def main(): commands = { + "tree": ( + TreeVisitor, + "list all records", + ), "list": ( ListVisitor, "list available instructions",