def UnaryExpr(self, node):
yield node
if isinstance(node.value, (pc_ast.GPR, pc_ast.FPR)):
- self.__regfetch[str(node.value)].append(node.value)
- stmt = "".join([
- str(self[node.op]),
- f"oppc_reg_fetch({str(self[node.value])})",
- ])
+ value = f"oppc_reg_fetch({str(self[node.value])})"
else:
- stmt = "".join([
- str(self[node.op]),
- f"({str(self[node.value])})",
- ])
- self[node].emit(stmt=stmt)
+ value = f"({str(self[node.value])})"
+ if isinstance(node.op, (pc_ast.Not, pc_ast.Add, pc_ast.Sub)):
+ op = {
+ pc_ast.Not: "~",
+ pc_ast.Add: "+",
+ pc_ast.Sub: "-",
+ }[node.op.__class__]
+ self[node].emit(stmt="".join([op, value]))
+ else:
+ raise ValueError(node)
@pc_util.Hook(pc_ast.Not, pc_ast.Add, pc_ast.Sub)
def Op(self, node):
yield node
- mapping = {
- pc_ast.Not: "~",
- pc_ast.Add: "+",
- pc_ast.Sub: "-",
- }
- stmt = mapping[node.__class__]
- self[node].emit(stmt=stmt)
@pc_util.Hook(pc_ast.BinLiteral, pc_ast.DecLiteral, pc_ast.HexLiteral)
def Integer(self, node):