summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2017-03-10 12:02:55 +0200
committerZahary Karadjov <zahary@gmail.com>2017-03-10 12:02:55 +0200
commit62ef5dfec832e0d9f68033118c02fc69df9e222a (patch)
tree7680d9dbb6ea803c94c4bb84c733e61b060a0efd
parentd1119c120d0b69897d84fb8c213f3e85c0856c88 (diff)
downloadNim-62ef5dfec832e0d9f68033118c02fc69df9e222a.tar.gz
new debugging helper to replace and friends
-rw-r--r--compiler/astalgo.nim17
-rw-r--r--compiler/options.nim5
2 files changed, 17 insertions, 5 deletions
diff --git a/compiler/astalgo.nim b/compiler/astalgo.nim
index 226d5ee42..161e4d637 100644
--- a/compiler/astalgo.nim
+++ b/compiler/astalgo.nim
@@ -67,6 +67,23 @@ proc debug*(n: PSym) {.deprecated.}
 proc debug*(n: PType) {.deprecated.}
 proc debug*(n: PNode) {.deprecated.}
 
+template mdbg*: bool {.dirty.} =
+  when compiles(c.module):
+    c.module.fileIdx == gProjectMainIdx
+  elif compiles(m.c.module):
+    m.c.module.fileIdx == gProjectMainIdx
+  elif compiles(cl.c.module):
+    cl.c.module.fileIdx == gProjectMainIdx
+  elif compiles(p):
+    when compiles(p.lex):
+      p.lex.fileIdx == gProjectMainIdx
+    else:
+      p.module.module.fileIdx == gProjectMainIdx
+  elif compiles(L.fileIdx):
+    L.fileIdx == gProjectMainIdx
+  else:
+    false
+
 # --------------------------- ident tables ----------------------------------
 proc idTableGet*(t: TIdTable, key: PIdObj): RootRef
 proc idTableGet*(t: TIdTable, key: int): RootRef
diff --git a/compiler/options.nim b/compiler/options.nim
index c6d016095..349f9dae1 100644
--- a/compiler/options.nim
+++ b/compiler/options.nim
@@ -420,11 +420,6 @@ proc binaryStrSearch*(x: openArray[string], y: string): int =
       return mid
   result = - 1
 
-template nimdbg*: untyped = c.module.fileIdx == gProjectMainIdx
-template cnimdbg*: untyped = p.module.module.fileIdx == gProjectMainIdx
-template pnimdbg*: untyped = p.lex.fileIdx == gProjectMainIdx
-template lnimdbg*: untyped = L.fileIdx == gProjectMainIdx
-
 proc parseIdeCmd*(s: string): IdeCmd =
   case s:
   of "sug": ideSug