From 086676782a6053158cc6da14bc65961205c4b014 Mon Sep 17 00:00:00 2001 From: cooldome Date: Wed, 21 Nov 2018 20:30:03 +0000 Subject: Add isInstanceOf for generic procs to the macros module (#9730) --- lib/core/macros.nim | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/core') diff --git a/lib/core/macros.nim b/lib/core/macros.nim index d74d86bf6..f45ca3f82 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -274,6 +274,12 @@ when defined(nimHasSymOwnerInMacro): ## result is also mnde of kind nnkSym if owner exists otherwise ## nnkNilLit is returned +when defined(nimHasInstantiationOfInMacro): + proc isInstantiationOf*(instanceProcSym, genProcSym: NimNode): bool {.magic: "SymIsInstantiationOf", noSideEffect.} + ## check if proc symbol is instance of the generic proc symbol + ## useful to check proc symbols against generic symbols + ## returned by `bindSym` + 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 -- cgit 1.4.1-2-gfad0