Mercurial > projects > ddmd
annotate dmd/UshrExp.d @ 187:b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
author | Abscissa |
---|---|
date | Tue, 07 Jun 2011 23:37:34 -0400 |
parents | e3afd1303184 |
children |
rev | line source |
---|---|
72 | 1 module dmd.UshrExp; |
2 | |
114 | 3 import dmd.common; |
72 | 4 import dmd.Expression; |
5 import dmd.Identifier; | |
6 import dmd.InterState; | |
7 import dmd.Loc; | |
0 | 8 import dmd.Scope; |
72 | 9 import dmd.Id; |
10 import dmd.IntRange; | |
11 import dmd.IRState; | |
12 import dmd.BinExp; | |
0 | 13 import dmd.TOK; |
72 | 14 import dmd.Type; |
15 | |
0 | 16 import dmd.backend.elem; |
17 import dmd.backend.OPER; | |
18 import dmd.backend.TYFL; | |
19 import dmd.backend.Util; | |
20 import dmd.expression.Util; | |
21 import dmd.expression.Ushr; | |
72 | 22 import dmd.expression.shift_optimize; |
23 | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
24 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
|
25 |
0 | 26 class UshrExp : BinExp |
27 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
28 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
|
29 |
0 | 30 this(Loc loc, Expression e1, Expression e2) |
31 { | |
178 | 32 register(); |
0 | 33 super(loc, TOK.TOKushr, UshrExp.sizeof, e1, e2); |
34 } | |
35 | |
72 | 36 override Expression semantic(Scope sc) |
0 | 37 { |
38 Expression e; | |
39 | |
40 if (!type) | |
41 { | |
42 BinExp.semanticp(sc); | |
43 e = op_overload(sc); | |
44 if (e) | |
45 return e; | |
46 e1 = e1.checkIntegral(); | |
47 e2 = e2.checkIntegral(); | |
48 e1 = e1.integralPromotions(sc); | |
49 e2 = e2.castTo(sc, Type.tshiftcnt); | |
50 type = e1.type; | |
51 } | |
52 return this; | |
53 } | |
54 | |
72 | 55 override Expression optimize(int result) |
0 | 56 { |
57 //printf("UshrExp.optimize(result = %d) %s\n", result, toChars()); | |
58 return shift_optimize(result, this, &Ushr); | |
59 } | |
60 | |
72 | 61 override Expression interpret(InterState istate) |
0 | 62 { |
115
6caaf0256da1
+ interpretation of (non-assign) binary expressions
Trass3r
parents:
114
diff
changeset
|
63 return interpretCommon(istate, &Ushr); |
0 | 64 } |
65 | |
72 | 66 override IntRange getIntRange() |
0 | 67 { |
68 assert(false); | |
69 } | |
70 | |
72 | 71 override Identifier opId() |
0 | 72 { |
73 return Id.ushr; | |
74 } | |
75 | |
72 | 76 override Identifier opId_r() |
0 | 77 { |
78 return Id.ushr_r; | |
79 } | |
80 | |
72 | 81 override elem* toElem(IRState* irs) |
0 | 82 { |
135 | 83 //return toElemBin(irs, OPER.OPshr); |
84 elem *eleft = e1.toElem(irs); | |
85 eleft.Ety = touns(eleft.Ety); | |
86 elem *eright = e2.toElem(irs); | |
87 elem *e = el_bin(OPER.OPshr, type.totym(), eleft, eright); | |
88 el_setLoc(e, loc); | |
89 return e; | |
0 | 90 } |
115
6caaf0256da1
+ interpretation of (non-assign) binary expressions
Trass3r
parents:
114
diff
changeset
|
91 } |