Mercurial > projects > ddmd
annotate dmd/MulExp.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 | cab4c37afb89 |
children | ceda59b4d255 |
rev | line source |
---|---|
72 | 1 module dmd.MulExp; |
2 | |
3 import dmd.Expression; | |
4 import dmd.Identifier; | |
5 import dmd.backend.elem; | |
6 import dmd.InterState; | |
0 | 7 import dmd.OutBuffer; |
72 | 8 import dmd.NegExp; |
9 import dmd.Loc; | |
0 | 10 import dmd.Id; |
72 | 11 import dmd.Scope; |
12 import dmd.IRState; | |
13 import dmd.BinExp; | |
14 import dmd.ArrayTypes; | |
0 | 15 import dmd.TOK; |
16 import dmd.Type; | |
17 import dmd.TY; | |
18 | |
19 import dmd.expression.Util; | |
20 import dmd.expression.Mul; | |
21 import dmd.backend.OPER; | |
72 | 22 import dmd.backend.Util; |
23 | |
0 | 24 class MulExp : BinExp |
25 { | |
26 this(Loc loc, Expression e1, Expression e2) | |
72 | 27 { |
0 | 28 super(loc, TOK.TOKmul, MulExp.sizeof, e1, e2); |
29 } | |
30 | |
72 | 31 override Expression semantic(Scope sc) |
0 | 32 { |
33 Expression e; | |
34 | |
35 static if (false) { | |
36 printf("MulExp.semantic() %s\n", toChars()); | |
37 } | |
38 if (type) | |
39 { | |
40 return this; | |
41 } | |
42 | |
43 BinExp.semanticp(sc); | |
44 e = op_overload(sc); | |
45 if (e) | |
46 return e; | |
47 | |
48 typeCombine(sc); | |
49 if (e1.op != TOKslice && e2.op != TOKslice) | |
50 { | |
51 e1.checkArithmetic(); | |
52 e2.checkArithmetic(); | |
53 } | |
54 if (type.isfloating()) | |
55 { | |
56 Type t1 = e1.type; | |
57 Type t2 = e2.type; | |
58 | |
59 if (t1.isreal()) | |
60 { | |
61 type = t2; | |
62 } | |
63 else if (t2.isreal()) | |
64 { | |
65 type = t1; | |
66 } | |
67 else if (t1.isimaginary()) | |
68 { | |
69 if (t2.isimaginary()) | |
70 { | |
71 switch (t1.ty) | |
72 { | |
73 case Timaginary32: type = Type.tfloat32; break; | |
74 case Timaginary64: type = Type.tfloat64; break; | |
75 case Timaginary80: type = Type.tfloat80; break; | |
76 default: assert(0); | |
77 } | |
78 | |
79 // iy * iv = -yv | |
80 e1.type = type; | |
81 e2.type = type; | |
82 Expression ee = new NegExp(loc, this); | |
83 ee = ee.semantic(sc); | |
84 return ee; | |
85 } | |
86 else | |
87 type = t2; // t2 is complex | |
88 } | |
89 else if (t2.isimaginary()) | |
90 { | |
91 type = t1; // t1 is complex | |
92 } | |
93 } | |
94 return this; | |
95 } | |
96 | |
72 | 97 override Expression optimize(int result) |
0 | 98 { |
99 Expression e; | |
100 | |
101 //printf("MulExp.optimize(result = %d) %s\n", result, toChars()); | |
102 e1 = e1.optimize(result); | |
103 e2 = e2.optimize(result); | |
104 if (e1.isConst() == 1 && e2.isConst() == 1) | |
105 { | |
106 e = Mul(type, e1, e2); | |
107 } | |
108 else | |
109 e = this; | |
110 return e; | |
111 } | |
112 | |
72 | 113 override Expression interpret(InterState istate) |
0 | 114 { |
115 assert(false); | |
116 } | |
117 | |
72 | 118 override void buildArrayIdent(OutBuffer buf, Expressions arguments) |
0 | 119 { |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
120 Exp_buildArrayIdent(buf, arguments, "Mul"); |
0 | 121 } |
122 | |
72 | 123 override Expression buildArrayLoop(Arguments fparams) |
0 | 124 { |
72 | 125 /* Evaluate assign expressions left to right |
126 */ | |
127 Expression ex1 = e1.buildArrayLoop(fparams); | |
128 Expression ex2 = e2.buildArrayLoop(fparams); | |
129 Expression e = new MulExp(Loc(0), ex1, ex2); | |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
130 return e; |
0 | 131 } |
132 | |
72 | 133 override bool isCommutative() |
0 | 134 { |
135 return true; | |
136 } | |
137 | |
72 | 138 override Identifier opId() |
0 | 139 { |
140 return Id.mul; | |
141 } | |
142 | |
72 | 143 override Identifier opId_r() |
0 | 144 { |
145 return Id.mul_r; | |
146 } | |
147 | |
72 | 148 override elem* toElem(IRState* irs) |
0 | 149 { |
150 return toElemBin(irs,OPmul); | |
151 } | |
152 } | |
153 |