summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xcompiler/semgnrc.nim18
-rw-r--r--lib/pure/nimprof.nim2
-rwxr-xr-xlib/system.nim6
-rwxr-xr-xlib/system/assign.nim2
-rwxr-xr-xlib/system/profiler.nim5
-rwxr-xr-xtodo.txt6
6 files changed, 19 insertions, 20 deletions
diff --git a/compiler/semgnrc.nim b/compiler/semgnrc.nim
index e9c746db5..861161acc 100755
--- a/compiler/semgnrc.nim
+++ b/compiler/semgnrc.nim
@@ -80,15 +80,13 @@ proc semGenericStmt(c: PContext, n: PNode,
   of nkIdent, nkAccQuoted:
     var s = SymtabGet(c.Tab, n.ident)
     if s == nil:
-      # no error if symbol cannot be bound, unless in ``bind`` context:
-      if withinBind in flags:
-        localError(n.info, errUndeclaredIdentifier, n.ident.s)
+      localError(n.info, errUndeclaredIdentifier, n.ident.s)
     else:
       if withinBind in flags or s.id in toBind:
         result = symChoice(c, n, s, scClosed)
       else: result = semGenericStmtSymbol(c, n, s)
   of nkDotExpr:
-    var s = QualifiedLookUp(c, n, {})
+    var s = QualifiedLookUp(c, n, {checkUndeclared})
     if s != nil: result = semGenericStmtSymbol(c, n, s)
     # XXX for example: ``result.add`` -- ``add`` needs to be looked up here...
   of nkEmpty, nkSym..nkNilLit: 
@@ -100,10 +98,12 @@ proc semGenericStmt(c: PContext, n: PNode,
   of nkCall, nkHiddenCallConv, nkInfix, nkPrefix, nkCommand, nkCallStrLit: 
     # check if it is an expression macro:
     checkMinSonsLen(n, 1)
-    var s = qualifiedLookup(c, n.sons[0], {})
+    var s = qualifiedLookup(c, n.sons[0], {checkUndeclared})
     var first = 0
+    var isDefinedMagic = false
     if s != nil: 
       incl(s.flags, sfUsed)
+      isDefinedMagic = s.magic in {mDefined, mDefinedInScope, mCompiles}
       case s.kind
       of skMacro:
         if macroToExpand(s):
@@ -135,14 +135,15 @@ proc semGenericStmt(c: PContext, n: PNode,
       else:
         result.sons[0] = newSymNode(s, n.sons[0].info)
         first = 1
-    for i in countup(first, sonsLen(result) - 1): 
-      result.sons[i] = semGenericStmt(c, result.sons[i], flags, toBind)
+    if not isDefinedMagic:
+      for i in countup(first, sonsLen(result) - 1): 
+        result.sons[i] = semGenericStmt(c, result.sons[i], flags, toBind)
   of nkMacroStmt: 
     checkMinSonsLen(n, 2)
     var a: PNode
     if isCallExpr(n.sons[0]): a = n.sons[0].sons[0]
     else: a = n.sons[0]
-    var s = qualifiedLookup(c, a, {})
+    var s = qualifiedLookup(c, a, {checkUndeclared})
     if s != nil and macroToExpand(s):
       result = semMacroStmt(c, n, {}, false)
     for i in countup(0, sonsLen(result)-1): 
@@ -287,6 +288,7 @@ proc semGenericStmt(c: PContext, n: PNode,
     else: body = n.sons[bodyPos]
     n.sons[bodyPos] = semGenericStmtScope(c, body, flags, toBind)
     closeScope(c.tab)
+  of nkPragma, nkPragmaExpr: nil
   else: 
     for i in countup(0, sonsLen(n) - 1): 
       result.sons[i] = semGenericStmt(c, n.sons[i], flags, toBind)
diff --git a/lib/pure/nimprof.nim b/lib/pure/nimprof.nim
index 8cf6ba683..7a907d2ca 100644
--- a/lib/pure/nimprof.nim
+++ b/lib/pure/nimprof.nim
@@ -48,7 +48,7 @@ var
   totalCalls = 0
 
 var
-  interval: TNanos = 1_000_000 - tickCountCorrection # 5ms
+  interval: TNanos = 5_000_000 - tickCountCorrection # 5ms
 
 proc setSamplingFrequency*(intervalInUs: int) =
   ## set this to change the sampling frequency. Default value is 5ms.
diff --git a/lib/system.nim b/lib/system.nim
index e56a7916e..a60433e57 100755
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -168,9 +168,6 @@ proc `..`*[T](b: T): TSlice[T] {.noSideEffect, inline.} =
   ## `slice`:idx: operator that constructs an interval ``[default(T), b]``
   result.b = b
 
-proc contains*[T](s: TSlice[T], value: T): bool {.noSideEffect, inline.} = 
-  result = value >= s.a and value <= s.b
-
 when not defined(niminheritable):
   {.pragma: inheritable.}
 
@@ -672,6 +669,9 @@ proc contains*[T](x: set[T], y: T): bool {.magic: "InSet", noSideEffect.}
   ## is achieved by reversing the parameters for ``contains``; ``in`` then
   ## passes its arguments in reverse order.
 
+proc contains*[T](s: TSlice[T], value: T): bool {.noSideEffect, inline.} =
+  result = s.a <= value and value <= s.b
+
 template `in` * (x, y: expr): expr {.immediate.} = contains(y, x)
 template `not_in` * (x, y: expr): expr {.immediate.} = not contains(y, x)
 
diff --git a/lib/system/assign.nim b/lib/system/assign.nim
index a6c274250..895a7f9fd 100755
--- a/lib/system/assign.nim
+++ b/lib/system/assign.nim
@@ -144,6 +144,8 @@ proc objectInit(dest: Pointer, typ: PNimType) =
   
 # ---------------------- assign zero -----------------------------------------
 
+# dummy declaration; XXX we need 'mixin' here
+proc destroy(x: int) = nil
 proc nimDestroyRange*[T](r: T) =
   # internal proc used for destroying sequences and arrays
   for i in countup(0, r.len - 1): destroy(r[i])
diff --git a/lib/system/profiler.nim b/lib/system/profiler.nim
index 28edeff7a..eafa010ef 100755
--- a/lib/system/profiler.nim
+++ b/lib/system/profiler.nim
@@ -11,10 +11,7 @@
 # code generator. The idea is to inject the instruction stream
 # with 'nimProfile()' calls. These calls are injected at every loop end
 # (except perhaps loops that have no side-effects). At every Nth call a
-# stack trace is taken. A stack tace is a list of cstrings. We have a count
-# table of those.
-# 
-# The nice thing about this profiler is that it's completely time independent!
+# stack trace is taken. A stack tace is a list of cstrings.
 
 {.push profiler: off.}
 
diff --git a/todo.txt b/todo.txt
index 91cd02429..dda33cf0a 100755
--- a/todo.txt
+++ b/todo.txt
@@ -2,12 +2,10 @@ version 0.9.0
 =============
 
 - make 'bind' default for templates and introduce 'mixin'
+- make 'm: stmt' use overloading resolution
 
 - implicit deref for parameter matching
 - optimize genericAssign in the code generator
-- the lookup rules for generics really are too permissive; global scope only
-  doesn't fly with closures though; for a start add a warning when processing
-  generic code
 
 
 Bugs
@@ -38,7 +36,7 @@ version 0.9.XX
     echo a
     echo b)
 
-- make 'm: stmt' use overloading resolution
+- implement the "snoopResult" pragma
 - implement "closure tuple consists of a single 'ref'" optimization
 - implement for loop transformation for first class iterators
 - JS gen: