handle arbitrary expressions dependent on static input params in proc signatures

This commit is contained in:
Zahary Karadjov
2014-03-16 17:12:30 +02:00
parent da5d88f04e
commit f0953db3ba
10 changed files with 60 additions and 18 deletions

View File

@@ -612,7 +612,19 @@ proc evalAtCompileTime(c: PContext, n: PNode): PNode =
if result.isNil: result = n
else: return result
result.typ = semfold.getIntervalType(callee.magic, call)
block maybeLabelAsStatic:
# XXX: temporary work-around needed for tlateboundstatic.
# This is certainly not correct, but it will get the job
# done until we have a more robust infrastructure for
# implicit statics.
if n.len > 1:
for i in 1 .. <n.len:
if n[i].typ.kind != tyStatic or tfUnresolved notin n[i].typ.flags:
break maybeLabelAsStatic
n.typ = newTypeWithSons(c, tyStatic, @[n.typ])
n.typ.flags.incl tfUnresolved
# optimization pass: not necessary for correctness of the semantic pass
if {sfNoSideEffect, sfCompileTime} * callee.flags != {} and
{sfForward, sfImportc} * callee.flags == {}: