From e3315deda734c3e56f0a8f5e84334cc6071ed89f Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Sun, 14 Jan 2024 21:23:43 +0300 Subject: [PATCH] oppc/code: support string literals --- src/openpower/oppc/pc_code.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/openpower/oppc/pc_code.py b/src/openpower/oppc/pc_code.py index 107099fa..4a2b4f75 100644 --- a/src/openpower/oppc/pc_code.py +++ b/src/openpower/oppc/pc_code.py @@ -279,6 +279,12 @@ class CodeVisitor(pc_util.Visitor): }[node.__class__] self[node].emit(stmt=op) + @pc_util.Hook(pc_ast.StringLiteral) + def StringLiteral(self, node): + yield node + escaped = repr(str(node))[1:-1] + self[node].emit(stmt=f"\"{escaped}\"") + @pc_util.Hook(pc_ast.BinLiteral, pc_ast.DecLiteral, pc_ast.HexLiteral) def Integer(self, node): yield node -- 2.30.2