further steps for closure support

This commit is contained in:
Araq 2012-02-08 09:10:59 +01:00
commit 2c4a1dbc0c
7 changed files with 101 additions and 57 deletions

View file

@ -92,7 +92,8 @@ proc semSym(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode =
# if a proc accesses a global variable, it is not side effect free:
if sfGlobal in s.flags:
incl(c.p.owner.flags, sfSideEffect)
elif s.owner != c.p.owner and s.owner.kind != skModule:
elif s.owner != c.p.owner and s.owner.kind != skModule and
c.p.owner.typ != nil and not IsGenericRoutine(s.owner):
c.p.owner.typ.callConv = ccClosure
if illegalCapture(s) or c.p.next.owner != s.owner:
# Currently captures are restricted to a single level of nesting: