From b2a66320fa9fdd92521b930e3449ac3f46184f5d Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Mon, 8 Jan 2024 16:19:38 +0300 Subject: [PATCH] oppc: swap declaration --- src/openpower/oppc/pc_util.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/openpower/oppc/pc_util.py b/src/openpower/oppc/pc_util.py index 183f6feb..e3e184ed 100644 --- a/src/openpower/oppc/pc_util.py +++ b/src/openpower/oppc/pc_util.py @@ -9,6 +9,19 @@ import mdis.walker import openpower.oppc.pc_ast as pc_ast +class Hook(mdis.dispatcher.Hook): + def __call__(self, call): + hook = super().__call__(call) + + class ConcreteHook(hook.__class__): + @functools.wraps(hook.__call__) + @contextlib.contextmanager + def __call__(self, dispatcher, node, *args, **kwargs): + return hook(dispatcher, node, *args, **kwargs) + + return ConcreteHook(*tuple(self)) + + class Code(list): def __init__(self): self.__level = 0 @@ -37,19 +50,6 @@ class Code(list): self.append(item) -class Hook(mdis.dispatcher.Hook): - def __call__(self, call): - hook = super().__call__(call) - - class ConcreteHook(hook.__class__): - @functools.wraps(hook.__call__) - @contextlib.contextmanager - def __call__(self, dispatcher, node, *args, **kwargs): - return hook(dispatcher, node, *args, **kwargs) - - return ConcreteHook(*tuple(self)) - - class PseudocodeVisitor(mdis.visitor.ContextVisitor): def __init__(self, root): self.__root = root -- 2.30.2