Mercurial > projects > ddmd
annotate dmd/MulAssignExp.d @ 168:ceed63f310fb
stringtable, stringbuffer and freelist moved to Global
author | korDen |
---|---|
date | Thu, 30 Sep 2010 12:57:13 +0400 |
parents | 60bb0fe4563e |
children | e3afd1303184 |
rev | line source |
---|---|
0 | 1 module dmd.MulAssignExp; |
2 | |
114 | 3 import dmd.common; |
0 | 4 import dmd.BinExp; |
5 import dmd.Loc; | |
6 import dmd.Expression; | |
7 import dmd.Scope; | |
8 import dmd.InterState; | |
9 import dmd.OutBuffer; | |
10 import dmd.Id; | |
11 import dmd.ArrayTypes; | |
12 import dmd.Identifier; | |
13 import dmd.IRState; | |
14 import dmd.TOK; | |
15 import dmd.Type; | |
16 import dmd.TY; | |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
17 import dmd.ArrayLengthExp; |
0 | 18 |
19 import dmd.backend.elem; | |
20 import dmd.backend.OPER; | |
117 | 21 import dmd.expression.Mul; |
0 | 22 import dmd.expression.Util; |
23 | |
24 class MulAssignExp : BinExp | |
25 { | |
26 this(Loc loc, Expression e1, Expression e2) | |
27 { | |
28 super(loc, TOK.TOKmulass, MulAssignExp.sizeof, e1, e2); | |
29 } | |
30 | |
72 | 31 override Expression semantic(Scope sc) |
0 | 32 { |
33 Expression e; | |
34 | |
35 BinExp.semantic(sc); | |
36 e2 = resolveProperties(sc, e2); | |
37 | |
38 e = op_overload(sc); | |
39 if (e) | |
40 return e; | |
41 | |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
42 version(DMDV2) { |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
43 if (e1.op == TOK.TOKarraylength) |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
44 { |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
45 e = ArrayLengthExp.rewriteOpAssign(this); |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
46 e = e.semantic(sc); |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
47 return e; |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
48 } |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
49 } |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
50 |
0 | 51 if (e1.op == TOKslice) |
52 { // T[] -= ... | |
53 typeCombine(sc); | |
54 type = e1.type; | |
55 return arrayOp(sc); | |
56 } | |
57 | |
58 e1 = e1.modifiableLvalue(sc, e1); | |
59 e1.checkScalar(); | |
60 e1.checkNoBool(); | |
61 type = e1.type; | |
62 typeCombine(sc); | |
63 e1.checkArithmetic(); | |
64 e2.checkArithmetic(); | |
73 | 65 checkComplexMulAssign(); |
0 | 66 if (e2.type.isfloating()) |
67 { | |
68 Type t1; | |
69 Type t2; | |
70 | |
71 t1 = e1.type; | |
72 t2 = e2.type; | |
73 if (t1.isreal()) | |
74 { | |
75 if (t2.isimaginary() || t2.iscomplex()) | |
76 { | |
77 e2 = e2.castTo(sc, t1); | |
78 } | |
79 } | |
80 else if (t1.isimaginary()) | |
81 { | |
82 if (t2.isimaginary() || t2.iscomplex()) | |
83 { | |
84 switch (t1.ty) | |
85 { | |
86 case Timaginary32: t2 = Type.tfloat32; break; | |
87 case Timaginary64: t2 = Type.tfloat64; break; | |
88 case Timaginary80: t2 = Type.tfloat80; break; | |
89 default: | |
90 assert(0); | |
91 } | |
92 e2 = e2.castTo(sc, t2); | |
93 } | |
94 } | |
95 } | |
96 return this; | |
97 } | |
98 | |
72 | 99 override Expression interpret(InterState istate) |
0 | 100 { |
117 | 101 return interpretAssignCommon(istate, &Mul); |
0 | 102 } |
103 | |
72 | 104 override void buildArrayIdent(OutBuffer buf, Expressions arguments) |
0 | 105 { |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
106 AssignExp_buildArrayIdent(buf, arguments, "Mul"); |
0 | 107 } |
108 | |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
109 override Expression buildArrayLoop(Parameters fparams) |
0 | 110 { |
123 | 111 return AssignExp_buildArrayLoop!(typeof(this))(fparams); |
0 | 112 } |
113 | |
72 | 114 override Identifier opId() /* For operator overloading */ |
0 | 115 { |
116 return Id.mulass; | |
117 } | |
118 | |
72 | 119 override elem* toElem(IRState* irs) |
0 | 120 { |
121 return toElemBin(irs,OPmulass); | |
122 } | |
72 | 123 } |