Mercurial > projects > ddmd
annotate dmd/XorExp.d @ 72:2e2a5c3f943a
reduced warnings by adding override to the methods
think this also normalizes different line endings used all over the place
author | Trass3r |
---|---|
date | Sat, 28 Aug 2010 16:19:48 +0200 |
parents | f708f0452e81 |
children | ceda59b4d255 |
rev | line source |
---|---|
72 | 1 module dmd.XorExp; |
2 | |
3 import dmd.Expression; | |
4 import dmd.Identifier; | |
5 import dmd.InterState; | |
0 | 6 import dmd.MATCH; |
72 | 7 import dmd.Id; |
8 import dmd.Type; | |
9 import dmd.OutBuffer; | |
10 import dmd.Loc; | |
11 import dmd.Scope; | |
12 import dmd.IntRange; | |
13 import dmd.IRState; | |
14 import dmd.ArrayTypes; | |
15 import dmd.BinExp; | |
0 | 16 import dmd.TOK; |
72 | 17 import dmd.TY; |
18 | |
19 import dmd.backend.elem; | |
67 | 20 import dmd.backend.OPER; |
0 | 21 import dmd.expression.Util; |
72 | 22 import dmd.expression.Xor; |
23 | |
0 | 24 class XorExp : BinExp |
25 { | |
26 this(Loc loc, Expression e1, Expression e2) | |
27 { | |
28 super(loc, TOK.TOKxor, XorExp.sizeof, e1, e2); | |
29 } | |
30 | |
72 | 31 override Expression semantic(Scope sc) |
0 | 32 { |
33 Expression e; | |
34 | |
35 if (!type) | |
36 { | |
37 BinExp.semanticp(sc); | |
38 e = op_overload(sc); | |
39 if (e) | |
40 return e; | |
41 if (e1.type.toBasetype().ty == Tbool && | |
42 e2.type.toBasetype().ty == Tbool) | |
43 { | |
44 type = e1.type; | |
45 e = this; | |
46 } | |
47 else | |
48 { | |
49 typeCombine(sc); | |
50 if (e1.op != TOKslice && e2.op != TOKslice) | |
51 { | |
52 e1.checkIntegral(); | |
53 e2.checkIntegral(); | |
54 } | |
55 } | |
56 } | |
57 return this; | |
58 } | |
59 | |
72 | 60 override Expression optimize(int result) |
0 | 61 { |
62 Expression e; | |
63 | |
64 e1 = e1.optimize(result); | |
65 e2 = e2.optimize(result); | |
66 if (e1.isConst() == 1 && e2.isConst() == 1) | |
67 e = Xor(type, e1, e2); | |
68 else | |
69 e = this; | |
70 | |
71 return e; | |
72 } | |
73 | |
72 | 74 override Expression interpret(InterState istate) |
0 | 75 { |
76 assert(false); | |
77 } | |
78 | |
72 | 79 override void buildArrayIdent(OutBuffer buf, Expressions arguments) |
0 | 80 { |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
81 Exp_buildArrayIdent(buf, arguments, "Xor"); |
0 | 82 } |
83 | |
72 | 84 override Expression buildArrayLoop(Arguments fparams) |
0 | 85 { |
72 | 86 /* Evaluate assign expressions left to right |
87 */ | |
88 Expression ex1 = e1.buildArrayLoop(fparams); | |
89 Expression ex2 = e2.buildArrayLoop(fparams); | |
90 Expression e = new XorExp(Loc(0), ex1, ex2); | |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
91 return e; |
0 | 92 } |
93 | |
72 | 94 override MATCH implicitConvTo(Type t) |
0 | 95 { |
72 | 96 MATCH result = Expression.implicitConvTo(t); |
97 | |
98 if (result == MATCHnomatch) | |
99 { | |
100 MATCH m1 = e1.implicitConvTo(t); | |
101 MATCH m2 = e2.implicitConvTo(t); | |
102 | |
103 // Pick the worst match | |
104 result = (m1 < m2) ? m1 : m2; | |
105 } | |
56 | 106 return result; |
0 | 107 } |
108 | |
72 | 109 override IntRange getIntRange() |
0 | 110 { |
111 assert(false); | |
112 } | |
113 | |
72 | 114 override bool isCommutative() |
0 | 115 { |
116 return true; | |
117 } | |
118 | |
72 | 119 override Identifier opId() |
0 | 120 { |
121 return Id.ixor; | |
122 } | |
123 | |
72 | 124 override Identifier opId_r() |
0 | 125 { |
126 return Id.ixor_r; | |
127 } | |
128 | |
72 | 129 override elem* toElem(IRState* irs) |
0 | 130 { |
67 | 131 return toElemBin(irs,OPxor); |
0 | 132 } |
133 } | |
134 |