changeset 122:c77e9f4f1793

Statements -> Vector
author Eldar Insafutdinov <e.insafutdinov@gmail.com>
date Thu, 02 Sep 2010 23:37:49 +0100
parents 347de076ad34
children 9e39c7de8438
files dmd/ArrayTypes.d dmd/CaseRangeStatement.d dmd/CompileStatement.d dmd/CompoundDeclarationStatement.d dmd/CompoundStatement.d dmd/ConditionalStatement.d dmd/ForeachRangeStatement.d dmd/ForeachStatement.d dmd/FuncDeclaration.d dmd/GotoStatement.d dmd/LabelStatement.d dmd/Parser.d dmd/StaticCtorDeclaration.d dmd/StaticDtorDeclaration.d dmd/SwitchStatement.d dmd/SynchronizedStatement.d dmd/UnrolledLoopStatement.d dmd/VolatileStatement.d
diffstat 18 files changed, 94 insertions(+), 112 deletions(-) [+]
line wrap: on
line diff
--- a/dmd/ArrayTypes.d	Thu Sep 02 22:41:12 2010 +0100
+++ b/dmd/ArrayTypes.d	Thu Sep 02 23:37:49 2010 +0100
@@ -3,11 +3,11 @@
 import dmd.common;
 import dmd.Array;
 import dmd.TemplateParameter;
+import dmd.Statement;
 
 alias Vector!Object Objects;
 alias Vector!TemplateParameter TemplateParameters;
-
-class Statements : Array { final typeof(this) copy() { auto a = new typeof(this); copyTo(a); return a; } }
+alias Vector!Statement Statements;
 
 class BaseClasses : Array { final typeof(this) copy() { auto a = new typeof(this); copyTo(a); return a; } }
 
--- a/dmd/CaseRangeStatement.d	Thu Sep 02 22:41:12 2010 +0100
+++ b/dmd/CaseRangeStatement.d	Thu Sep 02 23:37:49 2010 +0100
@@ -77,7 +77,7 @@
 				s = new ExpStatement(loc, null);
 			Expression e = new IntegerExp(loc, i, first.type);
 			Statement cs = new CaseStatement(loc, e, s);
-			statements.push(cast(void*)cs);
+			statements.push(cs);
 		}
 		Statement s = new CompoundStatement(loc, statements);
 		s = s.semantic(sc);
--- a/dmd/CompileStatement.d	Thu Sep 02 22:41:12 2010 +0100
+++ b/dmd/CompileStatement.d	Thu Sep 02 23:37:49 2010 +0100
@@ -61,7 +61,7 @@
 		while (p.token.value != TOK.TOKeof)
 		{
 			Statement s = p.parseStatement(ParseStatementFlags.PSsemi | ParseStatementFlags.PScurlyscope);
-			a.push(cast(void*)s);
+			a.push(s);
 		}
 		return a;
 	}
--- a/dmd/CompoundDeclarationStatement.d	Thu Sep 02 22:41:12 2010 +0100
+++ b/dmd/CompoundDeclarationStatement.d	Thu Sep 02 23:37:49 2010 +0100
@@ -22,10 +22,10 @@
 		a.setDim(statements.dim);
 		for (size_t i = 0; i < statements.dim; i++)
 		{	
-			Statement s = cast(Statement)statements.data[i];
+			Statement s = statements[i];
 			if (s)
 				s = s.syntaxCopy();
-			a.data[i] = cast(void*)s;
+			a[i] = s;
 		}
 		CompoundDeclarationStatement cs = new CompoundDeclarationStatement(loc, a);
 		return cs;
--- a/dmd/CompoundStatement.d	Thu Sep 02 22:41:12 2010 +0100
+++ b/dmd/CompoundStatement.d	Thu Sep 02 23:37:49 2010 +0100
@@ -43,8 +43,8 @@
 		
 		statements = new Statements();
 		statements.reserve(2);
-		statements.push(cast(void*)s1);
-		statements.push(cast(void*)s2);
+		statements.push(s1);
+		statements.push(s2);
 	}
 	
     override Statement syntaxCopy()
@@ -52,12 +52,11 @@
 		Statements a = new Statements();
 		a.setDim(statements.dim);
 
