summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2012-09-28 14:30:19 +0300
committerZahary Karadjov <zahary@gmail.com>2012-09-28 14:30:48 +0300
commit2aabae702d558acfb95003fe6a2aa7ae300f6ed4 (patch)
treec80aa13e3128e6d7435c95a687378424fb4c6142 /compiler
parent95cf849954d44b1440d0bb0da0c3bed378e4f1ad (diff)
downloadNim-2aabae702d558acfb95003fe6a2aa7ae300f6ed4.tar.gz
fixes ttypeselectors
Diffstat (limited to 'compiler')
-rwxr-xr-xcompiler/sem.nim13
-rwxr-xr-xcompiler/semexprs.nim6
2 files changed, 13 insertions, 6 deletions
diff --git a/compiler/sem.nim b/compiler/sem.nim
index 315ff92cd..397581f63 100755
--- a/compiler/sem.nim
+++ b/compiler/sem.nim
@@ -114,6 +114,16 @@ proc semConstExpr(c: PContext, n: PNode): PNode =
 
 include hlo, seminst, semcall
 
+proc symFromType(t: PType, info: TLineInfo): PSym =
+  if t.sym != nil: return t.sym
+  result = newSym(skType, getIdent"AnonType", t.owner, info)
+  result.flags.incl sfAnon
+  result.typ = t
+
+proc symNodeFromType(c: PContext, t: PType, info: TLineInfo): PNode =
+  result = newSymNode(symFromType(t, info), info)
+  result.typ = makeTypeDesc(c, t)
+
 proc semAfterMacroCall(c: PContext, n: PNode, s: PSym): PNode = 
   inc(evalTemplateCounter)
   if evalTemplateCounter > 100:
@@ -133,7 +143,8 @@ proc semAfterMacroCall(c: PContext, n: PNode, s: PSym): PNode =
       result = semStmt(c, result)
     of tyTypeDesc:
       if n.kind == nkStmtList: result.kind = nkStmtListType
-      result.typ = semTypeNode(c, result, nil)
+      var typ = semTypeNode(c, result, nil)
+      result = symNodeFromType(c, typ, n.info)
     else:
       result = semExpr(c, result)
       result = fitNode(c, s.typ.sons[0], result)
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 5dedc9b82..7c147e778 100755
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -1573,11 +1573,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
     result = semExpr(c, n.sons[0], flags)
   of nkTypeOfExpr:
     var typ = semTypeNode(c, n, nil).skipTypes({tyTypeDesc})
-    typ = makeTypedesc(c, typ)
-    var sym = newSym(skType, getIdent"TypeOfExpr", 
-                     typ.owner, n.info).linkTo(typ)
-    sym.flags.incl(sfAnon)
-    result = newSymNode(sym, n.info)
+    result = symNodeFromType(c, typ, n.info)
   of nkCall, nkInfix, nkPrefix, nkPostfix, nkCommand, nkCallStrLit: 
     # check if it is an expression macro:
     checkMinSonsLen(n, 1)