diff dmd/ClassDeclaration.d @ 77:ad4792a1cfd6

more D-ification container accessing
author Eldar Insafutdinov <e.insafutdinov@gmail.com>
date Sun, 29 Aug 2010 14:36:55 +0100
parents 7e0d548de9e6
children 43073c7c7769
line wrap: on
line diff
--- a/dmd/ClassDeclaration.d	Sun Aug 29 09:43:40 2010 +0100
+++ b/dmd/ClassDeclaration.d	Sun Aug 29 14:36:55 2010 +0100
@@ -581,11 +581,8 @@
 		{
 		interfaceSemantic(sc);
 
-		for (i = 0; i < members.dim; i++)
-		{
-			Dsymbol s = cast(Dsymbol)members.data[i];
+		foreach(Dsymbol s; members)
 			s.addMember(sc, this, true);
-		}
 
 		/* If this is a nested class, add the hidden 'this'
 		 * member which is a pointer to the enclosing scope.
@@ -695,11 +692,8 @@
 		Scope scsave = sc;	/// a copy must be created?
 		int members_dim = members.dim;
 		sizeok = 0;
-		for (i = 0; i < members_dim; i++)
-		{
-			Dsymbol s = cast(Dsymbol)members.data[i];
+		foreach(Dsymbol s; members)
 			s.semantic(sc);
-		}
 
 		if (sizeok == 2)
 		{	// semantic() failed because of forward references.
@@ -833,10 +827,8 @@
 			buf.writenl();
 			buf.writeByte('{');
 			buf.writenl();
-			for (int i = 0; i < members.dim; i++)
+			foreach(Dsymbol s; members)
 			{
-				Dsymbol s = cast(Dsymbol)members.data[i];
-
 				buf.writestring("    ");
 				s.toCBuffer(buf, hgs);
 			}
@@ -955,9 +947,8 @@
 		OverloadSet os = s.isOverloadSet();	
 		if (os)
 		{
-			for (int i = 0; i < os.a.dim; i++)
+			foreach(Dsymbol s2; os.a)
 			{   
-				Dsymbol s2 = cast(Dsymbol)os.a.data[i];
 				FuncDeclaration f2 = s2.isFuncDeclaration();
 				if (f2 && overloadApply(f2, &p.isf, &p))
 					return false;
@@ -1212,13 +1203,8 @@
 			scclass = SCcomdat;
 
 		// Put out the members
-		for (i = 0; i < members.dim; i++)
-		{
-			Dsymbol member;
-
-			member = cast(Dsymbol)members.data[i];
+		foreach(Dsymbol member; members)
 			member.toObjFile(0);
-		}
 
 static if (false) {
 		// Build destructor by aggregating dtors[]
@@ -1405,9 +1391,8 @@
 		{
 			if (cd.members)
 			{
-				for (size_t j = 0; j < cd.members.dim; j++)
+				foreach(Dsymbol sm; cd.members)
 				{
-					Dsymbol sm = cast(Dsymbol)cd.members.data[j];
 					//printf("sm = %s %s\n", sm.kind(), sm.toChars());
 					if (sm.hasPointers())
 						goto L2;