72
|
1 module dmd.UshrExp;
|
|
2
|
|
3 import dmd.Expression;
|
|
4 import dmd.Identifier;
|
|
5 import dmd.InterState;
|
|
6 import dmd.Loc;
|
0
|
7 import dmd.Scope;
|
72
|
8 import dmd.Id;
|
|
9 import dmd.IntRange;
|
|
10 import dmd.IRState;
|
|
11 import dmd.BinExp;
|
0
|
12 import dmd.TOK;
|
72
|
13 import dmd.Type;
|
|
14
|
0
|
15 import dmd.backend.elem;
|
|
16 import dmd.backend.OPER;
|
|
17 import dmd.backend.TYFL;
|
|
18 import dmd.backend.Util;
|
|
19 import dmd.expression.Util;
|
|
20 import dmd.expression.Ushr;
|
72
|
21 import dmd.expression.shift_optimize;
|
|
22
|
0
|
23 class UshrExp : BinExp
|
|
24 {
|
|
25 this(Loc loc, Expression e1, Expression e2)
|
|
26 {
|
|
27 super(loc, TOK.TOKushr, UshrExp.sizeof, e1, e2);
|
|
28 }
|
|
29
|
72
|
30 override Expression semantic(Scope sc)
|
0
|
31 {
|
|
32 Expression e;
|
|
33
|
|
34 if (!type)
|
|
35 {
|
|
36 BinExp.semanticp(sc);
|
|
37 e = op_overload(sc);
|
|
38 if (e)
|
|
39 return e;
|
|
40 e1 = e1.checkIntegral();
|
|
41 e2 = e2.checkIntegral();
|
|
42 e1 = e1.integralPromotions(sc);
|
|
43 e2 = e2.castTo(sc, Type.tshiftcnt);
|
|
44 type = e1.type;
|
|
45 }
|
|
46 return this;
|
|
47 }
|
|
48
|
72
|
49 override Expression optimize(int result)
|
0
|
50 {
|
|
51 //printf("UshrExp.optimize(result = %d) %s\n", result, toChars());
|
|
52 return shift_optimize(result, this, &Ushr);
|
|
53 }
|
|
54
|
72
|
55 override Expression interpret(InterState istate)
|
0
|
56 {
|
|
57 assert(false);
|
|
58 }
|
|
59
|
72
|
60 override IntRange getIntRange()
|
0
|
61 {
|
|
62 assert(false);
|
|
63 }
|
|
64
|
72
|
65 override Identifier opId()
|
0
|
66 {
|
|
67 return Id.ushr;
|
|
68 }
|
|
69
|
72
|
70 override Identifier opId_r()
|
0
|
71 {
|
|
72 return Id.ushr_r;
|
|
73 }
|
|
74
|
72
|
75 override elem* toElem(IRState* irs)
|
0
|
76 {
|
|
77 elem *eleft = e1.toElem(irs);
|
|
78 eleft.Ety = touns(eleft.Ety);
|
|
79 elem *eright = e2.toElem(irs);
|
|
80 elem *e = el_bin(OPshr, type.totym(), eleft, eright);
|
|
81 el_setLoc(e, loc);
|
|
82 return e;
|
|
83 }
|
|
84 }
|
|
85
|