From e33289eea5b899fbff1a00e4eb7a92f0d89cc165 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Sun, 14 Jan 2024 21:41:16 +0300 Subject: [PATCH] oppc/code: support multiple assignments --- src/openpower/oppc/pc_code.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/openpower/oppc/pc_code.py b/src/openpower/oppc/pc_code.py index 4a2b4f75..6ac371cb 100644 --- a/src/openpower/oppc/pc_code.py +++ b/src/openpower/oppc/pc_code.py @@ -164,6 +164,21 @@ class CodeVisitor(pc_util.Visitor): if isinstance(node.rvalue, pc_ast.Attribute): self.fixup_attr(node=node.rvalue) + if isinstance(node.lvalue, pc_ast.Sequence): + if not isinstance(node.rvalue, pc_ast.Sequence): + raise ValueError(node.rvalue) + if len(node.lvalue) != len(node.rvalue): + raise ValueError(node) + for (lvalue, rvalue) in zip(node.lvalue, node.rvalue): + assign = node.__class__( + lvalue=lvalue.clone(), + rvalue=rvalue.clone(), + ) + self.traverse(root=assign) + for (level, stmt) in self[assign]: + self[node].emit(stmt=stmt, level=level) + return + if isinstance(node.lvalue, pc_ast.SubscriptExpr): call = self.call(name="oppc_subscript_assign", node=node, stmt=True, code=[ self[node.lvalue.subject], @@ -553,6 +568,10 @@ class CodeVisitor(pc_util.Visitor): def AttributeName(self, node): yield node + @pc_util.Hook(pc_ast.Sequence) + def Sequence(self, node): + yield node + @pc_util.Hook(pc_ast.Attribute) def Attribute(self, node): yield node -- 2.30.2