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