pass typedesc as NimNode to macros (#11400)
* change typedesc's design in macros * Manual and changelog entry. * add link to RFC
This commit is contained in:
parent
71388caf2e
commit
cb45527e37
6 changed files with 54 additions and 39 deletions
|
|
@ -1554,11 +1554,7 @@ proc activate(c: PContext, n: PNode) =
|
|||
|
||||
proc maybeAddResult(c: PContext, s: PSym, n: PNode) =
|
||||
if s.kind == skMacro:
|
||||
let resultType =
|
||||
if s.typ.sons[0] != nil and s.typ.sons[0].kind == tyTypeDesc:
|
||||
s.typ.sons[0]
|
||||
else:
|
||||
sysTypeFromName(c.graph, n.info, "NimNode")
|
||||
let resultType = sysTypeFromName(c.graph, n.info, "NimNode")
|
||||
addResult(c, resultType, n.info, s.kind)
|
||||
addResultNode(c, n)
|
||||
elif s.typ.sons[0] != nil and not isInlineIterator(s):
|
||||
|
|
|
|||
|
|
@ -869,8 +869,8 @@ proc addParamOrResult(c: PContext, param: PSym, kind: TSymKind) =
|
|||
var a = copySym(param)
|
||||
a.typ = staticType.base
|
||||
addDecl(c, a)
|
||||
elif param.typ != nil and param.typ.kind == tyTypeDesc:
|
||||
addDecl(c, param)
|
||||
#elif param.typ != nil and param.typ.kind == tyTypeDesc:
|
||||
# addDecl(c, param)
|
||||
else:
|
||||
# within a macro, every param has the type NimNode!
|
||||
let nn = getSysSym(c.graph, param.info, "NimNode")
|
||||
|
|
|
|||
|
|
@ -2028,8 +2028,8 @@ proc setupMacroParam(x: PNode, typ: PType): TFullReg =
|
|||
case typ.kind
|
||||
of tyStatic:
|
||||
putIntoReg(result, x)
|
||||
of tyTypeDesc:
|
||||
putIntoReg(result, x)
|
||||
#of tyTypeDesc:
|
||||
# putIntoReg(result, x)
|
||||
else:
|
||||
result.kind = rkNode
|
||||
var n = x
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue