Mercurial > projects > ldc
comparison dmd/statement.c @ 34:4648206ca213 trunk
[svn r38] * resizing dynamic arrays support
* throw is replaced with assert(0)
* catch is ignored
* better foreach support
* various bugfixes
author | lindquist |
---|---|
date | Tue, 09 Oct 2007 02:50:00 +0200 |
parents | 788401029ecf |
children | 77cdca8c210f |
comparison
equal
deleted
inserted
replaced
33:bc641b23a714 | 34:4648206ca213 |
---|---|
1171 if (dim == 2) | 1171 if (dim == 2) |
1172 { // Declare key | 1172 { // Declare key |
1173 if (arg->storageClass & (STCout | STCref | STClazy)) | 1173 if (arg->storageClass & (STCout | STCref | STClazy)) |
1174 error("no storage class for key %s", arg->ident->toChars()); | 1174 error("no storage class for key %s", arg->ident->toChars()); |
1175 TY keyty = arg->type->ty; | 1175 TY keyty = arg->type->ty; |
1176 if ((keyty != Tint32 && keyty != Tuns32) || | 1176 if ((keyty != Tint32 && keyty != Tuns32) && |
1177 (global.params.is64bit && | 1177 (global.params.is64bit && keyty != Tint64 && keyty != Tuns64) |
1178 keyty != Tint64 && keyty != Tuns64) | |
1179 ) | 1178 ) |
1180 { | 1179 { |
1181 error("foreach: key type must be int or uint, not %s", arg->type->toChars()); | 1180 error("foreach: key type must be %s, not %s", global.params.is64bit ? "int, uint, long or ulong" : "int or uint",arg->type->toChars()); |
1182 } | 1181 } |
1183 Initializer *ie = new ExpInitializer(0, new IntegerExp(k)); | 1182 Initializer *ie = new ExpInitializer(0, new IntegerExp(k)); |
1184 VarDeclaration *var = new VarDeclaration(loc, arg->type, arg->ident, ie); | 1183 VarDeclaration *var = new VarDeclaration(loc, arg->type, arg->ident, ie); |
1185 var->storage_class |= STCconst; | 1184 var->storage_class |= STCconst; |
1186 DeclarationExp *de = new DeclarationExp(loc, var); | 1185 DeclarationExp *de = new DeclarationExp(loc, var); |
1313 else | 1312 else |
1314 error("foreach: %s is not an array of %s", tab->toChars(), value->type->toChars()); | 1313 error("foreach: %s is not an array of %s", tab->toChars(), value->type->toChars()); |
1315 } | 1314 } |
1316 | 1315 |
1317 if (key && | 1316 if (key && |
1318 ((key->type->ty != Tint32 && key->type->ty != Tuns32) || | 1317 ((key->type->ty != Tint32 && key->type->ty != Tuns32) && |
1319 (global.params.is64bit && | 1318 (global.params.is64bit && key->type->ty != Tint64 && key->type->ty != Tuns64) |
1320 key->type->ty != Tint64 && key->type->ty != Tuns64) | |
1321 ) | 1319 ) |
1322 ) | 1320 ) |
1323 { | 1321 { |
1324 error("foreach: key type must be int or uint, not %s", key->type->toChars()); | 1322 error("foreach: key type must be %s, not %s", global.params.is64bit ? "int, uint, long or ulong" : "int or uint", key->type->toChars()); |
1325 } | 1323 } |
1326 | 1324 |
1327 if (key && key->storage_class & (STCout | STCref)) | 1325 if (key && key->storage_class & (STCout | STCref)) |
1328 error("foreach: key cannot be out or ref"); | 1326 error("foreach: key cannot be out or ref"); |
1329 break; | 1327 break; |