From 7bf27de1919581843bab03d0b551fd4c51da15d6 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Fri, 12 Jan 2024 23:07:18 +0300 Subject: [PATCH] oppc/code: support for exprs --- src/openpower/oppc/pc_code.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/openpower/oppc/pc_code.py b/src/openpower/oppc/pc_code.py index 69dfad85..a1cd4314 100644 --- a/src/openpower/oppc/pc_code.py +++ b/src/openpower/oppc/pc_code.py @@ -189,6 +189,17 @@ class CodeVisitor(pc_util.Visitor): subject = str(self[node.subject]) self[node].emit(f"oppc_range_subscript({subject}, {start}, {end})") + @pc_util.Hook(pc_ast.ForExpr) + def ForExpr(self, node): + yield node + subject = str(self[node.subject]) + start = str(self[node.start]) + end = str(self[node.end]) + self[node].emit(f"for ({subject} = {start}; {subject} != ({end} + 1); ++{subject}) {{") + for (level, stmt) in self[node.body]: + self[node].emit(stmt=stmt, level=level) + self[node].emit(f"}}") + @pc_util.Hook(pc_ast.Call.Name) def CallName(self, node): yield node -- 2.30.2