removal of seq spam in generated C/C++ code and Module.typeStack cleanup (#21964)

* WIP: removal of seq spam in generated C/C++ output and Module.typeStack cleanup

* removal of seq spam in generated C/C++ output and Module.typeStack cleanup
This commit is contained in:
heterodoxic
2023-05-31 16:24:45 +02:00
committed by GitHub
parent 086a3e42eb
commit 0e5c18a73a

View File

@@ -408,12 +408,13 @@ proc getTypeDescWeak(m: BModule; t: PType; check: var IntSet; kind: TypeDescKind
m.typeCache[sig] = result
#echo "adding ", sig, " ", typeToString(t), " ", m.module.name.s
appcg(m, m.s[cfsTypes],
"struct $1 {$N" &
" NI len; $1_Content* p;$N" &
"};$N", [result])
"struct $1 {\n" &
" NI len; $1_Content* p;\n" &
"};\n", [result])
pushType(m, t)
else:
result = getTypeForward(m, t, sig) & seqStar(m)
pushType(m, t)
pushType(m, t)
else:
result = getTypeDescAux(m, t, check, kind)
@@ -428,14 +429,9 @@ proc seqV2ContentType(m: BModule; t: PType; check: var IntSet) =
if result == "":
discard getTypeDescAux(m, t, check, dkVar)
else:
# little hack for now to prevent multiple definitions of the same
# Seq_Content:
appcg(m, m.s[cfsTypes], """$N
$3ifndef $2_Content_PP
$3define $2_Content_PP
struct $2_Content { NI cap; $1 data[SEQ_DECL_SIZE];};
$3endif$N
""", [getTypeDescAux(m, t.skipTypes(abstractInst)[0], check, dkVar), result, rope"#"])
appcg(m, m.s[cfsTypes], """
struct $2_Content { NI cap; $1 data[SEQ_DECL_SIZE]; };
""", [getTypeDescAux(m, t.skipTypes(abstractInst)[0], check, dkVar), result])
proc paramStorageLoc(param: PSym): TStorageLoc =
if param.typ.skipTypes({tyVar, tyLent, tyTypeDesc}).kind notin {
@@ -1116,7 +1112,6 @@ proc finishTypeDescriptions(m: BModule) =
inc(i)
m.typeStack.setLen 0
proc isReloadable(m: BModule; prc: PSym): bool =
return m.hcrOn and sfNonReloadable notin prc.flags