From: Dmitry Selyutin Date: Sun, 14 Jan 2024 18:23:43 +0000 (+0300) Subject: oppc/code: support string literals X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e3315deda734c3e56f0a8f5e84334cc6071ed89f;p=openpower-isa.git oppc/code: support string literals --- 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