Mercurial > projects > ddmd
comparison dmd/expression/Ptr.d @ 0:10317f0c89a5
Initial commit
author | korDen |
---|---|
date | Sat, 24 Oct 2009 08:42:06 +0400 |
parents | |
children | e28b18c23469 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:10317f0c89a5 |
---|---|
1 module dmd.expression.Ptr; | |
2 | |
3 import dmd.Expression; | |
4 import dmd.Type; | |
5 import dmd.TOK; | |
6 import dmd.AddrExp; | |
7 import dmd.AddExp; | |
8 import dmd.StructLiteralExp; | |
9 import dmd.GlobalExpressions; | |
10 | |
11 Expression Ptr(Type type, Expression e1) | |
12 { | |
13 //printf("Ptr(e1 = %s)\n", e1->toChars()); | |
14 if (e1.op == TOK.TOKadd) | |
15 { | |
16 AddExp ae = cast(AddExp)e1; | |
17 if (ae.e1.op == TOK.TOKaddress && ae.e2.op == TOK.TOKint64) | |
18 { | |
19 AddrExp ade = cast(AddrExp)ae.e1; | |
20 if (ade.e1.op == TOK.TOKstructliteral) | |
21 { | |
22 StructLiteralExp se = cast(StructLiteralExp)ade.e1; | |
23 uint offset = cast(uint)ae.e2.toInteger(); | |
24 Expression e = se.getField(type, offset); | |
25 if (!e) | |
26 e = EXP_CANT_INTERPRET; | |
27 | |
28 return e; | |
29 } | |
30 } | |
31 } | |
32 | |
33 return EXP_CANT_INTERPRET; | |
34 } | |
35 |