diff options
Diffstat (limited to 'nim/ccgutils.pas')
-rw-r--r-- | nim/ccgutils.pas | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/nim/ccgutils.pas b/nim/ccgutils.pas index 97ef65f70..56eff6c9e 100644 --- a/nim/ccgutils.pas +++ b/nim/ccgutils.pas @@ -20,6 +20,7 @@ uses function toCChar(c: Char): string; function makeCString(const s: string): PRope; +function makeLLVMString(const s: string): PRope; function TableGetType(const tab: TIdTable; key: PType): PObject; function GetUniqueType(key: PType): PType; @@ -154,6 +155,33 @@ begin app(result, toRope(res)); end; +function makeLLVMString(const s: string): PRope; +const + MaxLineLength = 64; +var + i: int; + res: string; +begin + result := nil; + res := 'c"'; + for i := strStart to length(s)+strStart-1 do begin + if (i-strStart+1) mod MaxLineLength = 0 then begin + app(result, toRope(res)); + setLength(res, 0); + end; + case s[i] of + #0..#31, #128..#255, '"', '\': begin + addChar(res, '\'); + add(res, toHex(ord(s[i]), 2)); + end + else + addChar(res, s[i]) + end; + end; + add(res, '\00"'); + app(result, toRope(res)); +end; + begin InitTypeTables(); end. |