From 0ee7df7eae56bb7b577d8c13b56182b8f7338ea2 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Sun, 14 Jan 2024 17:19:58 +0300 Subject: [PATCH] oppc/code: fix if exprs check --- src/openpower/oppc/pc_code.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/openpower/oppc/pc_code.py b/src/openpower/oppc/pc_code.py index de0150f4..28dfb34a 100644 --- a/src/openpower/oppc/pc_code.py +++ b/src/openpower/oppc/pc_code.py @@ -77,9 +77,12 @@ class CodeVisitor(pc_util.Visitor): def ternary(self, node): self[node].clear() + test = self.ccall(name="oppc_bool", node=node, code=[ + self[node.test], + ]) self[node].emit(stmt="(") with self[node]: - for (level, stmt) in self[node.test]: + for (level, stmt) in self[test]: self[node].emit(stmt=stmt, level=level) self[node].emit(stmt="?") for (level, stmt) in self[node.body]: @@ -400,9 +403,12 @@ 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=[ + self[node.test], + ]) self[node].emit(stmt="if (") with self[node]: - for (level, stmt) in self[node.test]: + for (level, stmt) in self[test]: self[node].emit(stmt=stmt, level=level) self[node].emit(stmt=") {") for (level, stmt) in self[node.body]: -- 2.30.2