From f89b2e2b26115c2ee16d1265db4174f2a884ed07 Mon Sep 17 00:00:00 2001
From: Jonas Maebe <jonas@freepascal.org>
Date: Tue, 1 Jul 2014 16:30:49 +0000
Subject: [PATCH]   + support for tai_string (in nested typed constant
 expressions)

git-svn-id: branches/hlcgllvm@28121 -
---
 compiler/llvm/agllvm.pas | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/compiler/llvm/agllvm.pas b/compiler/llvm/agllvm.pas
index 09561541c0..547c53d7ba 100644
--- a/compiler/llvm/agllvm.pas
+++ b/compiler/llvm/agllvm.pas
@@ -738,6 +738,8 @@ implementation
       var
         hp2: tai;
         s: string;
+        i: longint;
+        ch: ansichar;
       begin
         case hp.typ of
           ait_comment :
@@ -803,8 +805,24 @@ implementation
 
           ait_string :
             begin
-              AsmWrite(target_asm.comment);
-              AsmWriteln('string');
+              if fdecllevel=0 then
+                AsmWrite(target_asm.comment);
+              AsmWrite('c"');
+              for i:=1 to tai_string(hp).len do
+               begin
+                 ch:=tai_string(hp).str[i-1];
+                 case ch of
+                           #0, {This can't be done by range, because a bug in FPC}
+                      #1..#31,
+                   #128..#255,
+                          '"',
+                          '\' : s:='\'+tostr(ord(ch) shr 8)+tostr((ord(ch) and $f));
+                 else
+                   s:=ch;
+                 end;
+                 AsmWrite(s);
+               end;
+              AsmWriteLn('"');
             end;
 
           ait_label :