Added `global` pragma that can be used to introduce new global variables from within procs

This commit is contained in:
Zahary Karadjov 2012-04-05 19:20:52 +03:00
commit 6d80583d5a
6 changed files with 22 additions and 10 deletions

View file

@ -409,8 +409,10 @@ proc isAssignable(c: PContext, n: PNode): TAssignableResult =
of nkSym:
# don't list 'skLet' here:
if n.sym.kind in {skVar, skResult, skTemp}:
if c.p.owner.id == n.sym.owner.id: result = arLocalLValue
else: result = arLValue
if c.p.owner.id == n.sym.owner.id and sfGlobal notin n.sym.flags:
result = arLocalLValue
else:
result = arLValue
of nkDotExpr:
if skipTypes(n.sons[0].typ, abstractInst).kind in {tyVar, tyPtr, tyRef}:
result = arLValue