Mercurial > projects > ddmd
annotate dmd/PostExp.d @ 192:eb38fdcb3e62 default tip
updated to compile with dmd2.062
author | korDen |
---|---|
date | Sat, 02 Mar 2013 01:25:52 -0800 |
parents | b0d41ff5e0df |
children |
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; | |
174 | 12 import dmd.PREC; |
72 | 13 import dmd.BinExp; |
0 | 14 import dmd.HdrGenState; |
72 | 15 import dmd.IntegerExp; |
0 | 16 import dmd.TOK; |
17 import dmd.Type; | |
18 import dmd.TY; | |
19 import dmd.Id; | |
20 | |
174 | 21 import dmd.expression.Util; |
22 | |
0 | 23 import dmd.backend.Util; |
72 | 24 import dmd.backend.OPER; |
25 | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
26 import dmd.DDMDExtensions; |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
27 |
0 | 28 class PostExp : BinExp |
29 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
30 mixin insertMemberExtension!(typeof(this)); |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
31 |
0 | 32 this(TOK op, Loc loc, Expression e) |
33 { | |
178 | 34 register(); |
0 | 35 super(loc, op, PostExp.sizeof, e, new IntegerExp(loc, 1, Type.tint32)); |
36 } | |
37 | |
72 | 38 override Expression semantic(Scope sc) |
0 | 39 { |
40 Expression e = this; | |
41 | |
42 if (!type) | |
43 { | |
44 BinExp.semantic(sc); | |
45 e2 = resolveProperties(sc, e2); | |
46 | |
47 e = op_overload(sc); | |
48 if (e) | |
49 return e; | |
50 | |
51 e = this; | |
52 e1 = e1.modifiableLvalue(sc, e1); | |
53 e1.checkScalar(); | |
54 e1.checkNoBool(); | |
55 if (e1.type.ty == Tpointer) | |
56 e = scaleFactor(sc); | |
57 else | |
58 e2 = e2.castTo(sc, e1.type); | |
59 e.type = e1.type; | |
60 } | |
61 return e; | |
62 } | |
63 | |
72 | 64 override Expression interpret(InterState istate) |
0 | 65 { |
66 assert(false); | |
67 } | |
68 | |
72 | 69 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 70 { |
174 | 71 expToCBuffer(buf, hgs, e1, precedence[op]); |
72 buf.writestring((op == TOKplusplus) ? "++" : "--"); | |
0 | 73 } |
74 | |
72 | 75 override Identifier opId() |
0 | 76 { |
77 return (op == TOKplusplus) ? Id.postinc : Id.postdec; | |
78 } | |
79 | |
72 | 80 override elem* toElem(IRState* irs) |
0 | 81 { |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
82 auto e = e1.toElem(irs); |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
83 auto einc = e2.toElem(irs); |
0 | 84 e = el_bin((op == TOKplusplus) ? OPpostinc : OPpostdec, |
85 e.Ety,e,einc); | |
86 el_setLoc(e,loc); | |
87 return e; | |
88 } | |
89 } | |
90 |