From 9f85ad387a1e8cc774898da0551caa0842e3baf5 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Sun, 14 Jan 2024 16:22:34 +0300 Subject: [PATCH] oppc/code: support ternary expr inside binary and unary --- src/openpower/oppc/pc_code.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/openpower/oppc/pc_code.py b/src/openpower/oppc/pc_code.py index f713e55b..d18bd140 100644 --- a/src/openpower/oppc/pc_code.py +++ b/src/openpower/oppc/pc_code.py @@ -149,6 +149,11 @@ class CodeVisitor(pc_util.Visitor): pc_ast.Eq, pc_ast.NotEq, pc_ast.Ge, pc_ast.Gt, ) + if isinstance(node.left, pc_ast.IfExpr): + self.ternary(node=node.left) + if isinstance(node.right, pc_ast.IfExpr): + self.ternary(node=node.right) + if isinstance(node.op, comparison): ccall = self.ccall(name=str(self[node.op]), node=node, code=[ self[node.left], @@ -168,6 +173,8 @@ class CodeVisitor(pc_util.Visitor): @pc_util.Hook(pc_ast.UnaryExpr) def UnaryExpr(self, node): 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=[ self[node.value], ]) -- 2.30.2