Mercurial > projects > ddmd
annotate dmd/PostExp.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 | e28b18c23469 |
children | af724d3510d7 |
rev | line source |
---|---|
72 | 1 module dmd.PostExp; |
2 | |
114 | 3 import dmd.common; |
72 | 4 import dmd.Expression; |
5 import dmd.Identifier; | |
6 import dmd.backend.elem; | |
7 import dmd.InterState; | |
8 import dmd.OutBuffer; | |
9 import dmd.Loc; | |
10 import dmd.Scope; | |
11 import dmd.IRState; | |
12 import dmd.BinExp; | |
0 | 13 import dmd.HdrGenState; |
72 | 14 import dmd.IntegerExp; |
0 | 15 import dmd.TOK; |
16 import dmd.Type; | |
17 import dmd.TY; | |
18 import dmd.Id; | |
19 | |
20 import dmd.backend.Util; | |
72 | 21 import dmd.backend.OPER; |
22 | |
0 | 23 class PostExp : BinExp |
24 { | |
25 this(TOK op, Loc loc, Expression e) | |
26 { | |
27 super(loc, op, PostExp.sizeof, e, new IntegerExp(loc, 1, Type.tint32)); | |
28 } | |
29 | |
72 | 30 override Expression semantic(Scope sc) |
0 | 31 { |
32 Expression e = this; | |
33 | |
34 if (!type) | |
35 { | |
36 BinExp.semantic(sc); | |
37 e2 = resolveProperties(sc, e2); | |
38 | |
39 e = op_overload(sc); | |
40 if (e) | |
41 return e; | |
42 | |
43 e = this; | |
44 e1 = e1.modifiableLvalue(sc, e1); | |
45 e1.checkScalar(); | |
46 e1.checkNoBool(); | |
47 if (e1.type.ty == Tpointer) | |
48 e = scaleFactor(sc); | |
49 else | |
50 e2 = e2.castTo(sc, e1.type); | |
51 e.type = e1.type; | |
52 } | |
53 return e; | |
54 } | |
55 | |
72 | 56 override Expression interpret(InterState istate) |
0 | 57 { |
58 assert(false); | |
59 } | |
60 | |
72 | 61 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 62 { |
63 assert(false); | |
64 } | |
65 | |
72 | 66 override Identifier opId() |
0 | 67 { |
68 return (op == TOKplusplus) ? Id.postinc : Id.postdec; | |
69 } | |
70 | |
72 | 71 override elem* toElem(IRState* irs) |
0 | 72 { |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
73 auto e = e1.toElem(irs); |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
74 auto einc = e2.toElem(irs); |
0 | 75 e = el_bin((op == TOKplusplus) ? OPpostinc : OPpostdec, |
76 e.Ety,e,einc); | |
77 el_setLoc(e,loc); | |
78 return e; | |
79 } | |
80 } | |
81 |