-		for (size_t i = 0; i < statements.dim; i++)
+		foreach (size_t i, Statement s; statements)
 		{	
-			Statement s = cast(Statement)statements.data[i];
 			if (s)
 				s = s.syntaxCopy();
-			a.data[i] = cast(void*)s;
+			a[i] = s;
 		}
 
 		return new CompoundStatement(loc, a);
@@ -65,8 +64,8 @@
 	
 	override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
 	{
-		for (int i = 0; i < statements.dim; i++)
-		{   Statement s = cast(Statement) statements.data[i];
+		foreach (s; statements)
+		{
 			if (s)
 				s.toCBuffer(buf, hgs);
 		}
@@ -83,7 +82,7 @@
 
 		for (size_t i = 0; i < statements.dim; )
 		{
-			s = cast(Statement) statements.data[i];
+			s = statements[i];
 			if (s)
 			{   
 				Statements a = s.flatten(sc);
@@ -97,7 +96,7 @@
 				
 				s = s.semantic(sc);
 
-				statements.data[i] = cast(void*)s;
+				statements[i] = s;
 				if (s)
 				{
 					Statement sentry;
@@ -110,11 +109,11 @@
 						sentry = sentry.semantic(sc);
 						if (s.isDeclarationStatement())
 						{	
-							statements.insert(i, cast(void*)sentry);
+							statements.insert(i, sentry);
 							i++;
 						}
 						else
-							statements.data[i] = cast(void*)sentry;
+							statements[i] = sentry;
 					}
 					if (sexception)
 					{
@@ -144,7 +143,7 @@
 
 							for (int j = i + 1; j < statements.dim; j++)
 							{
-								aa.push(statements.data[j]);
+								aa.push(statements[j]);
 							}
 							body_ = new CompoundStatement(Loc(0), aa);
 							body_ = new ScopeStatement(Loc(0), body_);
@@ -163,7 +162,7 @@
 								s = new TryFinallyStatement(Loc(0), s, sfinally);
 							s = s.semantic(sc);
 							statements.setDim(i + 1);
-							statements.push(cast(void*)s);
+							statements.push(s);
 							break;
 						}
 					}
@@ -171,7 +170,7 @@
 					{
 						if (0 && i + 1 == statements.dim)
 						{
-							statements.push(cast(void*)sfinally);
+							statements.push(sfinally);
 						}
 						else
 						{
@@ -185,13 +184,13 @@
 
 							for (int j = i + 1; j < statements.dim; j++)
 							{
-								aa.push(statements.data[j]);
+								aa.push(statements[j]);
 							}
 							body_ = new CompoundStatement(Loc(0), aa);
 							s = new TryFinallyStatement(Loc(0), body_, sfinally);
 							s = s.semantic(sc);
 							statements.setDim(i + 1);
-							statements.push(cast(void*)s);
+							statements.push(s);
 							break;
 						}
 					}
@@ -201,7 +200,7 @@
 		}
 		if (statements.dim == 1)
 		{
-			return cast(Statement)statements.data[0];
+			return statements[0];
 		}
 		return this;
 	}
@@ -215,8 +214,8 @@
 	{
 		//printf("CompoundStatement::blockExit(%p) %d\n", this, statements->dim);
 		BE result = BE.BEfallthru;
-		for (size_t i = 0; i < statements.dim; i++)
-		{	Statement s = cast(Statement)statements.data[i];
+		foreach (s; statements)
+		{
 			if (s)
 			{
 				//printf("result = x%x\n", result);
@@ -244,9 +243,8 @@
 	
     override bool isEmpty()
 	{
-		for (int i = 0; i < statements.dim; i++)
+		foreach (s; statements)
 		{	
-			Statement s = cast(Statement) statements.data[i];
 			if (s && !s.isEmpty())
 				return false;
 		}
@@ -262,9 +260,8 @@
 	{
 		ReturnStatement rs = null;
 
-		for (int i = 0; i < statements.dim; i++)
+		foreach(s; statements)
 		{	
-			Statement s = cast(Statement) statements.data[i];
 			if (s)
 			{
 				rs = s.isReturnStatement();
@@ -286,10 +283,8 @@
 			istate.start = null;
 		if (statements)
 		{
-			for (size_t i = 0; i < statements.dim; i++)
+			foreach(s; statements)
 			{   
-				Statement s = cast(Statement)statements.data[i];
-
 				if (s)
 				{
 					e = s.interpret(istate);
@@ -308,9 +303,8 @@
 	{
 		int cost = 0;
 
-		for (size_t i = 0; i < statements.dim; i++)
+		foreach(s; statements)
 		{	
-			Statement s = cast(Statement)statements.data[i];
 			if (s)
 			{
 				cost += s.inlineCost(ics);
@@ -327,9 +321,8 @@
 		Expression e = null;
 
 		//printf("CompoundStatement.doInline() %d\n", statements.dim);
-		for (size_t i = 0; i < statements.dim; i++)
+		foreach(s; statements)
 		{	
-			Statement s = cast(Statement)statements.data[i];
 			if (s)
 			{
 				Expression e2 = s.doInline(ids);
@@ -356,11 +349,10 @@
 	
     override Statement inlineScan(InlineScanState* iss)
 	{
-		for (size_t i = 0; i < statements.dim; i++)
+		foreach(ref Statement s; statements)
 		{	
-			Statement s = cast(Statement) statements.data[i];
 			if (s)
-				statements.data[i] = cast(void*)s.inlineScan(iss);
+				s = s.inlineScan(iss);
 		}
 
 		return this;
@@ -370,10 +362,8 @@
 	{
 		if (statements)
 		{
-			size_t dim = statements.dim;
-			for (size_t i = 0 ; i < dim ; i++)
+			foreach(s; statements)
 			{
-				Statement s = cast(Statement)statements.data[i];
 				if (s !is null)
 				{
 					s.toIR(irs);
--- a/dmd/ConditionalStatement.d	Thu Sep 02 22:41:12 2010 +0100
+++ b/dmd/ConditionalStatement.d	Thu Sep 02 23:37:49 2010 +0100
@@ -62,8 +62,8 @@
 		else
 			s = elsebody;
 
-		Statements a = new Statements();
-		a.push(cast(void*)s);
+		auto a = new Statements();
+		a.push(s);
 
 		return a;
 	}
--- a/dmd/ForeachRangeStatement.d	Thu Sep 02 22:41:12 2010 +0100
+++ b/dmd/ForeachRangeStatement.d	Thu Sep 02 23:37:49 2010 +0100
@@ -121,17 +121,17 @@
 		ie = new ExpInitializer(loc, (op == TOKforeach) ? upr : lwr);
 		VarDeclaration tmp = new VarDeclaration(loc, arg.type, id, ie);
 
-		Statements cs = new Statements();
+		auto cs = new Statements();
 		// Keep order of evaluation as lwr, then upr
 		if (op == TOKforeach)
 		{
-			cs.push(cast(void*)new DeclarationStatement(loc, new DeclarationExp(loc, key)));
-			cs.push(cast(void*)new DeclarationStatement(loc, new DeclarationExp(loc, tmp)));
+			cs.push(new DeclarationStatement(loc, new DeclarationExp(loc, key)));
+			cs.push(new DeclarationStatement(loc, new DeclarationExp(loc, tmp)));
 		}
 		else
 		{
-			cs.push(cast(void*)new DeclarationStatement(loc, new DeclarationExp(loc, tmp)));
-			cs.push(cast(void*)new DeclarationStatement(loc, new DeclarationExp(loc, key)));
+			cs.push(new DeclarationStatement(loc, new DeclarationExp(loc, tmp)));
+			cs.push(new DeclarationStatement(loc, new DeclarationExp(loc, key)));
 		}
 		Statement forinit = new CompoundDeclarationStatement(loc, cs);
 
--- a/dmd/ForeachStatement.d	Thu Sep 02 22:41:12 2010 +0100
+++ b/dmd/ForeachStatement.d	Thu Sep 02 23:37:49 2010 +0100
@@ -203,7 +203,7 @@
 					VarDeclaration var = new VarDeclaration(loc, arg.type, arg.ident, ie);
 					var.storage_class |= STC.STCmanifest;
 					DeclarationExp de = new DeclarationExp(loc, var);
-					st.push(cast(void*)new ExpStatement(loc, de));
+					st.push(new ExpStatement(loc, de));
 					arg = cast(Argument)arguments.data[1];	// value
 				}
 				// Declare value
@@ -234,13 +234,13 @@
 					var = new AliasDeclaration(loc, arg.ident, t);
 				}
 
-				DeclarationExp de = new DeclarationExp(loc, var);
-				st.push(cast(void*)new ExpStatement(loc, de));
+				auto de = new DeclarationExp(loc, var);
+				st.push(new ExpStatement(loc, de));
 
-				st.push(cast(void*)body_.syntaxCopy());
+				st.push(body_.syntaxCopy());
 				s = new CompoundStatement(loc, st);
 				s = new ScopeStatement(loc, s);
-				statements.push(cast(void*)s);
+				statements.push(s);
 			}
 
 			s = new UnrolledLoopStatement(loc, statements);
@@ -356,9 +356,9 @@
 				else
 					key.init = new ExpInitializer(loc, new IntegerExp(0));
 
-				Statements cs = new Statements();
-				cs.push(cast(void*)new DeclarationStatement(loc, new DeclarationExp(loc, tmp)));
-				cs.push(cast(void*)new DeclarationStatement(loc, new DeclarationExp(loc, key)));
+				auto cs = new Statements();
+				cs.push(new DeclarationStatement(loc, new DeclarationExp(loc, tmp)));
+				cs.push(new DeclarationStatement(loc, new DeclarationExp(loc, key)));
 				Statement forinit = new CompoundDeclarationStatement(loc, cs);
 
 				Expression cond;
@@ -600,15 +600,15 @@
 				// Resolve any forward referenced goto's
 				for (int i = 0; i < gotos.dim; i++)
 				{	
-					CompoundStatement cs = cast(CompoundStatement)gotos.data[i];
-					GotoStatement gs = cast(GotoStatement)cs.statements.data[0];
+					auto cs = cast(CompoundStatement)gotos.data[i];
+					auto gs = cast(GotoStatement)cs.statements[0];
 
 					if (!gs.label.statement)
 					{   
 						// 'Promote' it to this scope, and replace with a return
 						cases.push(cast(void*)gs);
 						s = new ReturnStatement(Loc(0), new IntegerExp(cases.dim + 1));
-						cs.statements.data[0] = cast(void*)s;
+						cs.statements[0] = s;
 					}
 				}
 
@@ -744,19 +744,19 @@
 				else
 				{	// Construct a switch statement around the return value
 					// of the apply function.
-					Statements a2 = new Statements();
+					auto a2 = new Statements();
 
 					// default: break; takes care of cases 0 and 1
 					s = new BreakStatement(Loc(0), null);
 					s = new DefaultStatement(Loc(0), s);
-					a2.push(cast(void*)s);
+					a2.push(s);
 
 					// cases 2...
 					for (int i = 0; i < cases.dim; i++)
 					{
 						s = cast(Statement)cases.data[i];
 						s = new CaseStatement(Loc(0), new IntegerExp(i + 2), s);
-						a2.push(cast(void*)s);
+						a2.push(s);
 					}
 
 					s = new CompoundStatement(loc, a2);
--- a/dmd/FuncDeclaration.d	Thu Sep 02 22:41:12 2010 +0100
+++ b/dmd/FuncDeclaration.d	Thu Sep 02 23:37:49 2010 +0100
@@ -1431,7 +1431,7 @@
 		}
 
 		{
-			Statements a = new Statements();
+			auto a = new Statements();
 
 			// Merge in initialization of 'out' parameters
 			if (parameters)
@@ -1443,7 +1443,7 @@
 				assert(v.init);
 				ExpInitializer ie = v.init.isExpInitializer();
 				assert(ie);
-				a.push(cast(void*)new ExpStatement(Loc(0), ie.exp));
+				a.push(new ExpStatement(Loc(0), ie.exp));
 				}
 			}
 			}
@@ -1473,7 +1473,7 @@
 				Expression e = new SymOffExp(Loc(0), p, offset);
 				e = new AssignExp(Loc(0), e1, e);
 				e.type = t;
-				a.push(cast(void*)new ExpStatement(Loc(0), e));
+				a.push(new ExpStatement(Loc(0), e));
 				p.isargptr = true;
 }
 			}
@@ -1489,7 +1489,7 @@
 			e = new AssignExp(Loc(0), e1, e);
 			e.op = TOK.TOKconstruct;
 			e = e.semantic(sc2);
-			a.push(cast(void*)new ExpStatement(Loc(0), e));
+			a.push(new ExpStatement(Loc(0), e));
 			}
 
 			// Merge contracts together with body into one compound statement
@@ -1501,7 +1501,7 @@
 			}
 } else {
 			if (frequire && global.params.useIn)
-			a.push(cast(void*)frequire);
+			a.push(frequire);
 }
 
 			// Precondition invariant
@@ -1543,17 +1543,17 @@
 			}
 			if (e)
 			{
-				ExpStatement s = new ExpStatement(Loc(0), e);
-				a.push(cast(void*)s);
+				auto s = new ExpStatement(Loc(0), e);
+				a.push(s);
 			}
 			}
 
 			if (fbody)
-			a.push(cast(void*)fbody);
+			a.push(fbody);
 
 			if (fensure)
 			{
-			a.push(cast(void*)returnLabel.statement);
+			a.push(returnLabel.statement);
 
 			if (type.nextOf().ty != TY.Tvoid)
 			{
@@ -1564,8 +1564,8 @@
 				{	e = e.implicitCastTo(sc, tintro.nextOf());
 				e = e.semantic(sc);
 				}
-				ReturnStatement s = new ReturnStatement(Loc(0), e);
-				a.push(cast(void*)s);
+				auto s = new ReturnStatement(Loc(0), e);
+				a.push(s);
 			}
 			}
 
--- a/dmd/GotoStatement.d	Thu Sep 02 22:41:12 2010 +0100
+++ b/dmd/GotoStatement.d	Thu Sep 02 23:37:49 2010 +0100
@@ -56,10 +56,10 @@
 			 * so we can patch it later, and add it to a 'look at this later'
 			 * list.
 			 */
-			Statements a = new Statements();
+			auto a = new Statements();
 			Statement s;
 
-			a.push(cast(void*)this);
+			a.push(this);
 			s = new CompoundStatement(loc, a);
 			sc.fes.gotos.push(cast(void*)s);		// 'look at this later' list
 			return s;
--- a/dmd/LabelStatement.d	Thu Sep 02 22:41:12 2010 +0100
+++ b/dmd/LabelStatement.d	Thu Sep 02 23:37:49 2010 +0100
@@ -77,12 +77,12 @@
 			if (a)
 			{
 				if (!a.dim)
-					a.push(cast(void*)new ExpStatement(loc, null));
+					a.push(new ExpStatement(loc, null));
 
-				Statement s = cast(Statement)a.data[0];
+				Statement s = a[0];
 
 				s = new LabelStatement(loc, ident, s);
-				a.data[0] = cast(void*)s;
+				a[0] = s;
 			}
 		}
 
--- a/dmd/Parser.d	Thu Sep 02 22:41:12 2010 +0100
+++ b/dmd/Parser.d	Thu Sep 02 23:37:49 2010 +0100
@@ -3239,7 +3239,7 @@
 			foreach(Dsymbol d; a)
 			{
 				s = new DeclarationStatement(loc, d);
-				as.push(cast(void*)s);
+				as.push(s);
 			}
 			s = new CompoundDeclarationStatement(loc, as);
 			}
@@ -3312,7 +3312,7 @@
 			Statements statements = new Statements();
 			while (token.value != TOK.TOKrcurly && token.value != TOKeof)
 			{
-			statements.push(cast(void*)parseStatement(ParseStatementFlags.PSsemi | ParseStatementFlags.PScurlyscope));
+			statements.push(parseStatement(ParseStatementFlags.PSsemi | ParseStatementFlags.PScurlyscope));
 			}
 			endloc = this.loc;
 			s = new CompoundStatement(loc, statements);
@@ -3664,7 +3664,7 @@
 			   token.value != TOKeof &&
 			   token.value != TOK.TOKrcurly)
 			{
-			statements.push(cast(void*)parseStatement(ParseStatementFlags.PSsemi | ParseStatementFlags.PScurlyscope));
+			statements.push(parseStatement(ParseStatementFlags.PSsemi | ParseStatementFlags.PScurlyscope));
 			}
 			s = new CompoundStatement(loc, statements);
 			s = new ScopeStatement(loc, s);
@@ -3700,7 +3700,7 @@
 			   token.value != TOKeof &&
 			   token.value != TOK.TOKrcurly)
 			{
-			statements.push(cast(void*)parseStatement(ParseStatementFlags.PSsemi | ParseStatementFlags.PScurlyscope));
+			statements.push(parseStatement(ParseStatementFlags.PSsemi | ParseStatementFlags.PScurlyscope));
 			}
 			s = new CompoundStatement(loc, statements);
 			s = new ScopeStatement(loc, s);
@@ -3945,7 +3945,7 @@
 						s = new LabelStatement(labelloc, label, s);
 						label = null;
 					}
-					statements.push(cast(void*)s);
+					statements.push(s);
 				}
 				nextToken();
 				continue;
--- a/dmd/StaticCtorDeclaration.d	Thu Sep 02 22:41:12 2010 +0100
+++ b/dmd/StaticCtorDeclaration.d	Thu Sep 02 23:37:49 2010 +0100
@@ -66,14 +66,14 @@
 			v.storage_class = STCstatic;
 			Statements sa = new Statements();
 			Statement s = new DeclarationStatement(Loc(0), v);
-			sa.push(cast(void*)s);
+			sa.push(s);
 			Expression e = new IdentifierExp(Loc(0), id);
 			e = new AddAssignExp(Loc(0), e, new IntegerExp(1));
 			e = new EqualExp(TOKnotequal, Loc(0), e, new IntegerExp(1));
 			s = new IfStatement(Loc(0), null, e, new ReturnStatement(Loc(0), null), null);
-			sa.push(cast(void*)s);
+			sa.push(s);
 			if (fbody)
-				sa.push(cast(void*)fbody);
+				sa.push(fbody);
 			fbody = new CompoundStatement(Loc(0), sa);
 		}
 
--- a/dmd/StaticDtorDeclaration.d	Thu Sep 02 22:41:12 2010 +0100
+++ b/dmd/StaticDtorDeclaration.d	Thu Sep 02 23:37:49 2010 +0100
@@ -73,16 +73,16 @@
 			Identifier id = Lexer.idPool("__gate");
 			VarDeclaration v = new VarDeclaration(Loc(0), Type.tint32, id, null);
 			v.storage_class = STCstatic;
-			Statements sa = new Statements();
+			auto sa = new Statements();
 			Statement s = new DeclarationStatement(Loc(0), v);
-			sa.push(cast(void*)s);
+			sa.push(s);
 			Expression e = new IdentifierExp(Loc(0), id);
 			e = new AddAssignExp(Loc(0), e, new IntegerExp(-1));
 			e = new EqualExp(TOKnotequal, Loc(0), e, new IntegerExp(0));
 			s = new IfStatement(Loc(0), null, e, new ReturnStatement(Loc(0), null), null);
-			sa.push(cast(void*)s);
+			sa.push(s);
 			if (fbody)
-				sa.push(cast(void*)fbody);
+				sa.push(fbody);
 			fbody = new CompoundStatement(Loc(0), sa);
 			vgate = v;
 		}
--- a/dmd/SwitchStatement.d	Thu Sep 02 22:41:12 2010 +0100
+++ b/dmd/SwitchStatement.d	Thu Sep 02 23:37:49 2010 +0100
@@ -167,10 +167,10 @@
 			}
 
 			a.reserve(4);
