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