summary refs log tree commit diff stats
path: root/compiler/semdata.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/semdata.nim')
-rw-r--r--compiler/semdata.nim20
1 files changed, 20 insertions, 0 deletions
diff --git a/compiler/semdata.nim b/compiler/semdata.nim
index 845efd25a..77a530a15 100644
--- a/compiler/semdata.nim
+++ b/compiler/semdata.nim
@@ -157,6 +157,26 @@ proc get*(p: PProcCon; key: PSym): PSym =
   if p.mapping.data == nil: return nil
   result = PSym(p.mapping.idTableGet(key))
 
+proc getGenSym*(c: PContext; s: PSym): PSym =
+  if sfGenSym notin s.flags: return s
+  var it = c.p
+  while it != nil:
+    result = get(it, s)
+    if result != nil:
+      #echo "got from table ", result.name.s, " ", result.info
+      return result
+    it = it.next
+  result = s
+
+proc considerGenSyms*(c: PContext; n: PNode) =
+  if n.kind == nkSym:
+    let s = getGenSym(c, n.sym)
+    if n.sym != s:
+      n.sym = s
+  else:
+    for i in 0..<n.safeLen:
+      considerGenSyms(c, n.sons[i])
+
 proc newOptionEntry*(): POptionEntry =
   new(result)
   result.options = gOptions