-			a.push(cast(void*)body_);
-			a.push(cast(void*)new BreakStatement(loc, null));
+			a.push(body_);
+			a.push(new BreakStatement(loc, null));
 			sc.sw.sdefault = new DefaultStatement(loc, s);
-			a.push(cast(void*)sc.sw.sdefault);
+			a.push(sc.sw.sdefault);
 			cs = new CompoundStatement(loc, a);
 			body_ = cs;
 		}
--- a/dmd/SynchronizedStatement.d	Thu Sep 02 22:41:12 2010 +0100
+++ b/dmd/SynchronizedStatement.d	Thu Sep 02 23:37:49 2010 +0100
@@ -88,19 +88,19 @@
 			VarDeclaration tmp = new VarDeclaration(loc, exp.type, id, ie);
 
 			Statements cs = new Statements();
-			cs.push(cast(void*)new DeclarationStatement(loc, new DeclarationExp(loc, tmp)));
+			cs.push(new DeclarationStatement(loc, new DeclarationExp(loc, tmp)));
 
 			FuncDeclaration fdenter = FuncDeclaration.genCfunc(Type.tvoid, Id.monitorenter);
 			Expression e = new CallExp(loc, new VarExp(loc, fdenter), new VarExp(loc, tmp));
 			e.type = Type.tvoid;			// do not run semantic on e
