summary refs log tree commit diff stats
path: root/compiler/semtempl.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-03-19 22:12:08 +0100
committerAraq <rumpf_a@web.de>2012-03-19 22:12:08 +0100
commitbb1885115db4d8075a6c688b58d4ccb91b6ad24a (patch)
tree311e436ba00df97885cc662bb3f690a3511cbf90 /compiler/semtempl.nim
parent7cd2f353c72ced274e5a6e6c0f92e8e32e9d6374 (diff)
parent7b41b0f84113d3b9901d5c598dd909a1df6f960f (diff)
downloadNim-bb1885115db4d8075a6c688b58d4ccb91b6ad24a.tar.gz
Merge branch 'master' of github.com:Araq/Nimrod
Diffstat (limited to 'compiler/semtempl.nim')
-rwxr-xr-xcompiler/semtempl.nim24
1 files changed, 12 insertions, 12 deletions
diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim
index 770a3ae8e..2600d80cb 100755
--- a/compiler/semtempl.nim
+++ b/compiler/semtempl.nim
@@ -7,6 +7,8 @@
 #    distribution, for details about the copyright.
 #
 
+# included from sem.nim
+
 proc isExpr(n: PNode): bool = 
   # returns true if ``n`` looks like an expression
   case n.kind
@@ -54,11 +56,6 @@ proc evalTemplateArgs(c: PContext, n: PNode, s: PSym): PNode =
     else: arg = copyTree(s.typ.n.sons[i].sym.ast)
     if arg == nil or arg.kind == nkEmpty: 
       LocalError(n.info, errWrongNumberOfArguments)
-    elif not (s.typ.sons[i].kind in {tyTypeDesc, tyStmt, tyExpr}): 
-      # concrete type means semantic checking for argument:
-      # XXX This is horrible! Better make semantic checking use some kind
-      # of fixpoint iteration ...
-      arg = fitNode(c, s.typ.sons[i], semExprWithType(c, arg))
     addSon(result, arg)
 
 proc evalTemplate*(c: PContext, n: PNode, sym: PSym): PNode = 
@@ -167,9 +164,9 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
   # check parameter list:
   pushOwner(s)
   openScope(c.tab)
-  n.sons[namePos] = newSymNode(s) # check that no pragmas exist:
-  if n.sons[pragmasPos].kind != nkEmpty: 
-    LocalError(n.info, errNoPragmasAllowedForX, "template") 
+  n.sons[namePos] = newSymNode(s)
+  if n.sons[pragmasPos].kind != nkEmpty:
+    pragma(c, s, n.sons[pragmasPos], templatePragmas)
   # check that no generic parameters exist:
   if n.sons[genericParamsPos].kind != nkEmpty: 
     LocalError(n.info, errNoGenericParamsAllowedForX, "template")
@@ -185,8 +182,6 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
       # use ``stmt`` as implicit result type
       s.typ.sons[0] = newTypeS(tyStmt, c)
       s.typ.n.sons[0] = newNodeIT(nkType, n.info, s.typ.sons[0])
-  # XXX: obsoleted - happens in semParamList # 
-  # addParams(c, s.typ.n)       # resolve parameters:
   var toBind = initIntSet()
   n.sons[bodyPos] = resolveTemplateParams(c, n.sons[bodyPos], false, toBind)
   if s.typ.sons[0].kind notin {tyStmt, tyTypeDesc}:
@@ -198,5 +193,10 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
   result = n
   if n.sons[bodyPos].kind == nkEmpty: 
     LocalError(n.info, errImplOfXexpected, s.name.s)
-  # add identifier of template as a last step to not allow recursive templates:
-  addInterfaceDecl(c, s)
+  let curScope = c.tab.tos - 1
+  var proto = SearchForProc(c, s, curScope)
+  if proto == nil:
+    addInterfaceOverloadableSymAt(c, s, curScope)
+  else:
+    SymTabReplace(c.tab.stack[curScope], proto, s)
+