Mercurial > projects > ddmd
view dmd/expression/ArrayLength.d @ 73:ef02e2e203c2
Updating to dmd2.033
author | korDen |
---|---|
date | Sat, 28 Aug 2010 19:42:41 +0400 |
parents | 10317f0c89a5 |
children | e28b18c23469 |
line wrap: on
line source
module dmd.expression.ArrayLength; import dmd.Type; import dmd.Expression; import dmd.StringExp; import dmd.IntegerExp; import dmd.ArrayLiteralExp; import dmd.Loc; import dmd.TOK; import dmd.AssocArrayLiteralExp; import dmd.GlobalExpressions; Expression ArrayLength(Type type, Expression e1) { Expression e; Loc loc = e1.loc; if (e1.op == TOKstring) { StringExp es1 = cast(StringExp)e1; e = new IntegerExp(loc, es1.len, type); } else if (e1.op == TOKarrayliteral) { ArrayLiteralExp ale = cast(ArrayLiteralExp)e1; size_t dim = ale.elements ? ale.elements.dim : 0; e = new IntegerExp(loc, dim, type); } else if (e1.op == TOKassocarrayliteral) { AssocArrayLiteralExp ale = cast(AssocArrayLiteralExp)e1; size_t dim = ale.keys.dim; e = new IntegerExp(loc, dim, type); } else e = EXP_CANT_INTERPRET; return e; }