-			cs.push(cast(void*)new ExpStatement(loc, e));
+			cs.push(new ExpStatement(loc, e));
 
 			FuncDeclaration fdexit = FuncDeclaration.genCfunc(Type.tvoid, Id.monitorexit);
 			e = new CallExp(loc, new VarExp(loc, fdexit), new VarExp(loc, tmp));
 			e.type = Type.tvoid;			// do not run semantic on e
 			Statement s = new ExpStatement(loc, e);
 			s = new TryFinallyStatement(loc, body_, s);
-			cs.push(cast(void*)s);
+			cs.push(s);
 
 			s = new CompoundStatement(loc, cs);
 			return s.semantic(sc);
@@ -120,14 +120,14 @@
 			tmp.storage_class |= STCgshared | STCstatic;
 
 			Statements cs = new Statements();
-			cs.push(cast(void*)new DeclarationStatement(loc, new DeclarationExp(loc, tmp)));
+			cs.push(new DeclarationStatement(loc, new DeclarationExp(loc, tmp)));
 
 			FuncDeclaration fdenter = FuncDeclaration.genCfunc(Type.tvoid, Id.criticalenter);
 			Expression e = new DotIdExp(loc, new VarExp(loc, tmp), Id.ptr);
 			e = e.semantic(sc);
 			e = new CallExp(loc, new VarExp(loc, fdenter), e);
 			e.type = Type.tvoid;			// do not run semantic on e
