Mercurial > projects > ddmd
diff dmd/ArrayInitializer.d @ 130:60bb0fe4563e
dmdfe 2.037 first main iteration
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Thu, 09 Sep 2010 22:51:44 +0100 |
parents | e6e542f37b94 |
children | 0c8cc2a10f99 |
line wrap: on
line diff
--- a/dmd/ArrayInitializer.d Sun Sep 05 15:32:22 2010 +0400 +++ b/dmd/ArrayInitializer.d Thu Sep 09 22:51:44 2010 +0100 @@ -98,8 +98,6 @@ length = 0; foreach (size_t i, Expression idx; index) { - Initializer val; - if (idx) { idx = idx.semantic(sc); @@ -108,7 +106,7 @@ length = cast(uint)idx.toInteger(); } - val = value[i]; + Initializer val = value[i]; val = val.semantic(sc, t.nextOf()); value[i] = val; length++; @@ -124,9 +122,22 @@ return this; } + int isAssociativeArray() + { + for (size_t i = 0; i < value.dim; i++) + { + if (index[i]) + return 1; + } + return 0; + } + override Type inferType(Scope sc) { //printf("ArrayInitializer.inferType() %s\n", toChars()); + assert(0); + return null; +static if (false) { type = Type.terror; for (size_t i = 0; i < value.dim; i++) { @@ -140,7 +151,9 @@ { Type t = iz.inferType(sc); if (i == 0) - { + { /* BUG: This gets the type from the first element. + * Fix to use all the elements to figure out the type. + */ t = new TypeSArray(t, new IntegerExp(value.dim)); t = t.semantic(loc, sc); type = t; @@ -150,8 +163,9 @@ return type; Laa: - /* It's possibly an associative array initializer - */ + /* It's possibly an associative array initializer. + * BUG: inferring type from first member. + */ Initializer iz = value[0]; Expression indexinit = index[0]; if (iz && indexinit) @@ -165,6 +179,7 @@ else error(loc, "cannot infer type from this array initializer"); return type; +} } /******************************** @@ -256,7 +271,7 @@ return null; } - Initializer toAssocArrayInitializer() + Expression toAssocArrayLiteral() { assert(false); }