From: Dmitry Selyutin Date: Sat, 2 Sep 2023 16:39:03 +0000 (+0300) Subject: insndb/core: walk over individual operands X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7222af4f4d12235a67b266321c9513aafe92c3ec;p=openpower-isa.git insndb/core: walk over individual operands --- diff --git a/src/openpower/insndb/core.py b/src/openpower/insndb/core.py index f441cf8b..403bacab 100644 --- a/src/openpower/insndb/core.py +++ b/src/openpower/insndb/core.py @@ -3731,3 +3731,19 @@ class Walker(mdis.walker.Walker): @mdis.dispatcher.Hook(Database) def dispatch_database(self, node): yield from self(tuple(node)) + + @mdis.dispatcher.Hook(Record) + def dispatch_record(self, node): + self.__record = node + for field in _dataclasses.fields(node): + key = field.name + value = getattr(node, key) + yield (value, node, key, mdis.walker.AttributePath) + + @mdis.dispatcher.Hook(Operands) + def dispatch_operands(self, node): + def hook(cls_kwargs): + (cls, kwargs) = cls_kwargs + return cls(record=self.__record, **kwargs) + + yield from self(tuple(map(hook, node)))