Mercurial > projects > ddmd
annotate dmd/UshrExp.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 | af1bebfd96a4 |
children | b0d41ff5e0df |
rev | line source |
---|---|
72 | 1 module dmd.UshrExp; |
2 | |
114 | 3 import dmd.common; |
72 | 4 import dmd.Expression; |
5 import dmd.Identifier; | |
6 import dmd.InterState; | |
7 import dmd.Loc; | |
0 | 8 import dmd.Scope; |
72 | 9 import dmd.Id; |
10 import dmd.IntRange; | |
11 import dmd.IRState; | |
12 import dmd.BinExp; | |
0 | 13 import dmd.TOK; |
72 | 14 import dmd.Type; |
15 | |
0 | 16 import dmd.backend.elem; |
17 import dmd.backend.OPER; | |
18 import dmd.backend.TYFL; | |
19 import dmd.backend.Util; | |
20 import dmd.expression.Util; | |
21 import dmd.expression.Ushr; | |
72 | 22 import dmd.expression.shift_optimize; |
23 | |
0 | 24 class UshrExp : BinExp |
25 { | |
26 this(Loc loc, Expression e1, Expression e2) | |
27 { | |
178 | 28 register(); |
0 | 29 super(loc, TOK.TOKushr, UshrExp.sizeof, e1, e2); |
30 } | |
31 | |
72 | 32 override Expression semantic(Scope sc) |
0 | 33 { |
34 Expression e; | |
35 | |
36 if (!type) | |
37 { | |
38 BinExp.semanticp(sc); | |
39 e = op_overload(sc); | |
40 if (e) | |
41 return e; | |
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("UshrExp.optimize(result = %d) %s\n", result, toChars()); | |
54 return shift_optimize(result, this, &Ushr); | |
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, &Ushr); |
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.ushr; | |
70 } | |
71 | |
72 | 72 override Identifier opId_r() |
0 | 73 { |
74 return Id.ushr_r; | |
75 } | |
76 | |
72 | 77 override elem* toElem(IRState* irs) |
0 | 78 { |
135 | 79 //return toElemBin(irs, OPER.OPshr); |
80 elem *eleft = e1.toElem(irs); | |
81 eleft.Ety = touns(eleft.Ety); | |
82 elem *eright = e2.toElem(irs); | |
83 elem *e = el_bin(OPER.OPshr, type.totym(), eleft, eright); | |
84 el_setLoc(e, loc); | |
85 return e; | |
0 | 86 } |
115
6caaf0256da1
+ interpretation of (non-assign) binary expressions
Trass3r
parents:
114
diff
changeset
|
87 } |