diff dmd/StructDeclaration.d @ 135:af1bebfd96a4 dmd2037

dmd 2.038
author Eldar Insafutdinov <e.insafutdinov@gmail.com>
date Mon, 13 Sep 2010 22:19:42 +0100
parents 206db751bd4c
children 90821c10b6a7
line wrap: on
line diff
--- a/dmd/StructDeclaration.d	Sat Sep 11 13:03:39 2010 +0100
+++ b/dmd/StructDeclaration.d	Mon Sep 13 22:19:42 2010 +0100
@@ -207,7 +207,22 @@
 		sc2.protection = PROT.PROTpublic;
 		sc2.explicitProtection = 0;
 
-		int members_dim = members.dim;
+
+        /* Set scope so if there are forward references, we still might be able to
+         * resolve individual members like enums.
+         */
+        foreach (s; members)
+        {
+	        /* There are problems doing this in the general case because
+	         * Scope keeps track of things like 'offset'
+	         */
+	        if (s.isEnumDeclaration() || (s.isAggregateDeclaration() && s.ident))
+	        {
+	            //printf("setScope %s %s\n", s->kind(), s->toChars());
+	            s.setScope(sc2);
+	        }
+        }
+
 		foreach(Dsymbol s; members)
 		{
 			s.semantic(sc2);
@@ -412,6 +427,22 @@
 		}
 	}
 	
+    Dsymbol search(Loc loc, Identifier ident, int flags)
+    {
+        //printf("%s.StructDeclaration::search('%s')\n", toChars(), ident->toChars());
+
+        if (scope_)
+    	    semantic(scope_);
+
+        if (!members || !symtab)
+        {
+    	    error("is forward referenced when looking for '%s'", ident.toChars());
+	        return null;
+        }
+
+        return ScopeDsymbol.search(loc, ident, flags);
+    }
+
     override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
 	{
 		assert(false);