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