oppc/code: rename ccall into call
authorDmitry Selyutin <ghostmansd@gmail.com>
Sun, 14 Jan 2024 15:35:32 +0000 (18:35 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Tue, 16 Jan 2024 19:10:07 +0000 (22:10 +0300)
src/openpower/oppc/pc_code.py

index 22adf1e51427006a8b85a6c2f9d646818b08baf6..d7cdeef5ee8fcbc9ee7844215f517f35531f35c9 100644 (file)
@@ -17,7 +17,7 @@ class Transient(pc_ast.Node):
         return f"oppc_transient(&(struct oppc_value){{}}, {self.__value}, {self.__bits})"
 
 
-class CCall(pc_ast.Dataclass):
+class Call(pc_ast.Dataclass):
     name: str
     code: tuple
     stmt: bool
@@ -58,7 +58,7 @@ class CodeVisitor(pc_util.Visitor):
         self.traverse(root=transient)
         return transient
 
-    def ccall(self, node, name, code, stmt=False):
+    def call(self, node, name, code, stmt=False):
         def validate(item):
             def validate(item):
                 (level, stmt) = item
@@ -71,13 +71,13 @@ class CodeVisitor(pc_util.Visitor):
             return tuple(map(validate, item))
 
         code = tuple(map(validate, code))
-        ccall = CCall(name=name, code=code, stmt=stmt)
-        self.traverse(root=ccall)
-        return ccall
+        call = Call(name=name, code=code, stmt=stmt)
+        self.traverse(root=call)
+        return call
 
     def ternary(self, node):
         self[node].clear()
-        test = self.ccall(name="oppc_bool", node=node, code=[
+        test = self.call(name="oppc_bool", node=node, code=[
             self[node.test],
         ])
         self[node].emit(stmt="(")
@@ -118,25 +118,25 @@ class CodeVisitor(pc_util.Visitor):
             self.ternary(node=node.rvalue)
 
         if isinstance(node.lvalue, pc_ast.SubscriptExpr):
-            ccall = self.ccall(name="oppc_subscript_assign", node=node, stmt=True, code=[
+            call = self.call(name="oppc_subscript_assign", node=node, stmt=True, code=[
                 self[node.lvalue.subject],
                 self[node.lvalue.index],
                 self[node.rvalue],
             ])
         elif isinstance(node.lvalue, pc_ast.RangeSubscriptExpr):
-            ccall = self.ccall(name="oppc_range_subscript_assign", node=node, stmt=True, code=[
+            call = self.call(name="oppc_range_subscript_assign", node=node, stmt=True, code=[
                 self[node.lvalue.subject],
                 self[node.lvalue.start],
                 self[node.lvalue.end],
                 self[node.rvalue],
             ])
         else:
-            ccall = self.ccall(name="oppc_assign", stmt=True, node=node, code=[
+            call = self.call(name="oppc_assign", stmt=True, node=node, code=[
                 self[node.lvalue],
                 self[node.rvalue],
             ])
         with self.pseudocode(node=node):
-            for (level, stmt) in self[ccall]:
+            for (level, stmt) in self[call]:
                 self[node].emit(stmt=stmt, level=level)
 
     @pc_util.Hook(pc_ast.BinaryExpr)
@@ -159,19 +159,19 @@ class CodeVisitor(pc_util.Visitor):
             self.ternary(node=node.right)
 
         if isinstance(node.op, comparison):
-            ccall = self.ccall(name=str(self[node.op]), node=node, code=[
+            call = self.call(name=str(self[node.op]), node=node, code=[
                 self[node.left],
                 self[node.right],
             ])
         else:
             transient = self.transient(node=node)
-            ccall = self.ccall(name=str(self[node.op]), node=node, code=[
+            call = self.call(name=str(self[node.op]), node=node, code=[
                 self[transient],
                 self[node.left],
                 self[node.right],
             ])
         with self.pseudocode(node=node):
-            for (level, stmt) in self[ccall]:
+            for (level, stmt) in self[call]:
                 self[node].emit(stmt=stmt, level=level)
 
     @pc_util.Hook(pc_ast.UnaryExpr)
@@ -179,11 +179,11 @@ class CodeVisitor(pc_util.Visitor):
         yield node
         if isinstance(node.value, pc_ast.IfExpr):
             self.ternary(node=node.value)
-        ccall = self.ccall(name=str(self[node.op]), node=node, code=[
+        call = self.call(name=str(self[node.op]), node=node, code=[
             self[node.value],
         ])
         with self.pseudocode(node=node):
-            for (level, stmt) in self[ccall]:
+            for (level, stmt) in self[call]:
                 self[node].emit(stmt=stmt, level=level)
 
     @pc_util.Hook(
@@ -251,7 +251,7 @@ class CodeVisitor(pc_util.Visitor):
         yield node
         self[node].emit(stmt=str(node))
 
-    @pc_util.Hook(CCall)
+    @pc_util.Hook(Call)
     def CCall(self, node):
         yield node
         end = (";" if node.stmt else "")
@@ -290,12 +290,12 @@ class CodeVisitor(pc_util.Visitor):
     def RepeatExpr(self, node):
         yield node
         transient = self.transient(node=node)
-        ccall = self.ccall(name="oppc_repeat", node=node, code=[
+        call = self.call(name="oppc_repeat", node=node, code=[
             self[transient],
             self[node.subject],
             self[node.times],
         ])
-        for (level, stmt) in self[ccall]:
+        for (level, stmt) in self[call]:
             self[node].emit(stmt=stmt, level=level)
 
     @pc_util.Hook(pc_ast.XLEN)
@@ -317,22 +317,22 @@ class CodeVisitor(pc_util.Visitor):
     @pc_util.Hook(pc_ast.SubscriptExpr)
     def SubscriptExpr(self, node):
         yield node
-        ccall = self.ccall(name="oppc_subscript", node=node, code=[
+        call = self.call(name="oppc_subscript", node=node, code=[
             self[node.subject],
             self[node.index],
         ])
-        for (level, stmt) in self[ccall]:
+        for (level, stmt) in self[call]:
             self[node].emit(stmt=stmt, level=level)
 
     @pc_util.Hook(pc_ast.RangeSubscriptExpr)
     def RangeSubscriptExpr(self, node):
         yield node
-        ccall = self.ccall(name="oppc_subscript", node=node, code=[
+        call = self.call(name="oppc_subscript", node=node, code=[
             self[node.subject],
             self[node.start],
             self[node.end],
         ])
-        for (level, stmt) in self[ccall]:
+        for (level, stmt) in self[call]:
             self[node].emit(stmt=stmt, level=level)
 
     @pc_util.Hook(pc_ast.ForExpr)
@@ -401,7 +401,7 @@ class CodeVisitor(pc_util.Visitor):
     @pc_util.Hook(pc_ast.IfExpr)
     def IfExpr(self, node):
         yield node
-        test = self.ccall(name="oppc_bool", node=node, code=[
+        test = self.call(name="oppc_bool", node=node, code=[
             self[node.test],
         ])
         self[node].emit(stmt="if (")
@@ -420,7 +420,7 @@ class CodeVisitor(pc_util.Visitor):
     @pc_util.Hook(pc_ast.SwitchExpr)
     def SwitchExpr(self, node):
         yield node
-        subject = self.ccall(name="oppc_int64", node=node, code=[
+        subject = self.call(name="oppc_int64", node=node, code=[
             self[node.subject],
         ])
         self[node].emit(stmt="switch (")
@@ -483,8 +483,8 @@ class CodeVisitor(pc_util.Visitor):
     def Call(self, node):
         yield node
         code = tuple(map(lambda arg: self[arg], node.args))
-        ccall = self.ccall(name=str(node.name), node=node, code=code)
-        for (level, stmt) in self[ccall]:
+        call = self.call(name=str(node.name), node=node, code=code)
+        for (level, stmt) in self[call]:
             self[node].emit(stmt=stmt, level=level)
 
     @pc_util.Hook(pc_ast.Symbol)