gc:destructors: progress
This commit is contained in:
parent
f2f0b5d695
commit
417d27c544
3 changed files with 16 additions and 10 deletions
|
|
@ -2614,20 +2614,15 @@ proc genConstSeqV2(p: BProc, n: PNode, t: PType): Rope =
|
||||||
data.add genConstExpr(p, n.sons[i])
|
data.add genConstExpr(p, n.sons[i])
|
||||||
data.add("}")
|
data.add("}")
|
||||||
|
|
||||||
result = getTempName(p.module)
|
|
||||||
let payload = getTempName(p.module)
|
let payload = getTempName(p.module)
|
||||||
let base = t.skipTypes(abstractInst).sons[0]
|
let base = t.skipTypes(abstractInst).sons[0]
|
||||||
|
|
||||||
appcg(p.module, cfsData,
|
appcg(p.module, cfsData,
|
||||||
"static const struct {$n" &
|
"static const struct {$n" &
|
||||||
" NI cap; void* allocator; $1 data[$2];$n" &
|
" NI cap; void* allocator; $1 data[$2];$n" &
|
||||||
"} $3 = {$2, NIM_NIL, $4};$n" &
|
"} $3 = {$2, NIM_NIL, $4};$n", [
|
||||||
"static NIM_CONST struct {$n" &
|
getTypeDesc(p.module, base), rope(len(n)), payload, data])
|
||||||
" NI len;$n" &
|
result = "{$1, ($2*)&$3}" % [rope(len(n)), getSeqPayloadType(p.module, t), payload]
|
||||||
" $6 p;$n" &
|
|
||||||
"} $5 = {$2, ($6)&$3};$n", [
|
|
||||||
getTypeDesc(p.module, base), rope(len(n)), payload, data,
|
|
||||||
result, getTypeDesc(p.module, t)])
|
|
||||||
|
|
||||||
proc genConstExpr(p: BProc, n: PNode): Rope =
|
proc genConstExpr(p: BProc, n: PNode): Rope =
|
||||||
case n.kind
|
case n.kind
|
||||||
|
|
|
||||||
|
|
@ -279,6 +279,7 @@ proc getSimpleTypeDesc(m: BModule, typ: PType): Rope =
|
||||||
of tyString:
|
of tyString:
|
||||||
case detectStrVersion(m)
|
case detectStrVersion(m)
|
||||||
of 2:
|
of 2:
|
||||||
|
discard cgsym(m, "NimStrPayload")
|
||||||
discard cgsym(m, "NimStringV2")
|
discard cgsym(m, "NimStringV2")
|
||||||
result = typeNameOrLiteral(m, typ, "NimStringV2")
|
result = typeNameOrLiteral(m, typ, "NimStringV2")
|
||||||
else:
|
else:
|
||||||
|
|
@ -545,7 +546,8 @@ proc getRecordDesc(m: BModule, typ: PType, name: Rope,
|
||||||
let popExSym = magicsys.getCompilerProc(m.g.graph, "popCurrentExceptionEx")
|
let popExSym = magicsys.getCompilerProc(m.g.graph, "popCurrentExceptionEx")
|
||||||
if lfDynamicLib in popExSym.loc.flags and sfImportc in popExSym.flags:
|
if lfDynamicLib in popExSym.loc.flags and sfImportc in popExSym.flags:
|
||||||
# echo popExSym.flags, " ma flags ", popExSym.loc.flags
|
# echo popExSym.flags, " ma flags ", popExSym.loc.flags
|
||||||
result = "extern " & getTypeDescAux(m, popExSym.typ, check) & " " & mangleName(m, popExSym) & ";\L" & result
|
result = "extern " & getTypeDescAux(m, popExSym.typ, check) & " " &
|
||||||
|
mangleName(m, popExSym) & ";\L" & result
|
||||||
else:
|
else:
|
||||||
result = genProcHeader(m, popExSym) & ";\L" & result
|
result = genProcHeader(m, popExSym) & ";\L" & result
|
||||||
hasField = true
|
hasField = true
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: '''nim c --gc:destructors $file'''
|
cmd: '''nim c --gc:destructors $file'''
|
||||||
output: '''1 1'''
|
output: '''hi
|
||||||
|
ho
|
||||||
|
ha
|
||||||
|
1 1'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import allocators
|
import allocators
|
||||||
|
|
@ -12,6 +15,12 @@ proc main =
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
const
|
||||||
|
test = @["hi", "ho", "ha"]
|
||||||
|
|
||||||
|
for t in test:
|
||||||
|
echo t
|
||||||
|
|
||||||
#echo s
|
#echo s
|
||||||
let (a, d) = allocCounters()
|
let (a, d) = allocCounters()
|
||||||
cprintf("%ld %ld\n", a, d)
|
cprintf("%ld %ld\n", a, d)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue