def __getitem__(self, node):
return self.__code[node]
- def transient(self, node, value="UINT64_C(0)", bits="(uint8_t)OPPC_XLEN"):
+ def transient(self, node,
+ value="UINT64_C(0)",
+ bits="(uint8_t)OPPC_XLEN"):
transient = Transient(value=value, bits=bits)
- with self.pseudocode(node=node):
- self.traverse(root=transient)
+ self.traverse(root=transient)
return transient
def ccall(self, node, name, code, stmt=False):
code = tuple(map(validate, code))
ccall = CCall(name=name, code=code, stmt=stmt)
- with self.pseudocode(node=node):
- self.traverse(root=ccall)
+ self.traverse(root=ccall)
return ccall
@contextlib.contextmanager
self[node.lvalue],
rvalue,
])
- for (level, stmt) in self[ccall]:
- self[node].emit(stmt=stmt, level=level)
+ with self.pseudocode(node=node):
+ for (level, stmt) in self[ccall]:
+ self[node].emit(stmt=stmt, level=level)
@pc_util.Hook(pc_ast.BinaryExpr)
def BinaryExpr(self, node):
self[node.left],
self[node.right],
])
- for (level, stmt) in self[ccall]:
- self[node].emit(stmt=stmt, level=level)
+ with self.pseudocode(node=node):
+ for (level, stmt) in self[ccall]:
+ self[node].emit(stmt=stmt, level=level)
@pc_util.Hook(pc_ast.UnaryExpr)
def UnaryExpr(self, node):
ccall = self.ccall(name=str(self[node.op]), node=node, code=[
self[node.value],
])
- for (level, stmt) in self[ccall]:
- self[node].emit(stmt=stmt, level=level)
+ with self.pseudocode(node=node):
+ for (level, stmt) in self[ccall]:
+ self[node].emit(stmt=stmt, level=level)
@pc_util.Hook(
pc_ast.Not, pc_ast.Add, pc_ast.Sub,
raise NotImplementedError()
value = f"UINT64_C({fmt(value)})"
transient = self.transient(node=node, value=value, bits=bits)
- for (level, stmt) in self[transient]:
- self[node].emit(stmt=stmt, level=level)
+ with self.pseudocode(node=node):
+ for (level, stmt) in self[transient]:
+ self[node].emit(stmt=stmt, level=level)
@pc_util.Hook(Transient)
def Transient(self, node):
yield node
(value, bits) = ("OPPC_XLEN", "(uint8_t)OPPC_XLEN")
transient = self.transient(node=node, value=value, bits=bits)
- for (level, stmt) in self[transient]:
- self[node].emit(stmt=stmt, level=level)
+ with self.pseudocode(node=node):
+ for (level, stmt) in self[transient]:
+ self[node].emit(stmt=stmt, level=level)
@pc_util.Hook(pc_ast.SubscriptExpr)
def SubscriptExpr(self, node):