Mercurial > projects > ddmd
view dmd/expression/Ptr.d @ 191:52188e7e3fb5
Fixed deprecated features, now compiles with DMD2.058
Also changed Array allocation policy:
Now doesn't reallocate but malloc's, followed by a memcpy (no free).
(this fixes a crash while compiling druntime. Same bug in dmd)
author | korDen@korDen-pc |
---|---|
date | Sun, 25 Mar 2012 03:11:12 +0400 |
parents | e28b18c23469 |
children |
line wrap: on
line source
module dmd.expression.Ptr; import dmd.common; import dmd.Expression; import dmd.Type; import dmd.TOK; import dmd.AddrExp; import dmd.AddExp; import dmd.StructLiteralExp; import dmd.GlobalExpressions; Expression Ptr(Type type, Expression e1) { //printf("Ptr(e1 = %s)\n", e1->toChars()); if (e1.op == TOK.TOKadd) { AddExp ae = cast(AddExp)e1; if (ae.e1.op == TOK.TOKaddress && ae.e2.op == TOK.TOKint64) { AddrExp ade = cast(AddrExp)ae.e1; if (ade.e1.op == TOK.TOKstructliteral) { StructLiteralExp se = cast(StructLiteralExp)ade.e1; uint offset = cast(uint)ae.e2.toInteger(); Expression e = se.getField(type, offset); if (!e) e = EXP_CANT_INTERPRET; return e; } } } return EXP_CANT_INTERPRET; }