Mercurial > projects > ddmd
annotate dmd/ShrExp.d @ 178:e3afd1303184
Many small bugs fixed
Made all classes derive from TObject to detect memory leaks (functionality is disabled for now)
Began work on overriding backend memory allocations (to avoid memory leaks)
author | korDen |
---|---|
date | Sun, 17 Oct 2010 07:42:00 +0400 |
parents | 60bb0fe4563e |
children | b0d41ff5e0df |
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 { | |
178 | 26 register(); |
0 | 27 super(loc, TOK.TOKshr, ShrExp.sizeof, e1, e2); |
28 } | |
29 | |
72 | 30 override Expression semantic(Scope sc) |
0 | 31 { |
32 Expression e; | |
33 | |
34 if (!type) | |
35 { | |
36 BinExp.semanticp(sc); | |
37 e = op_overload(sc); | |
38 | |
39 if (e) | |
40 return e; | |
41 | |
42 e1 = e1.checkIntegral(); | |
43 e2 = e2.checkIntegral(); | |
44 e1 = e1.integralPromotions(sc); | |
45 e2 = e2.castTo(sc, Type.tshiftcnt); | |
46 type = e1.type; | |
47 } | |
48 return this; | |
49 } | |
50 | |
72 | 51 override Expression optimize(int result) |
0 | 52 { |
53 //printf("ShrExp::optimize(result = %d) %s\n", result, toChars()); | |
54 return shift_optimize(result, this, &Shr); | |
55 } | |
56 | |
72 | 57 override Expression interpret(InterState istate) |
0 | 58 { |
115
6caaf0256da1
+ interpretation of (non-assign) binary expressions
Trass3r
parents:
114
diff
changeset
|
59 return interpretCommon(istate, &Shr); |
0 | 60 } |
61 | |
72 | 62 override IntRange getIntRange() |
0 | 63 { |
64 assert(false); | |
65 } | |
66 | |
72 | 67 override Identifier opId() |
0 | 68 { |
69 return Id.shr; | |
70 } | |
71 | |
72 | 72 override Identifier opId_r() |
0 | 73 { |
74 return Id.shr_r; | |
75 } | |
76 | |
72 | 77 override elem* toElem(IRState* irs) |
0 | 78 { |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
115
diff
changeset
|
79 return toElemBin(irs, e1.type.isunsigned() ? OPER.OPshr : OPER.OPashr); |
0 | 80 } |
81 } | |
82 |