summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorArne Döring <arne.doering@gmx.net>2019-09-18 20:02:30 +0200
committerAndreas Rumpf <rumpf_a@web.de>2019-09-18 20:02:30 +0200
commit188ce5f3ee5c83d749918f9f286537d65a513c53 (patch)
treed3a12f3b637c43aedcfec76a4acb736ac874ff23 /lib
parentf8000d4ba14414657b2255fda3ca058074166b76 (diff)
downloadNim-188ce5f3ee5c83d749918f9f286537d65a513c53.tar.gz
add nodeId proc to macros (#11456)
* add nodeId proc to macros

* add doc comment.

* fix typo
Diffstat (limited to 'lib')
-rw-r--r--lib/core/macros.nim6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim
index b0414153e..73f5790fa 100644
--- a/lib/core/macros.nim
+++ b/lib/core/macros.nim
@@ -1426,6 +1426,12 @@ proc boolVal*(n: NimNode): bool {.compileTime, noSideEffect.} =
   if n.kind == nnkIntLit: n.intVal != 0
   else: n == bindSym"true" # hacky solution for now
 
+when defined(nimMacrosGetNodeId):
+  proc nodeID*(n: NimNode): int {.magic: NodeId.}
+    ## Returns the id of ``n``, when the compiler has been compiled
+    ## with the flag ``-d:useNodeids``, otherwise returns ``-1``. This
+    ## proc is for the purpose to debug the compiler only.
+
 macro expandMacros*(body: typed): untyped =
   ## Expands one level of macro - useful for debugging.
   ## Can be used to inspect what happens when a macro call is expanded,