fixes codegen for nil cstrings
This commit is contained in:
parent
e4e6b1f496
commit
cc6fe6e578
1 changed files with 15 additions and 10 deletions
|
|
@ -65,19 +65,24 @@ proc genLiteral(p: BProc, n: PNode, ty: PType): Rope =
|
||||||
else:
|
else:
|
||||||
result = rope("NIM_NIL")
|
result = rope("NIM_NIL")
|
||||||
of nkStrLit..nkTripleStrLit:
|
of nkStrLit..nkTripleStrLit:
|
||||||
if n.strVal.isNil:
|
case skipTypes(ty, abstractVarRange).kind
|
||||||
|
of tyNil:
|
||||||
result = ropecg(p.module, "((#NimStringDesc*) NIM_NIL)", [])
|
result = ropecg(p.module, "((#NimStringDesc*) NIM_NIL)", [])
|
||||||
elif skipTypes(ty, abstractVarRange).kind == tyString:
|
of tyString:
|
||||||
let id = nodeTableTestOrSet(p.module.dataCache, n, p.module.labels)
|
if n.strVal.isNil:
|
||||||
if id == p.module.labels:
|
result = ropecg(p.module, "((#NimStringDesc*) NIM_NIL)", [])
|
||||||
# string literal not found in the cache:
|
|
||||||
result = ropecg(p.module, "((#NimStringDesc*) &$1)",
|
|
||||||
[getStrLit(p.module, n.strVal)])
|
|
||||||
else:
|
else:
|
||||||
result = ropecg(p.module, "((#NimStringDesc*) &$1$2)",
|
let id = nodeTableTestOrSet(p.module.dataCache, n, p.module.labels)
|
||||||
[p.module.tmpBase, rope(id)])
|
if id == p.module.labels:
|
||||||
|
# string literal not found in the cache:
|
||||||
|
result = ropecg(p.module, "((#NimStringDesc*) &$1)",
|
||||||
|
[getStrLit(p.module, n.strVal)])
|
||||||
|
else:
|
||||||
|
result = ropecg(p.module, "((#NimStringDesc*) &$1$2)",
|
||||||
|
[p.module.tmpBase, rope(id)])
|
||||||
else:
|
else:
|
||||||
result = makeCString(n.strVal)
|
if n.strVal.isNil: result = rope("NIM_NIL")
|
||||||
|
else: result = makeCString(n.strVal)
|
||||||
of nkFloatLit, nkFloat64Lit:
|
of nkFloatLit, nkFloat64Lit:
|
||||||
result = rope(n.floatVal.toStrMaxPrecision)
|
result = rope(n.floatVal.toStrMaxPrecision)
|
||||||
of nkFloat32Lit:
|
of nkFloat32Lit:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue