few more fixes for static params in macros; new failing test cases for static evaluation

This commit is contained in:
Zahary Karadjov 2014-03-09 16:04:58 +02:00
commit 5aa486cf11
2 changed files with 58 additions and 15 deletions

View file

@ -602,15 +602,24 @@ proc semObjectNode(c: PContext, n: PNode, prev: PType): PType =
incl(result.flags, tfFinal)
proc addParamOrResult(c: PContext, param: PSym, kind: TSymKind) =
if kind == skMacro and param.typ.kind notin {tyTypeDesc, tyStatic}:
# within a macro, every param has the type PNimrodNode!
# and param.typ.kind in {tyTypeDesc, tyExpr, tyStmt}:
let nn = getSysSym"PNimrodNode"
var a = copySym(param)
a.typ = nn.typ
if sfGenSym notin a.flags: addDecl(c, a)
template addDecl(x) =
if sfGenSym notin x.flags: addDecl(c, x)
if kind == skMacro:
if param.typ.kind == tyTypeDesc:
addDecl(param)
elif param.typ.kind == tyStatic:
var a = copySym(param)
a.typ = param.typ.base
addDecl(a)
else:
# within a macro, every param has the type PNimrodNode!
let nn = getSysSym"PNimrodNode"
var a = copySym(param)
a.typ = nn.typ
addDecl(a)
else:
if sfGenSym notin param.flags: addDecl(c, param)
addDecl(param)
let typedescId = getIdent"typedesc"