diff dmd/StructInitializer.d @ 128:e6e542f37b94

Some more Array -> Vector conversions
author Eldar Insafutdinov <e.insafutdinov@gmail.com>
date Sat, 04 Sep 2010 01:33:05 +0100
parents 9ee9b55452cb
children 60bb0fe4563e
line wrap: on
line diff
--- a/dmd/StructInitializer.d	Fri Sep 03 23:55:51 2010 +0100
+++ b/dmd/StructInitializer.d	Sat Sep 04 01:33:05 2010 +0100
@@ -36,7 +36,7 @@
     Identifiers field;	// of Identifier *'s
     Initializers value;	// parallel array of Initializer *'s
 
-    Array vars;		// parallel array of VarDeclaration *'s
+    VarDeclarations vars;		// parallel array of VarDeclaration *'s
     AggregateDeclaration ad;	// which aggregate this is for
 
     this(Loc loc)
@@ -47,7 +47,7 @@
 		field = new Identifiers();
 		value = new Initializers();
 		
-		vars = new Array();
+		vars = new VarDeclarations();
 	}
 	
     override Initializer syntaxCopy()
@@ -138,7 +138,7 @@
 				{
 					val = val.semantic(sc, v.type);
 					value[i] = val;
-					vars.data[i] = cast(void*)v;
+					vars[i] = v;
 				}
 				else
 				{
@@ -152,7 +152,7 @@
 		{	
 			/* Rewrite as empty delegate literal { }
 			 */
-			Arguments arguments = new Arguments;
+			auto arguments = new Arguments;
 			Type tf = new TypeFunction(arguments, null, 0, LINK.LINKd);
 			FuncLiteralDeclaration fd = new FuncLiteralDeclaration(loc, Loc(0), tf, TOK.TOKdelegate, null);
 			fd.fbody = new CompoundStatement(loc, new Statements());
@@ -222,7 +222,7 @@
 
     override dt_t* toDt()
 	{
-		scope Array dts = new Array();
+		scope dts = new Vector!(dt_t*);
 		uint i;
 		uint j;
 		dt_t* dt;
@@ -236,7 +236,7 @@
 
 		for (i = 0; i < vars.dim; i++)
 		{
-			VarDeclaration v = cast(VarDeclaration)vars.data[i];
+			VarDeclaration v = vars[i];
 			Initializer val = value[i];
 
 			//printf("vars[%d] = %s\n", i, v.toChars());
@@ -247,9 +247,9 @@
 				//printf(" adfield[%d] = %s\n", j, ((VarDeclaration *)ad.fields[j]).toChars());
 				if (cast(VarDeclaration)ad.fields[j] == v) // TODO: check if 'is' needs to be used here
 				{
-					if (dts.data[j])
+					if (dts[j])
 						error(loc, "field %s of %s already initialized", v.toChars(), ad.toChars());
-					dts.data[j] = cast(void*)val.toDt();
+					dts[j] = val.toDt();
 					break;
 				}
 			}
@@ -260,9 +260,9 @@
 		offset = 0;
 		for (j = 0; j < dts.dim; j++)
 		{
-			VarDeclaration v = cast(VarDeclaration)ad.fields[j];
+			VarDeclaration v = ad.fields[j];
 
-			d = cast(dt_t*)dts.data[j];
+			d = dts[j];
 			if (!d)
 			{   
 				// An instance specific initializer was not provided.
@@ -285,9 +285,9 @@
 							v.type.toDt(&d);
 							break;
 						}
-						VarDeclaration v2 = cast(VarDeclaration)ad.fields[k];
+						VarDeclaration v2 = ad.fields[k];
 
-						if (v2.offset < offset2 && dts.data[k])
+						if (v2.offset < offset2 && dts[k])
 							break;			// overlap
 					}
 				}