diff dmd/StaticDtorDeclaration.d @ 179:cd48cb899aee

Updated to dmd2.040
author korDen
date Sun, 17 Oct 2010 20:56:07 +0400
parents e3afd1303184
children b0d41ff5e0df
line wrap: on
line diff
--- a/dmd/StaticDtorDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
+++ b/dmd/StaticDtorDeclaration.d	Sun Oct 17 20:56:07 2010 +0400
@@ -34,10 +34,11 @@
 {
 	VarDeclaration vgate;	// 'gate' variable
 
-	this(Loc loc, Loc endloc)
+    this(Loc loc, Loc endloc, string name = "_staticDtor")
 	{
 		register();
-		super(loc, endloc, Identifier.generateId("_staticDtor"), STCstatic, null);
+		super(loc, endloc, Identifier.generateId(name), STCstatic, null);
+	    vgate = null;
 	}
 	
 	override Dsymbol syntaxCopy(Dsymbol s)
@@ -49,20 +50,15 @@
 	
 	override void semantic(Scope sc)
 	{
-		ClassDeclaration cd;
-		Type tret;
-
-		cd = sc.scopesym.isClassDeclaration();
-		if (!cd)
-		{
-		}
-		type = new TypeFunction(null, Type.tvoid, false, LINK.LINKd);
+	    ClassDeclaration cd = sc.scopesym.isClassDeclaration();
+		if (!type)
+			type = new TypeFunction(null, Type.tvoid, false, LINK.LINKd);
 
 		/* If the static ctor appears within a template instantiation,
 		 * it could get called multiple times by the module constructors
 		 * for different modules. Thus, protect it with a gate.
 		 */
-		if (inTemplateInstance())
+	    if (inTemplateInstance() && semanticRun < PASSsemantic)
 		{
 			/* Add this prefix to the function:
 			 *	static int gate;
@@ -73,7 +69,7 @@
 			 */
 			Identifier id = Lexer.idPool("__gate");
 			VarDeclaration v = new VarDeclaration(Loc(0), Type.tint32, id, null);
-			v.storage_class = STCstatic;
+			v.storage_class = isSharedStaticDtorDeclaration() ? STCstatic : STCtls;
 			auto sa = new Statements();
 			Statement s = new DeclarationStatement(Loc(0), v);
 			sa.push(s);
@@ -109,11 +105,6 @@
 		return null;
 	}
 	
-	override bool isStaticDestructor()
-	{
-		return true;
-	}
-	
 	override bool isVirtual()
 	{
 		return false;