-			cs.push(cast(void*)new ExpStatement(loc, e));
+			cs.push(new ExpStatement(loc, e));
 
 			FuncDeclaration fdexit = FuncDeclaration.genCfunc(Type.tvoid, Id.criticalexit);
 			e = new DotIdExp(loc, new VarExp(loc, tmp), Id.ptr);
@@ -136,7 +136,7 @@
 			e.type = Type.tvoid;			// do not run semantic on e
 			Statement s = new ExpStatement(loc, e);
 			s = new TryFinallyStatement(loc, body_, s);
-			cs.push(cast(void*)s);
+			cs.push(s);
 
 			s = new CompoundStatement(loc, cs);
 			return s.semantic(sc);
--- a/dmd/UnrolledLoopStatement.d	Thu Sep 02 22:41:12 2010 +0100
+++ b/dmd/UnrolledLoopStatement.d	Thu Sep 02 23:37:49 2010 +0100
@@ -44,13 +44,11 @@
 		scd.sbreak = this;
 		scd.scontinue = this;
 
-		for (size_t i = 0; i < statements.dim; i++)
+		foreach(ref Statement s; statements)
 		{
-			Statement s = cast(Statement) statements.data[i];
 			if (s)
 			{
 				s = s.semantic(scd);
-				statements.data[i] = cast(void*)s;
 			}
 		}
 
