comparison dmd/MulAssignExp.d @ 0:10317f0c89a5

Initial commit
author korDen
date Sat, 24 Oct 2009 08:42:06 +0400
parents
children 832f71e6f96c
comparison
equal deleted inserted replaced
-1:000000000000 0:10317f0c89a5
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
28 Expression semantic(Scope sc)
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();
53 if (e2.type.isfloating())
54 {
55 Type t1;
56 Type t2;
57
58 t1 = e1.type;
59 t2 = e2.type;
60 if (t1.isreal())
61 {
62 if (t2.isimaginary() || t2.iscomplex())
63 {
64 e2 = e2.castTo(sc, t1);
65 }
66 }
67 else if (t1.isimaginary())
68 {
69 if (t2.isimaginary() || t2.iscomplex())
70 {
71 switch (t1.ty)
72 {
73 case Timaginary32: t2 = Type.tfloat32; break;
74 case Timaginary64: t2 = Type.tfloat64; break;
75 case Timaginary80: t2 = Type.tfloat80; break;
76 default:
77 assert(0);
78 }
79 e2 = e2.castTo(sc, t2);
80 }
81 }
82 }
83 return this;
84 }
85
86 Expression interpret(InterState* istate)
87 {
88 assert(false);
89 }
90
91 void buildArrayIdent(OutBuffer buf, Expressions arguments)
92 {
93 assert(false);
94 }
95
96 Expression buildArrayLoop(Arguments fparams)
97 {
98 assert(false);
99 }
100
101 Identifier opId() /* For operator overloading */
102 {
103 return Id.mulass;
104 }
105
106 elem* toElem(IRState* irs)
107 {
108 return toElemBin(irs,OPmulass);
109 }
110 }