I'm trying to write a helper macro that takes in an untyped argument and
converts it directly into the appropriate NimNode. what I've ended up doing is
var nimNodes{.compiletime.} = seq[NimNode]
var nimNodeIndex{.compiletime.} = 0
macro toNimNode(x: untyped):int =
nimNodes.add(x)
result = newLit(nimNodeIndex)
inc nimNodeIndex
Run
and then using the returned index as a fake pointer. This is the kludgiest of
kludges; is there a cleaner way that I'm not seeing?
Motivating example: building a compiletime Table[string,NimNode] or
Table[NimTypeKind,NimNode] for another macro to use.