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
|
0
|
24 class UshrExp : BinExp
|
|
25 {
|
|
26 this(Loc loc, Expression e1, Expression e2)
|
|
27 {
|
|
28 super(loc, TOK.TOKushr, UshrExp.sizeof, e1, e2);
|
|
29 }
|
|
30
|
72
|
31 override Expression semantic(Scope sc)
|
0
|
32 {
|
|
33 Expression e;
|
|
34
|
|
35 if (!type)
|
|
36 {
|
|
37 BinExp.semanticp(sc);
|
|
38 e = op_overload(sc);
|
|
39 if (e)
|
|
40 return e;
|
|
41 e1 = e1.checkIntegral();
|
|
42 e2 = e2.checkIntegral();
|
|
43 e1 = e1.integralPromotions(sc);
|
|
44 e2 = e2.castTo(sc, Type.tshiftcnt);
|
|
45 type = e1.type;
|
|
46 }
|
|
47 return this;
|
|
48 }
|
|
49
|
72
|
50 override Expression optimize(int result)
|
0
|
51 {
|
|
52 //printf("UshrExp.optimize(result = %d) %s\n", result, toChars());
|
|
53 return shift_optimize(result, this, &Ushr);
|
|
54 }
|
|
55
|
72
|
56 override Expression interpret(InterState istate)
|
0
|
57 {
|
|
58 assert(false);
|
|
59 }
|
|
60
|
72
|
61 override IntRange getIntRange()
|
0
|
62 {
|
|
63 assert(false);
|
|
64 }
|
|
65
|
72
|
66 override Identifier opId()
|
0
|
67 {
|
|
68 return Id.ushr;
|
|
69 }
|
|
70
|
72
|
71 override Identifier opId_r()
|
0
|
72 {
|
|
73 return Id.ushr_r;
|
|
74 }
|
|
75
|
72
|
76 override elem* toElem(IRState* irs)
|
0
|
77 {
|
|
78 elem *eleft = e1.toElem(irs);
|
|
79 eleft.Ety = touns(eleft.Ety);
|
|
80 elem *eright = e2.toElem(irs);
|
|
81 elem *e = el_bin(OPshr, type.totym(), eleft, eright);
|
|
82 el_setLoc(e, loc);
|
|
83 return e;
|
|
84 }
|
|
85 }
|
|
86
|