From 62ef5dfec832e0d9f68033118c02fc69df9e222a Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Fri, 10 Mar 2017 12:02:55 +0200 Subject: [PATCH] new debugging helper to replace and friends --- compiler/astalgo.nim | 17 +++++++++++++++++ compiler/options.nim | 5 ----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/compiler/astalgo.nim b/compiler/astalgo.nim index 226d5ee42c..161e4d6372 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 c6d0160951..349f9dae16 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