summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-09-18 02:58:18 +0200
committerAraq <rumpf_a@web.de>2013-09-18 02:58:18 +0200
commitf1e789bfc20a807365fc59f1a5f0c6fb96803ac7 (patch)
treef1bcfa3dd22a2c6c5fdd49fb64e1cc9269e45da2 /compiler
parent51672aef724ee7c0cac260a8172ae70b3ccd9494 (diff)
downloadNim-f1e789bfc20a807365fc59f1a5f0c6fb96803ac7.tar.gz
fixes #576
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ast.nim3
-rw-r--r--compiler/ccgstmts.nim5
-rw-r--r--compiler/pragmas.nim1
3 files changed, 6 insertions, 3 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim
index 6e0cafd74..ea60284da 100644
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -231,7 +231,8 @@ type
     sfVolatile,       # variable is volatile
     sfRegister,       # variable should be placed in a register
     sfPure,           # object is "pure" that means it has no type-information
-    
+                      # enum is "pure", its values need qualified access
+                      # variable is "pure"; it's an explicit "global"
     sfNoSideEffect,   # proc has no side effects
     sfSideEffect,     # proc may have side effects; cannot prove it has none
     sfMainModule,     # module is the main module
diff --git a/compiler/ccgstmts.nim b/compiler/ccgstmts.nim
index 8115abc2f..3c8c6d9a3 100644
--- a/compiler/ccgstmts.nim
+++ b/compiler/ccgstmts.nim
@@ -151,8 +151,9 @@ proc genSingleVar(p: BProc, a: PNode) =
   var targetProc = p
   var immediateAsgn = a.sons[2].kind != nkEmpty
   if sfGlobal in v.flags:
-    if v.owner.kind != skModule:
-      targetProc = p.module.postInitProc
+    if sfPure in v.flags:
+      # v.owner.kind != skModule:
+      targetProc = p.module.preInitProc
     assignGlobalVar(targetProc, v)
     # XXX: be careful here.
     # Global variables should not be zeromem-ed within loops 
diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim
index aeffcdc4c..8c2425de3 100644
--- a/compiler/pragmas.nim
+++ b/compiler/pragmas.nim
@@ -569,6 +569,7 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: int,
         of wGlobal:
           noVal(it)
           incl(sym.flags, sfGlobal)
+          incl(sym.flags, sfPure)
         of wMerge: 
           noval(it)
           incl(sym.flags, sfMerge)