Mercurial > projects > ddmd
view dmd/expression/ArrayLength.d @ 114:e28b18c23469
added a module dmd.common for commonly used stuff
it currently holds code for consistency checking of predefined versions
also added a VisualD project file
author | Trass3r |
---|---|
date | Wed, 01 Sep 2010 18:21:58 +0200 |
parents | 10317f0c89a5 |
children | 60bb0fe4563e |
line wrap: on
line source
module dmd.expression.ArrayLength; import dmd.common; 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; }