--gc:destructors: next steps; WIP
This commit is contained in:
parent
4389409e26
commit
f485ebe162
8 changed files with 108 additions and 64 deletions
|
|
@ -54,9 +54,9 @@ proc genStringLiteralV1(m: BModule; n: PNode): Rope =
|
|||
proc genStringLiteralDataOnlyV2(m: BModule, s: string): Rope =
|
||||
result = getTempName(m)
|
||||
addf(m.s[cfsData], "static const struct {$n" &
|
||||
" NI cap; void* allocator; NIM_CHAR[$2] data;$n" &
|
||||
" NI cap; void* allocator; NIM_CHAR data[$2];$n" &
|
||||
"} $1 = { $2, NIM_NIL, $3 };$n",
|
||||
[result, rope(len(s)+1), makeCString(s)])
|
||||
[result, rope(len(s)), makeCString(s)])
|
||||
|
||||
proc genStringLiteralV2(m: BModule; n: PNode): Rope =
|
||||
let id = nodeTableTestOrSet(m.dataCache, n, m.labels)
|
||||
|
|
@ -67,10 +67,22 @@ proc genStringLiteralV2(m: BModule; n: PNode): Rope =
|
|||
let pureLit = genStringLiteralDataOnlyV2(m, n.strVal)
|
||||
result = getTempName(m)
|
||||
addf(m.s[cfsData], "static const NimStringV2 $1 = {$2, (NimStrPayload*)&$3};$n",
|
||||
[result, rope(len(n.strVal)+1), pureLit])
|
||||
[result, rope(len(n.strVal)), pureLit])
|
||||
else:
|
||||
result = m.tmpBase & rope(id)
|
||||
|
||||
proc genStringLiteralV2Const(m: BModule; n: PNode): Rope =
|
||||
let id = nodeTableTestOrSet(m.dataCache, n, m.labels)
|
||||
var pureLit: Rope
|
||||
if id == m.labels:
|
||||
discard cgsym(m, "NimStrPayload")
|
||||
discard cgsym(m, "NimStringV2")
|
||||
# string literal not found in the cache:
|
||||
pureLit = genStringLiteralDataOnlyV2(m, n.strVal)
|
||||
else:
|
||||
pureLit = m.tmpBase & rope(id)
|
||||
result = "{$1, (NimStrPayload*)&$2}" % [rope(len(n.strVal)), pureLit]
|
||||
|
||||
# ------ Version selector ---------------------------------------------------
|
||||
|
||||
proc genStringLiteralDataOnly(m: BModule; s: string; info: TLineInfo): Rope =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue