oppc: swap declaration
authorDmitry Selyutin <ghostmansd@gmail.com>
Mon, 8 Jan 2024 13:19:38 +0000 (16:19 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Tue, 16 Jan 2024 19:10:07 +0000 (22:10 +0300)
src/openpower/oppc/pc_util.py

index 183f6febd8fcc888471225977ae3b39aa710d081..e3e184edc7284dba6fa64fc3069e4ddbcc11f446 100644 (file)
@@ -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