Mercurial > projects > ddmd
annotate dmd/ShlExp.d @ 192:eb38fdcb3e62 default tip
updated to compile with dmd2.062
author | korDen |
---|---|
date | Sat, 02 Mar 2013 01:25:52 -0800 |
parents | b0d41ff5e0df |
children |
rev | line source |
---|---|
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; | |
162 | 19 import dmd.expression.Util; |
0 | 20 |
72 | 21 import dmd.backend.OPER; |
22 | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
23 import dmd.DDMDExtensions; |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
24 |
0 | 25 class ShlExp : BinExp |
26 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
27 mixin insertMemberExtension!(typeof(this)); |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
28 |
0 | 29 this(Loc loc, Expression e1, Expression e2) |
30 { | |
178 | 31 register(); |
0 | 32 super(loc, TOK.TOKshl, ShlExp.sizeof, e1, e2); |
33 } | |
34 | |
72 | 35 override Expression semantic(Scope sc) |
0 | 36 { |
37 Expression e; | |
38 | |
39 //printf("ShlExp.semantic(), type = %p\n", type); | |
40 if (!type) | |
41 { | |
42 BinExp.semanticp(sc); | |
43 e = op_overload(sc); | |
44 | |
45 if (e) | |
46 return e; | |
47 | |
48 e1 = e1.checkIntegral(); | |
49 e2 = e2.checkIntegral(); | |
50 e1 = e1.integralPromotions(sc); | |
51 e2 = e2.castTo(sc, Type.tshiftcnt); | |
52 type = e1.type; | |
53 } | |
54 | |
55 return this; | |
56 } | |
57 | |
72 | 58 override Expression optimize(int result) |
0 | 59 { |
60 //printf("ShlExp::optimize(result = %d) %s\n", result, toChars()); | |
61 return shift_optimize(result, this, &Shl); | |
62 } | |
63 | |
72 | 64 override Expression interpret(InterState istate) |
0 | 65 { |
115
6caaf0256da1
+ interpretation of (non-assign) binary expressions
Trass3r
parents:
114
diff
changeset
|
66 return interpretCommon(istate, &Shl); |
0 | 67 } |
68 | |
72 | 69 override IntRange getIntRange() |
0 | 70 { |
162 | 71 IntRange ir; |
72 IntRange ir1 = e1.getIntRange(); | |
73 IntRange ir2 = e2.getIntRange(); | |
74 | |
75 ir.imin = getMask(ir1.imin) << ir2.imin; | |
76 ir.imax = getMask(ir1.imax) << ir2.imax; | |
77 | |
78 ir.imin &= type.sizemask(); | |
79 ir.imax &= type.sizemask(); | |
80 | |
81 //printf("ShlExp: imin = x%llx, imax = x%llx\n", ir.imin, ir.imax); | |
82 //e1.dump(0); | |
83 | |
84 return ir; | |
0 | 85 } |
86 | |
72 | 87 override Identifier opId() |
0 | 88 { |
89 return Id.shl; | |
90 } | |
91 | |
72 | 92 override Identifier opId_r() |
0 | 93 { |
94 return Id.shl_r; | |
95 } | |
96 | |
72 | 97 override elem* toElem(IRState* irs) |
0 | 98 { |
99 return toElemBin(irs, OPER.OPshl); | |
100 } | |
101 } | |
102 |