diff dmd/backend/glue.d @ 176:fa9a71a9f5a8

Moved all the mutable globals to Global
author korDen
date Sun, 10 Oct 2010 05:22:45 +0400
parents 94b6033c07f3
children 1475fd394c9e
line wrap: on
line diff
--- a/dmd/backend/glue.d	Sun Oct 10 03:48:06 2010 +0400
+++ b/dmd/backend/glue.d	Sun Oct 10 05:22:45 2010 +0400
@@ -19,9 +19,6 @@
 
 import core.stdc.string;
 
-__gshared Array obj_symbols_towrite;
-__gshared Outbuffer objbuf;
-
 version (Windows)
 {
 	extern (C++) extern
@@ -48,8 +45,6 @@
 import std.exception;
 import std.string;
 
-__gshared string lastmname;
-
 struct Outbuffer
 {
     ubyte* buf;		// the buffer itself
@@ -275,18 +270,13 @@
 	}
 }
 
-static this()
-{
-	obj_symbols_towrite = new Array();
-}
-
 /**************************************
  * Append s to list of object files to generate later.
  */
  
 void obj_append(Dsymbol s)
 {
-    obj_symbols_towrite.push(cast(void*)s);
+    global.obj_symbols_towrite.push(cast(void*)s);
 }
 
 version (Bug4059)
@@ -315,8 +305,8 @@
 void clearStringTab()
 {
     //printf("clearStringTab()\n");
-    memset(stringTab.ptr, 0, stringTab.sizeof);
-    stidx = 0;
+    memset(global.stringTab.ptr, 0, global.stringTab.sizeof);
+    global.stidx = 0;
 
 //    assertexp_sfilename = null;
 //    assertexp_name = null;
@@ -333,7 +323,7 @@
     slist_reset();
     clearStringTab();
 
-    obj_init(&objbuf, srcfile, null);
+    obj_init(&global.objbuf, srcfile, null);
 
     el_reset();
     cg87_reset();
@@ -343,6 +333,8 @@
 void obj_end(Library library, File objfile)
 {
 	obj_term();
+	
+	auto objbuf = &global.objbuf;
 
     if (library)
     {
@@ -370,10 +362,9 @@
     objbuf.inc = 0;
 }
 
-static __gshared int count;
-
 void obj_write_deferred(Library library)
 {
+	auto obj_symbols_towrite = global.obj_symbols_towrite;
 	for (int i = 0; i < obj_symbols_towrite.dim; i++)
     {	
 		Dsymbol s = cast(Dsymbol)obj_symbols_towrite.data[i];
@@ -383,18 +374,18 @@
 		if (m)
 		{   
 			mname = m.srcfile.toChars();
-			lastmname = mname;
+			global.lastmname = mname;
 		}
 		else
 		{
 			//mname = s->ident->toChars();
-			mname = lastmname;
+			mname = global.lastmname;
 			assert(mname.length != 0);
 		}
 
 		obj_start(cast(char*)toStringz(mname));
 
-		count++;		// sequence for generating names
+		int count = ++global.count;		// sequence for generating names
 
 		/* Create a module that's a doppelganger of m, with just
 		 * enough to be able to create the moduleinfo.