Skip to content

Commit

Permalink
Merge pull request #4939 from WalterBright/foreach2
Browse files Browse the repository at this point in the history
statement.d: for => foreach
  • Loading branch information
yebblies committed Aug 25, 2015
2 parents 05d132b + 898f608 commit d6725fa
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions src/statement.d
Expand Up @@ -316,7 +316,7 @@ public:
//printf("CompoundStatement::blockExit(%p) %d\n", cs, cs->statements->dim);
result = BEfallthru;
Statement slast = null;
for (size_t i = 0; i < cs.statements.dim; i++)
foreach (i; 0 .. cs.statements.dim)
{
Statement s = (*cs.statements)[i];
if (s)
Expand Down Expand Up @@ -362,7 +362,7 @@ public:
void visit(UnrolledLoopStatement uls)
{
result = BEfallthru;
for (size_t i = 0; i < uls.statements.dim; i++)
foreach (i; 0 .. uls.statements.dim)
{
Statement s = (*uls.statements)[i];
if (s)
Expand Down Expand Up @@ -592,7 +592,7 @@ public:
assert(s._body);
result = s._body.blockExit(func, false);
int catchresult = 0;
for (size_t i = 0; i < s.catches.dim; i++)
foreach (i; 0 .. s.catches.dim)
{
Catch c = (*s.catches)[i];
if (c.type == Type.terror)
Expand Down Expand Up @@ -970,7 +970,7 @@ extern (C++) Statement toStatement(Dsymbol s)
if (!a)
return null;
auto statements = new Statements();
for (size_t i = 0; i < a.dim; i++)
foreach (i; 0 .. a.dim)
{
statements.push(toStatement((*a)[i]));
}
Expand All @@ -986,7 +986,7 @@ extern (C++) Statement toStatement(Dsymbol s)
void visit(TemplateMixin tm)
{
auto a = new Statements();
for (size_t i = 0; i < tm.members.dim; i++)
foreach (i; 0 .. tm.members.dim)
{
Statement s = toStatement((*tm.members)[i]);
if (s)
Expand Down Expand Up @@ -1394,7 +1394,7 @@ public:
{
auto a = new Statements();
a.setDim(statements.dim);
for (size_t i = 0; i < statements.dim; i++)
foreach (i; 0 .. statements.dim)
{
Statement s = (*statements)[i];
(*a)[i] = s ? s.syntaxCopy() : null;
Expand All @@ -1407,7 +1407,7 @@ public:
//printf("CompoundStatement::semantic(this = %p, sc = %p)\n", this, sc);
version (none)
{
for (size_t i = 0; i < statements.dim; i++)
foreach (i; 0 .. statements.dim)
{
Statement s = (*statements)[i];
if (s)
Expand Down Expand Up @@ -1458,7 +1458,7 @@ public:
* { sexception; throw __o; }
*/
auto a = new Statements();
for (size_t j = i + 1; j < statements.dim; j++)
foreach (j; i + 1 .. statements.dim)
{
a.push((*statements)[j]);
}
Expand Down Expand Up @@ -1499,7 +1499,7 @@ public:
* s; try { s1; s2; } finally { sfinally; }
*/
auto a = new Statements();
for (size_t j = i + 1; j < statements.dim; j++)
foreach (j; i + 1 .. statements.dim)
{
a.push((*statements)[j]);
}
Expand All @@ -1522,7 +1522,7 @@ public:
}
i++;
}
for (size_t i = 0; i < statements.dim; ++i)
foreach (i; 0 .. statements.dim)
{
Lagain:
Statement s = (*statements)[i];
Expand Down Expand Up @@ -1559,7 +1559,7 @@ public:
final ReturnStatement isReturnStatement()
{
ReturnStatement rs = null;
for (size_t i = 0; i < statements.dim; i++)
foreach (i; 0 .. statements.dim)
{
Statement s = (*statements)[i];
if (s)
Expand Down Expand Up @@ -1613,7 +1613,7 @@ public:
{
auto a = new Statements();
a.setDim(statements.dim);
for (size_t i = 0; i < statements.dim; i++)
foreach (i; 0 .. statements.dim)
{
Statement s = (*statements)[i];
(*a)[i] = s ? s.syntaxCopy() : null;
Expand Down Expand Up @@ -1646,7 +1646,7 @@ public:
{
auto a = new Statements();
a.setDim(statements.dim);
for (size_t i = 0; i < statements.dim; i++)
foreach (i; 0 .. statements.dim)
{
Statement s = (*statements)[i];
(*a)[i] = s ? s.syntaxCopy() : null;
Expand All @@ -1661,7 +1661,7 @@ public:
scd.sbreak = this;
scd.scontinue = this;
Statement serror = null;
for (size_t i = 0; i < statements.dim; i++)
foreach (i; 0 .. statements.dim)
{
Statement s = (*statements)[i];
if (s)
Expand Down Expand Up @@ -2144,7 +2144,7 @@ public:
}
else
assert(0);
for (size_t j = 0; j < n; j++)
foreach (j; 0 .. n)
{
size_t k = (op == TOKforeach) ? j : n - 1 - j;
Expression e = null;
Expand Down Expand Up @@ -2325,7 +2325,7 @@ public:
goto Lapply;
}
}
for (size_t i = 0; i < dim; i++)
foreach (i; 0 .. dim)
{
// Declare parameterss
Parameter p = (*parameters)[i];
Expand Down Expand Up @@ -2589,7 +2589,7 @@ public:
error("cannot infer argument types, expected %d argument%s, not %d", exps.dim, plural, dim);
goto Lerror2;
}
for (size_t i = 0; i < dim; i++)
foreach (i; 0 .. dim)
{
Parameter p = (*parameters)[i];
Expression exp = (*exps)[i];
Expand Down Expand Up @@ -2665,7 +2665,7 @@ public:
* int delegate(ref T param) { body }
*/
auto params = new Parameters();
for (size_t i = 0; i < dim; i++)
foreach (i; 0 .. dim)
{
Parameter p = (*parameters)[i];
StorageClass stc = STCref;
Expand Down Expand Up @@ -2719,7 +2719,7 @@ public:
flde = flde.semantic(sc);
fld.tookAddressOf = 0;
// Resolve any forward referenced goto's
for (size_t i = 0; i < gotos.dim; i++)
foreach (i; 0 .. gotos.dim)
{
GotoStatement gs = cast(GotoStatement)(*gotos)[i].statement;
if (!gs.label.statement)
Expand Down Expand Up @@ -2921,7 +2921,7 @@ public:
s = new DefaultStatement(Loc(), s);
a.push(s);
// cases 2...
for (size_t i = 0; i < cases.dim; i++)
foreach (i; 0 .. cases.dim)
{
s = (*cases)[i];
s = new CaseStatement(Loc(), new IntegerExp(i + 2), s);
Expand Down Expand Up @@ -2949,7 +2949,7 @@ public:
bool checkForArgTypes()
{
bool result = false;
for (size_t i = 0; i < parameters.dim; i++)
foreach (i; 0 .. parameters.dim)
{
Parameter p = (*parameters)[i];
if (!p.type)
Expand Down Expand Up @@ -3399,7 +3399,7 @@ public:
{
if (args)
{
for (size_t i = 0; i < args.dim; i++)
foreach (i; 0 .. args.dim)
{
Expression e = (*args)[i];
sc = sc.startCTFE();
Expand Down Expand Up @@ -3653,7 +3653,7 @@ public:
if (conditionError || _body.isErrorStatement())
goto Lerror;
// Resolve any goto case's with exp
for (size_t i = 0; i < gotoCases.dim; i++)
foreach (i; 0 .. gotoCases.dim)
{
GotoCaseStatement gcs = gotoCases[i];
if (!gcs.exp)
Expand All @@ -3665,7 +3665,7 @@ public:
{
if (!scx.sw)
continue;
for (size_t j = 0; j < scx.sw.cases.dim; j++)
foreach (j; 0 .. scx.sw.cases.dim)
{
CaseStatement cs = (*scx.sw.cases)[j];
if (cs.exp.equals(gcs.exp))
Expand All @@ -3691,12 +3691,12 @@ public:
if (ed)
{
size_t dim = ed.members.dim;
for (size_t i = 0; i < dim; i++)
foreach (i; 0 .. dim)
{
EnumMember em = (*ed.members)[i].isEnumMember();
if (em)
{
for (size_t j = 0; j < cases.dim; j++)
foreach (j; 0 .. cases.dim)
{
CaseStatement cs = (*cases)[j];
if (cs.exp.equals(em.value) || (!cs.exp.type.isString() && !em.value.type.isString() && cs.exp.toInteger() == em.value.toInteger()))
Expand Down Expand Up @@ -3816,7 +3816,7 @@ public:
errors = true;
}
L1:
for (size_t i = 0; i < sw.cases.dim; i++)
foreach (i; 0 .. sw.cases.dim)
{
CaseStatement cs = (*sw.cases)[i];
//printf("comparing '%s' with '%s'\n", exp->toChars(), cs->exp->toChars());
Expand Down Expand Up @@ -4378,7 +4378,7 @@ public:
AggregateDeclaration ad = fd.isAggregateMember2();
assert(ad);
size_t dim = sc.fieldinit_dim;
for (size_t i = 0; i < dim; i++)
foreach (i; 0 .. dim)
{
VarDeclaration v = ad.fields[i];
bool mustInit = (v.storage_class & STCnodefaultctor || v.type.needsNested());
Expand Down Expand Up @@ -4914,7 +4914,7 @@ public:
{
auto a = new Catches();
a.setDim(catches.dim);
for (size_t i = 0; i < a.dim; i++)
foreach (i; 0 .. a.dim)
{
Catch c = (*catches)[i];
(*a)[i] = c.syntaxCopy();
Expand All @@ -4929,7 +4929,7 @@ public:
/* Even if body is empty, still do semantic analysis on catches
*/
bool catchErrors = false;
for (size_t i = 0; i < catches.dim; i++)
foreach (i; 0 .. catches.dim)
{
Catch c = (*catches)[i];
c.semantic(sc);
Expand All @@ -4939,7 +4939,7 @@ public:
continue;
}
// Determine if current catch 'hides' any previous catches
for (size_t j = 0; j < i; j++)
foreach (j; 0 .. i)
{
Catch cj = (*catches)[j];
char* si = c.loc.toChars();
Expand All @@ -4960,7 +4960,7 @@ public:
*/
if (!(_body.blockExit(sc.func, false) & BEthrow) && ClassDeclaration.exception)
{
for (size_t i = 0; i < catches.dim; i++)
foreach (i; 0 .. catches.dim)
{
Catch c = (*catches)[i];
/* If catch exception type is derived from Exception
Expand Down Expand Up @@ -5327,7 +5327,7 @@ public:
Statements* a = statement ? statement.flatten(sc) : null;
if (a)
{
for (size_t i = 0; i < a.dim; i++)
foreach (i; 0 .. a.dim)
{
Statement s = (*a)[i];
s = new DebugStatement(loc, s);
Expand Down Expand Up @@ -5508,7 +5508,7 @@ public:
if (sc.fieldinit)
{
size_t dim = sc.fieldinit_dim;
for (size_t i = 0; i < dim; i++)
foreach (i; 0 .. dim)
sc.fieldinit[i] |= CSXlabel;
}
sc.slabel = this;
Expand Down Expand Up @@ -5647,7 +5647,7 @@ public:
{
auto a = new Statements();
a.setDim(statements.dim);
for (size_t i = 0; i < statements.dim; i++)
foreach (i; 0 .. statements.dim)
{
Statement s = (*statements)[i];
(*a)[i] = s ? s.syntaxCopy() : null;
Expand All @@ -5657,7 +5657,7 @@ public:

CompoundAsmStatement semantic(Scope* sc)
{
for (size_t i = 0; i < statements.dim; i++)
foreach (i; 0 .. statements.dim)
{
Statement s = (*statements)[i];
(*statements)[i] = s ? s.semantic(sc) : null;
Expand Down Expand Up @@ -5701,7 +5701,7 @@ public:
{
auto m = new Dsymbols();
m.setDim(imports.dim);
for (size_t i = 0; i < imports.dim; i++)
foreach (i; 0 .. imports.dim)
{
Dsymbol s = (*imports)[i];
(*m)[i] = s.syntaxCopy(null);
Expand All @@ -5711,7 +5711,7 @@ public:

Statement semantic(Scope* sc)
{
for (size_t i = 0; i < imports.dim; i++)
foreach (i; 0 .. imports.dim)
{
Import s = (*imports)[i].isImport();
assert(!s.aliasdecls.dim);
Expand All @@ -5729,7 +5729,7 @@ public:
s.semantic(sc);
//s->semantic2(sc); // Bugzilla 14666
sc.insert(s);
for (size_t j = 0; j < s.aliasdecls.dim; j++)
foreach (j; 0 .. s.aliasdecls.dim)
{
sc.insert(s.aliasdecls[j]);
}
Expand Down

0 comments on commit d6725fa

Please sign in to comment.