Mercurial > projects > ddmd
diff dmd/ForeachStatement.d @ 126:1765f3ef917d
ClassDeclarations, Arguments -> Vector
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Fri, 03 Sep 2010 23:25:55 +0100 |
parents | c77e9f4f1793 |
children | 60bb0fe4563e |
line wrap: on
line diff
--- a/dmd/ForeachStatement.d Fri Sep 03 22:17:54 2010 +0100 +++ b/dmd/ForeachStatement.d Fri Sep 03 23:25:55 2010 +0100 @@ -180,8 +180,8 @@ else t = Argument.getNth(tuple.arguments, k).type; - Argument arg = cast(Argument)arguments.data[0]; - Statements st = new Statements(); + auto arg = arguments[0]; + auto st = new Statements(); if (dim == 2) { @@ -204,7 +204,7 @@ var.storage_class |= STC.STCmanifest; DeclarationExp de = new DeclarationExp(loc, var); st.push(new ExpStatement(loc, de)); - arg = cast(Argument)arguments.data[1]; // value + arg = arguments[1]; // value } // Declare value if (arg.storageClass & (STC.STCout | STC.STCref | STC.STClazy)) @@ -215,7 +215,7 @@ Type tb = e.type.toBasetype(); if ((tb.ty == TY.Tfunction || tb.ty == TY.Tsarray) && e.op == TOK.TOKvar) { - VarExp ve = cast(VarExp)e; + auto ve = cast(VarExp)e; var = new AliasDeclaration(loc, arg.ident, ve.var); } else @@ -277,7 +277,7 @@ Argument arg; int i = (dim == 1) ? 0 : 1; // index of value - arg = cast(Argument)arguments.data[i]; + arg = arguments[i]; arg.type = arg.type.semantic(loc, sc); tnv = arg.type.toBasetype(); if (tnv.ty != tn.ty && (tnv.ty == TY.Tchar || tnv.ty == TY.Twchar || tnv.ty == TY.Tdchar)) @@ -286,7 +286,7 @@ error("foreach: value of UTF conversion cannot be ref"); if (dim == 2) { - arg = cast(Argument)arguments.data[0]; + arg = arguments[0]; if (arg.storageClass & STC.STCref) error("foreach: key cannot be ref"); } @@ -297,9 +297,9 @@ for (size_t i = 0; i < dim; i++) { // Declare args - Argument arg = cast(Argument)arguments.data[i]; + auto arg = arguments[i]; Type argtype = arg.type.semantic(loc, sc); - VarDeclaration var = new VarDeclaration(loc, argtype, arg.ident, null); + auto var = new VarDeclaration(loc, argtype, arg.ident, null); var.storage_class |= STC.STCforeach; var.storage_class |= arg.storageClass & (STC.STCin | STC.STCout | STC.STCref | STC.STC_TYPECTOR); if (var.storage_class & (STC.STCref | STC.STCout)) @@ -508,12 +508,12 @@ e = new VarExp(loc, r); Expression einit = new DotIdExp(loc, e, idhead); // einit = einit.semantic(sc); - Argument arg = cast(Argument)arguments.data[0]; - VarDeclaration ve = new VarDeclaration(loc, arg.type, arg.ident, new ExpInitializer(loc, einit)); + auto arg = arguments[0]; + auto ve = new VarDeclaration(loc, arg.type, arg.ident, new ExpInitializer(loc, einit)); ve.storage_class |= STC.STCforeach; ve.storage_class |= arg.storageClass & (STC.STCin | STC.STCout | STC.STCref | STC.STC_TYPECTOR); - DeclarationExp de = new DeclarationExp(loc, ve); + auto de = new DeclarationExp(loc, ve); Statement body2 = new CompoundStatement(loc, new DeclarationStatement(loc, de), this.body_); s = new ForStatement(loc, init, condition, increment, body2); @@ -569,7 +569,7 @@ args = new Arguments(); for (size_t i = 0; i < dim; i++) { - Argument arg = cast(Argument)arguments.data[i]; + auto arg = arguments[i]; arg.type = arg.type.semantic(loc, sc); if (arg.storageClass & STC.STCref) @@ -588,7 +588,7 @@ body_ = new CompoundStatement(loc, s, body_); } a = new Argument(STC.STCref, arg.type, id, null); - args.push(cast(void*)a); + args.push(a); } t = new TypeFunction(args, Type.tint32, 0, LINK.LINKd); fld = new FuncLiteralDeclaration(loc, Loc(0), t, TOK.TOKdelegate, this); @@ -615,7 +615,7 @@ if (tab.ty == TY.Taarray) { // Check types - Argument arg = cast(Argument)arguments.data[0]; + auto arg = arguments[0]; if (dim == 2) { if (arg.storageClass & STC.STCref) @@ -623,7 +623,7 @@ if (!arg.type.equals(taa.index)) error("foreach: index must be type %s, not %s", taa.index.toChars(), arg.type.toChars()); - arg = cast(Argument)arguments.data[1]; + arg = arguments[1]; } if (!arg.type.equals(taa.nextOf())) error("foreach: value must be type %s, not %s", taa.nextOf().toChars(), arg.type.toChars()); @@ -781,9 +781,8 @@ { bool result = true; - for (size_t i = 0; i < arguments.dim; i++) + foreach (arg; arguments) { - Argument arg = cast(Argument)arguments.data[i]; if (!arg.type) { error("cannot infer type for %s", arg.ident.toChars()); @@ -842,7 +841,7 @@ buf.writestring(" ("); for (int i = 0; i < arguments.dim; i++) { - Argument a = cast(Argument)arguments.data[i]; + auto a = arguments[i]; if (i) buf.writestring(", "); if (a.storageClass & STCref)