I have this snippet
import macros
template texture(a, b): untyped =
var a: TexturePtr
init:
state.a = loadTexture(b)
finish:
state.a.free()
static:
let node = getAst(texture(background, "res/menu.png")) # undeclared identifier: background
let node = getAst(quote do: texture(background, "res/menu.png")) # undeclared identifier: TexturePtr
I want an option that doesn't error and returns this AST:
var background: TexturePtr
init:
state.background = loadTexture("res/menu.png")
finish:
state.background.free()
Basically gives the result of a single template expanded, not expanded all the way to the point of type checking. Does Nim have a hook for this?
import macros
template texture(a, b): untyped =
var a: TexturePtr
init:
state.a = loadTexture(b)
finish:
state.a.free()
macro mcr(body) =
result = newEmptyNode()
let node = getAst(`body[0]`) # do what here?
echo body.treeRepr
mcr:
texture background, "res/menu.png"