Mercurial > projects > ddmd
annotate dmd/ShrExp.d @ 130:60bb0fe4563e
dmdfe 2.037 first main iteration
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Thu, 09 Sep 2010 22:51:44 +0100 |
parents | 6caaf0256da1 |
children | e3afd1303184 |
rev | line source |
---|---|
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 { |
115
6caaf0256da1
+ interpretation of (non-assign) binary expressions
Trass3r
parents:
114
diff
changeset
|
58 return interpretCommon(istate, &Shr); |
0 | 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 { |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
115
diff
changeset
|
78 return toElemBin(irs, e1.type.isunsigned() ? OPER.OPshr : OPER.OPashr); |
0 | 79 } |
80 } | |
81 |