Mercurial > projects > ddmd
annotate dmd/ShlExp.d @ 162:438eaa11eed4
updated build script to use dmd2.039
some missing methods implemented
author | korDen |
---|---|
date | Tue, 21 Sep 2010 14:59:56 +0400 |
parents | 6caaf0256da1 |
children | e3afd1303184 |
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 | |
0 | 23 class ShlExp : BinExp |
24 { | |
25 this(Loc loc, Expression e1, Expression e2) | |
26 { | |
27 super(loc, TOK.TOKshl, ShlExp.sizeof, e1, e2); | |
28 } | |
29 | |
72 | 30 override Expression semantic(Scope sc) |
0 | 31 { |
32 Expression e; | |
33 | |
34 //printf("ShlExp.semantic(), type = %p\n", type); | |
35 if (!type) | |
36 { | |
37 BinExp.semanticp(sc); | |
38 e = op_overload(sc); | |
39 | |
40 if (e) | |
41 return e; | |
42 | |
43 e1 = e1.checkIntegral(); | |
44 e2 = e2.checkIntegral(); | |
45 e1 = e1.integralPromotions(sc); | |
46 e2 = e2.castTo(sc, Type.tshiftcnt); | |
47 type = e1.type; | |
48 } | |
49 | |
50 return this; | |
51 } | |
52 | |
72 | 53 override Expression optimize(int result) |
0 | 54 { |
55 //printf("ShlExp::optimize(result = %d) %s\n", result, toChars()); | |
56 return shift_optimize(result, this, &Shl); | |
57 } | |
58 | |
72 | 59 override Expression interpret(InterState istate) |
0 | 60 { |
115
6caaf0256da1
+ interpretation of (non-assign) binary expressions
Trass3r
parents:
114
diff
changeset
|
61 return interpretCommon(istate, &Shl); |
0 | 62 } |
63 | |
72 | 64 override IntRange getIntRange() |
0 | 65 { |
162 | 66 IntRange ir; |
67 IntRange ir1 = e1.getIntRange(); | |
68 IntRange ir2 = e2.getIntRange(); | |
69 | |
70 ir.imin = getMask(ir1.imin) << ir2.imin; | |
71 ir.imax = getMask(ir1.imax) << ir2.imax; | |
72 | |
73 ir.imin &= type.sizemask(); | |
74 ir.imax &= type.sizemask(); | |
75 | |
76 //printf("ShlExp: imin = x%llx, imax = x%llx\n", ir.imin, ir.imax); | |
77 //e1.dump(0); | |
78 | |
79 return ir; | |
0 | 80 } |
81 | |
72 | 82 override Identifier opId() |
0 | 83 { |
84 return Id.shl; | |
85 } | |
86 | |
72 | 87 override Identifier opId_r() |
0 | 88 { |
89 return Id.shl_r; | |
90 } | |
91 | |
72 | 92 override elem* toElem(IRState* irs) |
0 | 93 { |
94 return toElemBin(irs, OPER.OPshl); | |
95 } | |
96 } | |
97 |