Mercurial > projects > ddmd
comparison dmd/ForeachStatement.d @ 96:acd69f84627e
further work
author | Trass3r |
---|---|
date | Tue, 31 Aug 2010 02:12:15 +0200 |
parents | 39648eb578f6 |
children | e28b18c23469 |
comparison
equal
deleted
inserted
replaced
95:ae5b11064a9a | 96:acd69f84627e |
---|---|
251 sym.parent = sc.scopesym; | 251 sym.parent = sc.scopesym; |
252 sc = sc.push(sym); | 252 sc = sc.push(sym); |
253 | 253 |
254 sc.noctor++; | 254 sc.noctor++; |
255 | 255 |
256 Lagain: | |
256 switch (tab.ty) | 257 switch (tab.ty) |
257 { | 258 { |
258 case TY.Tarray: | 259 case TY.Tarray: |
259 case TY.Tsarray: | 260 case TY.Tsarray: |
260 if (!checkForArgTypes()) | 261 if (!checkForArgTypes()) |
316 if (var.storage_class & STC.STCref && !tn.isMutable()) | 317 if (var.storage_class & STC.STCref && !tn.isMutable()) |
317 { | 318 { |
318 var.storage_class |= STC.STCconst; | 319 var.storage_class |= STC.STCconst; |
319 } | 320 } |
320 } | 321 } |
321 static if (false) { | 322 static if (false) |
323 { | |
322 DeclarationExp de = new DeclarationExp(loc, var); | 324 DeclarationExp de = new DeclarationExp(loc, var); |
323 de.semantic(sc); | 325 de.semantic(sc); |
324 } | 326 } |
325 } | 327 } |
326 | 328 |
327 static if (true) { | 329 static if (true) |
330 { | |
328 { | 331 { |
329 /* Convert to a ForStatement | 332 /* Convert to a ForStatement |
330 * foreach (key, value; a) body => | 333 * foreach (key, value; a) body => |
331 * for (T[] tmp = a[], size_t key; key < tmp.length; ++key) | 334 * for (T[] tmp = a[], size_t key; key < tmp.length; ++key) |
332 * { T value = tmp[k]; body } | 335 * { T value = tmp[k]; body } |
421 if (dim < 1 || dim > 2) | 424 if (dim < 1 || dim > 2) |
422 { | 425 { |
423 error("only one or two arguments for associative array foreach"); | 426 error("only one or two arguments for associative array foreach"); |
424 break; | 427 break; |
425 } | 428 } |
429 version(SARRAYVALUE) | |
430 { | |
431 /* This only works if Key or Value is a static array. | |
432 */ | |
433 tab = taa.getImpl().type; | |
434 goto Lagain; | |
435 } | |
436 else | |
437 { | |
426 if (op == TOK.TOKforeach_reverse) | 438 if (op == TOK.TOKforeach_reverse) |
427 { | 439 { |
428 error("no reverse iteration on associative arrays"); | 440 error("no reverse iteration on associative arrays"); |
429 } | 441 } |
430 goto Lapply; | 442 goto Lapply; |
431 | 443 } |
432 case TY.Tclass: | 444 case TY.Tclass: |
433 case TY.Tstruct: | 445 case TY.Tstruct: |
434 version (DMDV2) { | 446 version (DMDV2) { |
435 { /* Look for range iteration, i.e. the properties | 447 { /* Look for range iteration, i.e. the properties |
436 * .empty, .next, .retreat, .head and .rear | 448 * .empty, .next, .retreat, .head and .rear |