From 7222af4f4d12235a67b266321c9513aafe92c3ec Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Sat, 2 Sep 2023 19:39:03 +0300 Subject: [PATCH] insndb/core: walk over individual operands --- src/openpower/insndb/core.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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))) -- 2.30.2