summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorheterodoxic <122719743+heterodoxic@users.noreply.github.com>2023-05-31 16:24:45 +0200
committerGitHub <noreply@github.com>2023-05-31 16:24:45 +0200
commit0e5c18a73a2d72067ba18211fa20e4782175fd40 (patch)
treebe39952ab7dcf7717f22b8937319744c42ad8746
parent086a3e42ebe1fbe8d8129168de3925688e495540 (diff)
downloadNim-0e5c18a73a2d72067ba18211fa20e4782175fd40.tar.gz
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
-rw-r--r--compiler/ccgtypes.nim21
1 files changed, 8 insertions, 13 deletions
diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim
index 9bcfa41ef..6423aa487 100644
--- a/compiler/ccgtypes.nim
+++ b/compiler/ccgtypes.nim
@@ -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