summary refs log tree commit diff stats
path: root/compiler/astyaml.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2023-12-17 18:43:52 +0100
committerGitHub <noreply@github.com>2023-12-17 18:43:52 +0100
commitfe18ec5dc089831c6ea634ade211d8d0dadfec86 (patch)
treebba4a9600c3c53face21ad6cdec45be54f01ca65 /compiler/astyaml.nim
parent9b08abaa0574c32f414c09bb4ef183739003884d (diff)
downloadNim-fe18ec5dc089831c6ea634ade211d8d0dadfec86.tar.gz
types refactoring; WIP (#23086)
Diffstat (limited to 'compiler/astyaml.nim')
-rw-r--r--compiler/astyaml.nim76
1 files changed, 15 insertions, 61 deletions
diff --git a/compiler/astyaml.nim b/compiler/astyaml.nim
index b098d92b9..c7e090cd3 100644
--- a/compiler/astyaml.nim
+++ b/compiler/astyaml.nim
@@ -45,38 +45,11 @@ proc lineInfoToStr*(conf: ConfigRef; info: TLineInfo): string =
   result.addYamlString(toFilename(conf, info))
   result.addf ", $1, $2]", [toLinenumber(info), toColumn(info)]
 
-proc treeToYamlAux(
-  res: var string;
-  conf: ConfigRef;
-  n: PNode;
-  marker: var IntSet;
-  indent, maxRecDepth: int;
-)
-
-proc symToYamlAux(
-  res: var string;
-  conf: ConfigRef;
-  n: PSym;
-  marker: var IntSet;
-  indent, maxRecDepth: int;
-)
-
-proc typeToYamlAux(
-  res: var string;
-  conf: ConfigRef;
-  n: PType;
-  marker: var IntSet;
-  indent, maxRecDepth: int;
-)
-
-proc symToYamlAux(
-    res: var string;
-    conf: ConfigRef;
-    n: PSym;
-    marker: var IntSet;
-    indent: int;
-    maxRecDepth: int;
-) =
+proc treeToYamlAux(res: var string; conf: ConfigRef; n: PNode; marker: var IntSet; indent, maxRecDepth: int)
+proc symToYamlAux(res: var string; conf: ConfigRef; n: PSym; marker: var IntSet; indent, maxRecDepth: int)
+proc typeToYamlAux(res: var string; conf: ConfigRef; n: PType; marker: var IntSet; indent, maxRecDepth: int)
+
+proc symToYamlAux(res: var string; conf: ConfigRef; n: PSym; marker: var IntSet; indent: int; maxRecDepth: int) =
   if n == nil:
     res.add("null")
   elif containsOrIncl(marker, n.id):
@@ -106,14 +79,7 @@ proc symToYamlAux(
     res.addf("\n$1lode: $2", [istr])
     res.treeToYamlAux(conf, n.loc.lode, marker, indent + 1, maxRecDepth - 1)
 
-proc typeToYamlAux(
-    res: var string;
-    conf: ConfigRef;
-    n: PType;
-    marker: var IntSet;
-    indent: int;
-    maxRecDepth: int;
-) =
+proc typeToYamlAux(res: var string; conf: ConfigRef; n: PType; marker: var IntSet; indent: int; maxRecDepth: int) =
   if n == nil:
     res.add("null")
   elif containsOrIncl(marker, n.id):
@@ -130,20 +96,14 @@ proc typeToYamlAux(
     res.addf("\n$1callconv: $2", [istr, makeYamlString($n.callConv)])
     res.addf("\n$1size: $2", [istr, $(n.size)])
     res.addf("\n$1align: $2", [istr, $(n.align)])
-    if n.len > 0:
+    if n.hasElementType:
       res.addf("\n$1sons:")
-      for i in 0..<n.len:
+      for a in n.kids:
         res.addf("\n  - ")
-        res.typeToYamlAux(conf, n[i], marker, indent + 1, maxRecDepth - 1)
-
-proc treeToYamlAux(
-    res: var string;
-    conf: ConfigRef;
-    n: PNode;
-    marker: var IntSet;
-    indent: int;
-    maxRecDepth: int;
-) =
+        res.typeToYamlAux(conf, a, marker, indent + 1, maxRecDepth - 1)
+
+proc treeToYamlAux(res: var string; conf: ConfigRef; n: PNode; marker: var IntSet; indent: int;
+                   maxRecDepth: int) =
   if n == nil:
     res.add("null")
   else:
@@ -178,23 +138,17 @@ proc treeToYamlAux(
         res.addf("\n$1typ: ", [istr])
         res.typeToYamlAux(conf, n.typ, marker, indent + 1, maxRecDepth)
 
-proc treeToYaml*(
-    conf: ConfigRef; n: PNode; indent: int = 0; maxRecDepth: int = -1
-): string =
+proc treeToYaml*(conf: ConfigRef; n: PNode; indent: int = 0; maxRecDepth: int = -1): string =
   var marker = initIntSet()
   result = newStringOfCap(1024)
   result.treeToYamlAux(conf, n, marker, indent, maxRecDepth)
 
-proc typeToYaml*(
-    conf: ConfigRef; n: PType; indent: int = 0; maxRecDepth: int = -1
-): string =
+proc typeToYaml*(conf: ConfigRef; n: PType; indent: int = 0; maxRecDepth: int = -1): string =
   var marker = initIntSet()
   result = newStringOfCap(1024)
   result.typeToYamlAux(conf, n, marker, indent, maxRecDepth)
 
-proc symToYaml*(
-    conf: ConfigRef; n: PSym; indent: int = 0; maxRecDepth: int = -1
-): string =
+proc symToYaml*(conf: ConfigRef; n: PSym; indent: int = 0; maxRecDepth: int = -1): string =
   var marker = initIntSet()
   result = newStringOfCap(1024)
   result.symToYamlAux(conf, n, marker, indent, maxRecDepth)