diff options
author | cooldome <cdome@bk.ru> | 2018-09-03 12:25:59 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-09-03 13:25:59 +0200 |
commit | e63c66b8104225cefe0413471410ef4c072f9954 (patch) | |
tree | cd2aaf32d9fda170074c247b5a310650020ef8f9 /lib | |
parent | 1abef2dc59e812f7aee41620bf5cd298f5cc8270 (diff) | |
download | Nim-e63c66b8104225cefe0413471410ef4c072f9954.tar.gz |
Add sym owner to macros (#8253)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/core/macros.nim | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 5b29d5e94..4d76d60c2 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -237,6 +237,12 @@ else: # bootstrapping substitute else: n.strValOld +when defined(nimHasSymOwnerInMacro): + proc owner*(sym: NimNode): NimNode {.magic: "SymOwner", noSideEffect.} + ## accepts node of kind nnkSym and returns its owner's symbol. + ## result is also mnde of kind nnkSym if owner exists otherwise + ## nnkNilLit is returned + proc getType*(n: NimNode): NimNode {.magic: "NGetType", noSideEffect.} ## with 'getType' you can access the node's `type`:idx:. A Nim type is ## mapped to a Nim AST too, so it's slightly confusing but it means the same |