Mercurial > projects > ddmd
annotate dmd/DivAssignExp.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 | ef02e2e203c2 |
rev | line source |
---|---|
0 | 1 module dmd.DivAssignExp; |
2 | |
3 import dmd.BinExp; | |
4 import dmd.Loc; | |
5 import dmd.Expression; | |
6 import dmd.Scope; | |
7 import dmd.InterState; | |
8 import dmd.OutBuffer; | |
9 import dmd.ArrayTypes; | |
10 import dmd.Identifier; | |
11 import dmd.IRState; | |
12 import dmd.TOK; | |
13 import dmd.Type; | |
14 import dmd.TY; | |
15 import dmd.Id; | |
16 import dmd.CommaExp; | |
17 import dmd.RealExp; | |
18 import dmd.AssignExp; | |
19 | |
20 import dmd.backend.elem; | |
21 import dmd.backend.OPER; | |
22 import dmd.backend.Util; | |
23 import dmd.expression.Util; | |
24 | |
25 class DivAssignExp : BinExp | |
26 { | |
27 this(Loc loc, Expression e1, Expression e2) | |
28 { | |
29 super(loc, TOK.TOKdivass, DivAssignExp.sizeof, e1, e2); | |
30 } | |
31 | |
72 | 32 override Expression semantic(Scope sc) |
0 | 33 { |
34 Expression e; | |
35 | |
36 BinExp.semantic(sc); | |
37 e2 = resolveProperties(sc, e2); | |
38 | |
39 e = op_overload(sc); | |
40 if (e) | |
41 return e; | |
42 | |
43 if (e1.op == TOKslice) | |
44 { // T[] -= ... | |
45 typeCombine(sc); | |
46 type = e1.type; | |
47 return arrayOp(sc); | |
48 } | |
49 | |
50 e1 = e1.modifiableLvalue(sc, e1); | |
51 e1.checkScalar(); | |
52 e1.checkNoBool(); | |
53 type = e1.type; | |
54 typeCombine(sc); | |
55 e1.checkArithmetic(); | |
56 e2.checkArithmetic(); | |
57 if (e2.type.isimaginary()) | |
58 { | |
59 Type t1; | |
60 Type t2; | |
61 | |
62 t1 = e1.type; | |
63 if (t1.isreal()) | |
64 { | |
65 // x/iv = i(-x/v) | |
66 // Therefore, the result is 0 | |
67 e2 = new CommaExp(loc, e2, new RealExp(loc, 0, t1)); | |
68 e2.type = t1; | |
69 e = new AssignExp(loc, e1, e2); | |
70 e.type = t1; | |
71 return e; | |
72 } | |
73 else if (t1.isimaginary()) | |
74 { | |
75 Expression e3; | |
76 | |
77 switch (t1.ty) | |
78 { | |
79 case Timaginary32: t2 = Type.tfloat32; break; | |
80 case Timaginary64: t2 = Type.tfloat64; break; | |
81 case Timaginary80: t2 = Type.tfloat80; break; | |
82 default: | |
83 assert(0); | |
84 } | |
85 e2 = e2.castTo(sc, t2); | |
86 e3 = new AssignExp(loc, e1, e2); | |
87 e3.type = t1; | |
88 return e3; | |
89 } | |
90 } | |
91 return this; | |
92 } | |
93 | |
72 | 94 override Expression interpret(InterState istate) |
0 | 95 { |
96 assert(false); | |
97 } | |
98 | |
72 | 99 override void buildArrayIdent(OutBuffer buf, Expressions arguments) |
0 | 100 { |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
101 AssignExp_buildArrayIdent(buf, arguments, "Div"); |
0 | 102 } |
103 | |
72 | 104 override Expression buildArrayLoop(Arguments fparams) |
0 | 105 { |
106 assert(false); | |
107 } | |
108 | |
72 | 109 override Identifier opId() /* For operator overloading */ |
0 | 110 { |
111 return Id.divass; | |
112 } | |
113 | |
72 | 114 override elem* toElem(IRState* irs) |
0 | 115 { |
116 return toElemBin(irs,OPdivass); | |
117 } | |
72 | 118 } |