summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-08-19 10:01:46 +0200
committerAraq <rumpf_a@web.de>2014-08-19 10:01:46 +0200
commitb5248d9037c4240dccdd6d46eac8b104dea10852 (patch)
tree918a72fe631bc81c44f96f2d6a8cd6701e050de9 /compiler
parente662013ee00c2ea8f80d2aff03965d789d38fd78 (diff)
downloadNim-b5248d9037c4240dccdd6d46eac8b104dea10852.tar.gz
fixes #1143
Diffstat (limited to 'compiler')
-rw-r--r--compiler/astalgo.nim27
-rw-r--r--compiler/ccgtypes.nim2
-rw-r--r--compiler/ccgutils.nim6
3 files changed, 21 insertions, 14 deletions
diff --git a/compiler/astalgo.nim b/compiler/astalgo.nim
index 3431aaf41..16efbb172 100644
--- a/compiler/astalgo.nim
+++ b/compiler/astalgo.nim
@@ -390,29 +390,30 @@ proc symToYaml(n: PSym, indent: int = 0, maxRecDepth: int = - 1): PRope =
   var marker = initIntSet()
   result = symToYamlAux(n, marker, indent, maxRecDepth)
 
-proc debugTree(n: PNode, indent: int, maxRecDepth: int): PRope
-proc debugType(n: PType): PRope = 
+proc debugTree(n: PNode, indent: int, maxRecDepth: int; renderType=false): PRope
+proc debugType(n: PType, maxRecDepth=100): PRope = 
   if n == nil: 
     result = toRope("null")
-  else: 
+  else:
     result = toRope($n.kind)
     if n.sym != nil: 
       app(result, " ")
       app(result, n.sym.name.s)
-    if (n.kind != tyString) and (sonsLen(n) > 0): 
+    if (n.kind != tyString) and (sonsLen(n) > 0) and maxRecDepth != 0:
       app(result, "(")
-      for i in countup(0, sonsLen(n) - 1): 
+      for i in countup(0, sonsLen(n) - 1):
         if i > 0: app(result, ", ")
-        if n.sons[i] == nil: 
+        if n.sons[i] == nil:
           app(result, "null")
-        else: 
-          app(result, debugType(n.sons[i])) 
-      if n.kind == tyObject and n.n != nil: 
+        else:
+          app(result, debugType(n.sons[i], maxRecDepth-1))
+      if n.kind == tyObject and n.n != nil:
         app(result, ", node: ")
-        app(result, debugTree(n.n, 2, 100))
+        app(result, debugTree(n.n, 2, maxRecDepth-1, renderType=true))
       app(result, ")")
 
-proc debugTree(n: PNode, indent: int, maxRecDepth: int): PRope = 
+proc debugTree(n: PNode, indent: int, maxRecDepth: int;
+               renderType=false): PRope = 
   if n == nil: 
     result = toRope("null")
   else: 
@@ -436,6 +437,8 @@ proc debugTree(n: PNode, indent: int, maxRecDepth: int): PRope =
             [istr, toRope(n.sym.name.s), toRope(n.sym.id)])
         #     [istr, symToYaml(n.sym, indent, maxRecDepth), 
         #     toRope(n.sym.id)])
+        if renderType and n.sym.typ != nil:
+          appf(result, ",$N$1\"typ\": $2", [istr, debugType(n.sym.typ, 2)])
       of nkIdent: 
         if n.ident != nil: 
           appf(result, ",$N$1\"ident\": $2", [istr, makeYamlString(n.ident.s)])
@@ -447,7 +450,7 @@ proc debugTree(n: PNode, indent: int, maxRecDepth: int): PRope =
           for i in countup(0, sonsLen(n) - 1): 
             if i > 0: app(result, ",")
             appf(result, "$N$1$2", [spaces(indent + 4), debugTree(n.sons[i], 
-                indent + 4, maxRecDepth - 1)])
+                indent + 4, maxRecDepth - 1, renderType)])
           appf(result, "$N$1]", [istr])
     appf(result, ",$N$1\"info\": $2", [istr, lineInfoToStr(n.info)])
     appf(result, "$N$1}", [spaces(indent)])
diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim
index 86142995c..fc6febc6f 100644
--- a/compiler/ccgtypes.nim
+++ b/compiler/ccgtypes.nim
@@ -723,7 +723,7 @@ proc discriminatorTableName(m: BModule, objtype: PType, d: PSym): PRope =
   if objtype.sym == nil: 
     internalError(d.info, "anonymous obj with discriminator")
   result = ropef("NimDT_$1_$2", [
-    toRope(objtype.sym.name.s.mangle), toRope(d.name.s.mangle)])
+    toRope(objtype.id), toRope(d.name.s.mangle)])
 
 proc discriminatorTableDecl(m: BModule, objtype: PType, d: PSym): PRope = 
   discard cgsym(m, "TNimNode")
diff --git a/compiler/ccgutils.nim b/compiler/ccgutils.nim
index 6af6a857c..65957584a 100644
--- a/compiler/ccgutils.nim
+++ b/compiler/ccgutils.nim
@@ -94,6 +94,10 @@ proc getUniqueType*(key: PType): PType =
     else: result = getUniqueType(lastSon(key))
   of tyGenericInst, tyOrdinal, tyMutable, tyConst, tyIter, tyStatic:
     result = getUniqueType(lastSon(key))
+    #let obj = lastSon(key)
+    #if obj.sym != nil and obj.sym.name.s == "TOption":
+    #  echo "for ", typeToString(key), " I returned "
+    #  debug result
   of tyArrayConstr, tyGenericInvokation, tyGenericBody,
      tyOpenArray, tyArray, tySet, tyRange, tyTuple,
      tyPtr, tyRef, tySequence, tyForward, tyVarargs, tyProxy, tyVar:
@@ -126,7 +130,7 @@ proc getUniqueType*(key: PType): PType =
         if t != nil and sameType(t, key): 
           return t
       idTablePut(gTypeTable[k], key, key)
-      result = key
+      result = key    
   of tyEnum:
     result = PType(idTableGet(gTypeTable[k], key))
     if result == nil: