oppc/code: deprecate redundant node arguments
authorDmitry Selyutin <ghostmansd@gmail.com>
Sun, 14 Jan 2024 19:13:03 +0000 (22:13 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Tue, 16 Jan 2024 19:10:07 +0000 (22:10 +0300)
src/openpower/oppc/pc_code.py

index 939bcae88108ae279d33be01d89166a853514fa9..d408648360b0b03cd594556d404ae42bd4573548 100644 (file)
@@ -56,14 +56,14 @@ class CodeVisitor(pc_util.Visitor):
     def __setitem__(self, node, code):
         self.__code[node] = code
 
-    def transient(self, node,
+    def transient(self,
             value="UINT64_C(0)",
             bits="(uint8_t)OPPC_XLEN"):
         transient = Transient(value=value, bits=bits)
         self.traverse(root=transient)
         return transient
 
-    def call(self, node, name, code, stmt=False):
+    def call(self, name, code, stmt=False):
         def validate(item):
             def validate(item):
                 (level, stmt) = item
@@ -82,7 +82,7 @@ class CodeVisitor(pc_util.Visitor):
 
     def fixup_ternary(self, node):
         self[node].clear()
-        test = self.call(name="oppc_bool", node=node, code=[
+        test = self.call(name="oppc_bool", code=[
             self[node.test],
         ])
         self[node].emit(stmt="(")
@@ -130,7 +130,7 @@ class CodeVisitor(pc_util.Visitor):
         code[-1] = (level, stmt[:-1])
 
         if not assign:
-            call = self.call(name="oppc_attr", node=root, code=[
+            call = self.call(name="oppc_attr", code=[
                 code,
             ])
             code = self[call]
@@ -181,25 +181,25 @@ class CodeVisitor(pc_util.Visitor):
             return
 
         if isinstance(node.lvalue, pc_ast.SubscriptExpr):
-            call = self.call(name="oppc_subscript_assign", node=node, stmt=True, code=[
+            call = self.call(name="oppc_subscript_assign", stmt=True, code=[
                 self[node.lvalue.subject],
                 self[node.lvalue.index],
                 self[node.rvalue],
             ])
         elif isinstance(node.lvalue, pc_ast.RangeSubscriptExpr):
-            call = self.call(name="oppc_range_subscript_assign", node=node, stmt=True, code=[
+            call = self.call(name="oppc_range_subscript_assign", stmt=True, code=[
                 self[node.lvalue.subject],
                 self[node.lvalue.start],
                 self[node.lvalue.end],
                 self[node.rvalue],
             ])
         elif isinstance(node.lvalue, pc_ast.Attribute):
-            call = self.call(name="oppc_attr_assign", stmt=True, node=node, code=[
+            call = self.call(name="oppc_attr_assign", stmt=True, code=[
                 self[node.lvalue],
                 self[node.rvalue],
             ])
         else:
-            call = self.call(name="oppc_assign", stmt=True, node=node, code=[
+            call = self.call(name="oppc_assign", stmt=True, code=[
                 self[node.lvalue],
                 self[node.rvalue],
             ])
@@ -231,13 +231,13 @@ class CodeVisitor(pc_util.Visitor):
             self.fixup_attr(node=node.right)
 
         if isinstance(node.op, comparison):
-            call = self.call(name=str(self[node.op]), node=node, code=[
+            call = self.call(name=str(self[node.op]), code=[
                 self[node.left],
                 self[node.right],
             ])
         else:
-            transient = self.transient(node=node)
-            call = self.call(name=str(self[node.op]), node=node, code=[
+            transient = self.transient()
+            call = self.call(name=str(self[node.op]), code=[
                 self[transient],
                 self[node.left],
                 self[node.right],
@@ -251,7 +251,7 @@ class CodeVisitor(pc_util.Visitor):
         yield node
         if isinstance(node.value, pc_ast.IfExpr):
             self.fixup_ternary(node=node.value)
-        call = self.call(name=str(self[node.op]), node=node, code=[
+        call = self.call(name=str(self[node.op]), code=[
             self[node.value],
         ])
         with self.pseudocode(node=node):
@@ -319,7 +319,7 @@ class CodeVisitor(pc_util.Visitor):
         if (value > ((2**64) - 1)):
             raise NotImplementedError()
         value = f"UINT64_C({fmt(value)})"
-        transient = self.transient(node=node, value=value, bits=bits)
+        transient = self.transient(value=value, bits=bits)
         with self.pseudocode(node=node):
             for (level, stmt) in self[transient]:
                 self[node].emit(stmt=stmt, level=level)
@@ -367,8 +367,8 @@ class CodeVisitor(pc_util.Visitor):
     @pc_util.Hook(pc_ast.RepeatExpr)
     def RepeatExpr(self, node):
         yield node
-        transient = self.transient(node=node)
-        call = self.call(name="oppc_repeat", node=node, code=[
+        transient = self.transient()
+        call = self.call(name="oppc_repeat", code=[
             self[transient],
             self[node.subject],
             self[node.times],
@@ -380,7 +380,7 @@ class CodeVisitor(pc_util.Visitor):
     def XLEN(self, node):
         yield node
         (value, bits) = ("OPPC_XLEN", "(uint8_t)OPPC_XLEN")
-        transient = self.transient(node=node, value=value, bits=bits)
+        transient = self.transient(value=value, bits=bits)
         with self.pseudocode(node=node):
             for (level, stmt) in self[transient]:
                 self[node].emit(stmt=stmt, level=level)
@@ -395,7 +395,7 @@ class CodeVisitor(pc_util.Visitor):
     @pc_util.Hook(pc_ast.SubscriptExpr)
     def SubscriptExpr(self, node):
         yield node
-        call = self.call(name="oppc_subscript", node=node, code=[
+        call = self.call(name="oppc_subscript", code=[
             self[node.subject],
             self[node.index],
         ])
@@ -405,7 +405,7 @@ class CodeVisitor(pc_util.Visitor):
     @pc_util.Hook(pc_ast.RangeSubscriptExpr)
     def RangeSubscriptExpr(self, node):
         yield node
-        call = self.call(name="oppc_subscript", node=node, code=[
+        call = self.call(name="oppc_subscript", code=[
             self[node.subject],
             self[node.start],
             self[node.end],
@@ -479,7 +479,7 @@ class CodeVisitor(pc_util.Visitor):
     @pc_util.Hook(pc_ast.IfExpr)
     def IfExpr(self, node):
         yield node
-        test = self.call(name="oppc_bool", node=node, code=[
+        test = self.call(name="oppc_bool", code=[
             self[node.test],
         ])
         self[node].emit(stmt="if (")
@@ -498,7 +498,7 @@ class CodeVisitor(pc_util.Visitor):
     @pc_util.Hook(pc_ast.SwitchExpr)
     def SwitchExpr(self, node):
         yield node
-        subject = self.call(name="oppc_int64", node=node, code=[
+        subject = self.call(name="oppc_int64", code=[
             self[node.subject],
         ])
         self[node].emit(stmt="switch (")
@@ -561,7 +561,7 @@ class CodeVisitor(pc_util.Visitor):
     def Call(self, node):
         yield node
         code = tuple(map(lambda arg: self[arg], node.args))
-        call = self.call(name=str(node.name), node=node, code=code)
+        call = self.call(name=str(node.name), code=code)
         for (level, stmt) in self[call]:
             self[node].emit(stmt=stmt, level=level)