summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rwxr-xr-xcompiler/ast.nim18
-rwxr-xr-xcompiler/semexprs.nim23
-rwxr-xr-xcompiler/semtempl.nim6
3 files changed, 15 insertions, 32 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim
index 2c8ca52d7..04631a059 100755
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -922,12 +922,6 @@ proc delSon(father: PNode, idx: int) =
   for i in countup(idx, length - 2): father.sons[i] = father.sons[i + 1]
   setlen(father.sons, length - 1)
 
-proc hasSons*(n: PNode): bool {.inline.} =
-  result = n.kind notin { nkCharLit..nkInt64Lit,
-                          nkFloatLit..nkFloat64Lit,
-                          nkStrLit..nkTripleStrLit,
-                          nkSym, nkIdent }
-
 proc copyNode(src: PNode): PNode = 
   # does not copy its sons!
   if src == nil: 
@@ -959,18 +953,6 @@ proc shallowCopy*(src: PNode): PNode =
   of nkStrLit..nkTripleStrLit: result.strVal = src.strVal
   else: newSeq(result.sons, sonsLen(src))
 
-proc copySons*(src: PNode): Pnode =
-  # copies a node and its immediate sons
-  if src == nil: return nil
-  assert src.hasSons
-  result = newNode(src.kind)
-  result.info = src.info
-  result.typ = src.typ
-  result.flags = src.flags * PersistentNodeFlags
-  newSeq(result.sons, src.len)
-  for i in countup(0, src.len - 1):
-    result.sons[i] = src.sons[i]
-
 proc copyTree(src: PNode): PNode = 
   # copy a whole syntax tree; performs deep copying
   if src == nil: 
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 704f182c8..5a339c5a7 100755
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -491,15 +491,15 @@ proc expectStringArg(c: PContext, n: PNode, i: int): PNode =
   
 include semmagic
 
-proc semOverloadedCallAnalyseEffects(c: PContext, n: PNode, orig: PNode,
+proc semOverloadedCallAnalyseEffects(c: PContext, n: PNode, nOrig: PNode,
                                      flags: TExprFlags): PNode =
   if efWantIterator in flags:
-    result = semOverloadedCall(c, n, orig, {skIterator})
+    result = semOverloadedCall(c, n, nOrig, {skIterator})
   elif efInTypeOf in flags:
     # for ``type(countup(1,3))``, see ``tests/ttoseq``.
-    result = semOverloadedCall(c, n, orig, {skIterator, skProc, skMethod, skConverter, skMacro, skTemplate})
+    result = semOverloadedCall(c, n, nOrig, {skIterator, skProc, skMethod, skConverter, skMacro, skTemplate})
   else:
-    result = semOverloadedCall(c, n, orig, {skProc, skMethod, skConverter, skMacro, skTemplate})
+    result = semOverloadedCall(c, n, nOrig, {skProc, skMethod, skConverter, skMacro, skTemplate})
   if result != nil:
     if result.sons[0].kind != nkSym: 
       InternalError("semDirectCallAnalyseEffects")
@@ -513,9 +513,9 @@ proc semOverloadedCallAnalyseEffects(c: PContext, n: PNode, orig: PNode,
         if {sfImportc, sfSideEffect} * callee.flags != {}:
           incl(c.p.owner.flags, sfSideEffect)
 
-proc semDirectCallAnalyseEffects(c: PContext, n: PNode, orig: PNode,
+proc semDirectCallAnalyseEffects(c: PContext, n: PNode, nOrig: PNode,
                                  flags: TExprFlags): PNode =
-  result = semOverloadedCallAnalyseEffects(c, n, orig, flags)
+  result = semOverloadedCallAnalyseEffects(c, n, nOrig, flags)
 
 proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode = 
   result = nil
@@ -532,14 +532,14 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
       return semExpr(c, result, flags)
   else: 
     n.sons[0] = semExpr(c, n.sons[0])
-  let orig = n.copySons
+  let nOrig = n.copyTree
   semOpAux(c, n)
   var t: PType = nil
   if (n.sons[0].typ != nil): t = skipTypes(n.sons[0].typ, abstractInst)
   if (t != nil) and (t.kind == tyProc): 
     var m: TCandidate
     initCandidate(m, t)
-    matches(c, n, orig, m)
+    matches(c, n, nOrig, m)
     if m.state != csMatch: 
       var msg = msgKindToString(errTypeMismatch)
       for i in countup(1, sonsLen(n) - 1): 
@@ -560,7 +560,7 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
     # the old ``prc`` (which is likely an nkIdent) has to be restored:
     if result == nil: 
       n.sons[0] = prc
-      result = semOverloadedCallAnalyseEffects(c, n, orig, flags)
+      result = semOverloadedCallAnalyseEffects(c, n, nOrig, flags)
     if result == nil: 
       GlobalError(n.info, errExprXCannotBeCalled, 
                   renderTree(n, {renderNoComments}))
@@ -571,7 +571,7 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
 
 proc semDirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode = 
   # this seems to be a hotspot in the compiler!
-  let nOrig = n.copySons
+  let nOrig = n.copyTree
   semOpAux(c, n)
   result = semOverloadedCallAnalyseEffects(c, n, nOrig, flags)
   if result == nil: 
@@ -1269,12 +1269,11 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
     if s != nil: 
       case s.kind
       of skMacro:
-        if c.filename.endsWith("hello.nim") and sfImmediate notin s.flags:
+        if false and sfImmediate notin s.flags: # XXX not yet enabled
           result = semDirectOp(c, n, flags)
         else:
           result = semMacroExpr(c, n, s)
       of skTemplate:
-        var hello = c.filename.endsWith("hello.nim")
         if sfImmediate notin s.flags:
           result = semDirectOp(c, n, flags)
         else:
diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim
index b1f70803e..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
@@ -191,10 +193,10 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
   result = n
   if n.sons[bodyPos].kind == nkEmpty: 
     LocalError(n.info, errImplOfXexpected, s.name.s)
-  let curScope = c.tab.tos - 2 # -2 because we have a scope open for parameters
+  let curScope = c.tab.tos - 1
   var proto = SearchForProc(c, s, curScope)
   if proto == nil:
-    addInterfaceOverloadableSymAt(c, s, c.tab.tos - 2)
+    addInterfaceOverloadableSymAt(c, s, curScope)
   else:
     SymTabReplace(c.tab.stack[curScope], proto, s)