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