Implement encoding LLVM strings.
This commit is contained in:
parent
7cd2560956
commit
0536c7e683
17
ll.py
17
ll.py
|
@ -217,6 +217,17 @@ def gdecl2s(gdecl):
|
|||
.format(gdecl.name, ty2s(gdecl.ty), ginit2s(gdecl.body)))
|
||||
|
||||
|
||||
def ll_encode(s):
|
||||
# TODO
|
||||
return s
|
||||
def ll_encode(string):
|
||||
res_l = []
|
||||
for c in string:
|
||||
code = ord(c)
|
||||
if code <= 31 or code == 127:
|
||||
res_l.append('\{:02X}'.format(code))
|
||||
elif c == '\\':
|
||||
res_l.append('\\\\')
|
||||
elif c == '"':
|
||||
res_l.append('\\22')
|
||||
else:
|
||||
res_l.append(c)
|
||||
|
||||
return ''.join(res_l)
|
||||
|
|
Loading…
Reference in New Issue
Block a user