summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-09-29 08:07:05 +0200
committerAraq <rumpf_a@web.de>2012-09-29 08:07:05 +0200
commit2b49000cbb79d128cacdb0f3616b9fd72a480462 (patch)
treef5f6b07414babd063f3aa301157aeb7ce9c4b8c9 /compiler
parent3bcf9f4e53c8672b3763951274543e7cff6c35e5 (diff)
parente314da76b907f58d050dae1365053ceaa976db7f (diff)
downloadNim-2b49000cbb79d128cacdb0f3616b9fd72a480462.tar.gz
Merge branch 'master' of github.com:Araq/Nimrod
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)