72
|
1 module dmd.ShrExp;
|
|
2
|
114
|
3 import dmd.common;
|
72
|
4 import dmd.Expression;
|
|
5 import dmd.Identifier;
|
|
6 import dmd.InterState;
|
|
7 import dmd.Loc;
|
|
8 import dmd.Scope;
|
|
9 import dmd.IntRange;
|
|
10 import dmd.IRState;
|
|
11 import dmd.BinExp;
|
0
|
12 import dmd.TOK;
|
|
13 import dmd.Type;
|
72
|
14 import dmd.Id;
|
|
15
|
0
|
16 import dmd.backend.elem;
|
|
17 import dmd.backend.OPER;
|
|
18
|
|
19 import dmd.expression.shift_optimize;
|
72
|
20 import dmd.expression.Shr;
|
|
21
|
0
|
22 class ShrExp : BinExp
|
|
23 {
|
|
24 this(Loc loc, Expression e1, Expression e2)
|
|
25 {
|
|
26 super(loc, TOK.TOKshr, ShrExp.sizeof, e1, e2);
|
|
27 }
|
|
28
|
72
|
29 override Expression semantic(Scope sc)
|
0
|
30 {
|
|
31 Expression e;
|
|
32
|
|
33 if (!type)
|
|
34 {
|
|
35 BinExp.semanticp(sc);
|
|
36 e = op_overload(sc);
|
|
37
|
|
38 if (e)
|
|
39 return e;
|
|
40
|
|
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("ShrExp::optimize(result = %d) %s\n", result, toChars());
|
|
53 return shift_optimize(result, this, &Shr);
|
|
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.shr;
|
|
69 }
|
|
70
|
72
|
71 override Identifier opId_r()
|
0
|
72 {
|
|
73 return Id.shr_r;
|
|
74 }
|
|
75
|
72
|
76 override elem* toElem(IRState* irs)
|
0
|
77 {
|
|
78 return toElemBin(irs, OPER.OPshr);
|
|
79 }
|
|
80 }
|
|
81
|