'sv_analysis=openpower.sv.sv_analysis:main',
'pypowersim=openpower.decoder.isa.pypowersim:run_simulation',
'pysvp64asm=openpower.insndb.asm:main',
- 'pysvp64dis=openpower.insndb.dis:main'
- ]
- }
+ 'pysvp64db=openpower.insndb.db:main',
+ 'pysvp64dis=openpower.insndb.dis:main',
+ ],
+ },
)
--- /dev/null
+import argparse
+import contextlib
+import sys
+
+from openpower.decoder.power_enums import (
+ find_wiki_dir,
+)
+from openpower.insndb.types import (
+ Database,
+ Visitor,
+)
+
+
+def main():
+ class ListVisitor(Visitor):
+ @contextlib.contextmanager
+ def db(self, db):
+ yield db
+
+ @contextlib.contextmanager
+ def record(self, record):
+ print(record.name)
+ yield record
+
+ visitors = {
+ "list": ListVisitor,
+ }
+ parser = argparse.ArgumentParser()
+ subparser = parser.add_subparsers(dest="command", required=True)
+ parser_list = subparser.add_parser("list")
+ args = vars(parser.parse_args())
+ command = args.pop("command")
+ visitor = visitors[command]()
+
+ db = Database(find_wiki_dir())
+ db.visit(visitor=visitor)
import collections as _collections
+import contextlib as _contextlib
import csv as _csv
import dataclasses as _dataclasses
import enum as _enum
from openpower.decoder.pseudo.pagereader import ISA as _ISA
+class Visitor:
+ @_contextlib.contextmanager
+ def db(self, db):
+ yield db
+
+ @_contextlib.contextmanager
+ def record(self, record):
+ yield record
+
+
@_functools.total_ordering
class Style(_enum.Enum):
LEGACY = _enum.auto()
mdwn: MarkdownRecord
svp64: SVP64Record = None
+ def visit(self, visitor):
+ with visitor.record(record=self) as record:
+ pass
+
def __lt__(self, other):
if not isinstance(other, Record):
return NotImplemented
return super().__init__()
+ def visit(self, visitor):
+ with visitor.db(db=self) as db:
+ for record in self.__db:
+ record.visit(visitor=visitor)
+
def __repr__(self):
return repr(self.__db)