comparison dmd/ShlExp.d @ 0:10317f0c89a5

Initial commit
author korDen
date Sat, 24 Oct 2009 08:42:06 +0400
parents
children cab4c37afb89
comparison
equal deleted inserted replaced
-1:000000000000 0:10317f0c89a5
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;
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
19 import dmd.backend.OPER;
20
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
28 Expression semantic(Scope sc)
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
51 Expression optimize(int result)
52 {
53 //printf("ShlExp::optimize(result = %d) %s\n", result, toChars());
54 return shift_optimize(result, this, &Shl);
55 }
56
57 Expression interpret(InterState* istate)
58 {
59 assert(false);
60 }
61
62 IntRange getIntRange()
63 {
64 assert(false);
65 }
66
67 Identifier opId()
68 {
69 return Id.shl;
70 }
71
72 Identifier opId_r()
73 {
74 return Id.shl_r;
75 }
76
77 elem* toElem(IRState* irs)
78 {
79 return toElemBin(irs, OPER.OPshl);
80 }
81 }
82