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
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
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="(")
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)
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)
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(
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 "")
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)
@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)
@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 (")
@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 (")
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)