@@ -77,9 +75,8 @@
 	override BE blockExit()
 	{
 		BE result = BEfallthru;
-		for (size_t i = 0; i < statements.dim; i++)
+		foreach (s; statements)
 		{	
-			Statement s = cast(Statement) statements.data[i];
 			if (s)
 			{
 				int r = s.blockExit();
@@ -134,10 +131,8 @@
 
 		block* bdox;
 
-		size_t dim = statements.dim;
-		for (size_t i = 0 ; i < dim ; i++)
+		foreach (s; statements)
 		{
-			Statement s = cast(Statement)statements.data[i];
 			if (s !is null)
 			{
 				mystate.contBlock = block_calloc(blx);
--- a/dmd/VolatileStatement.d	Thu Sep 02 22:41:12 2010 +0100
+++ b/dmd/VolatileStatement.d	Thu Sep 02 23:37:49 2010 +0100
@@ -44,12 +44,9 @@
 		Statements a = statement ? statement.flatten(sc) : null;
 		if (a)
 		{	
-			for (int i = 0; i < a.dim; i++)
+			foreach (ref Statement s; a)
 			{   
-				Statement s = cast(Statement)a.data[i];
-
 				s = new VolatileStatement(loc, s);
-				a.data[i] = cast(void*)s;
 			}
 		}