From ec0c019d91dc2f8a278f6f7d5fb7a5dcb5762e2b Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Sat, 10 Jun 2023 21:35:50 +0300 Subject: [PATCH] insndb/db: support tree command sketch --- src/openpower/insndb/db.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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", -- 2.30.2