Mercurial > projects > ddmd
annotate dmd/MinAssignExp.d @ 130:60bb0fe4563e
dmdfe 2.037 first main iteration
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Thu, 09 Sep 2010 22:51:44 +0100 |
parents | 9e39c7de8438 |
children | e3afd1303184 |
rev | line source |
---|---|
0 | 1 module dmd.MinAssignExp; |
2 | |
114 | 3 import dmd.common; |
117 | 4 import dmd.expression.Min; |
0 | 5 import dmd.BinExp; |
6 import dmd.Loc; | |
7 import dmd.Expression; | |
8 import dmd.Scope; | |
9 import dmd.InterState; | |
10 import dmd.OutBuffer; | |
11 import dmd.ArrayTypes; | |
12 import dmd.Identifier; | |
13 import dmd.IRState; | |
14 import dmd.TY; | |
15 import dmd.TOK; | |
16 import dmd.Id; | |
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.Util; | |
21 import dmd.backend.OPER; | |
22 | |
23 class MinAssignExp : BinExp | |
24 { | |
25 this(Loc loc, Expression e1, Expression e2) | |
26 { | |
27 super(loc, TOK.TOKminass, MinAssignExp.sizeof, e1, e2); | |
28 } | |
29 | |
72 | 30 override Expression semantic(Scope sc) |
0 | 31 { |
32 Expression e; | |
33 | |
34 if (type) | |
35 return this; | |
36 | |
37 BinExp.semantic(sc); | |
38 e2 = resolveProperties(sc, e2); | |
39 | |
40 e = op_overload(sc); | |
41 if (e) | |
42 return e; | |
43 | |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
44 if (e1.op == TOKarraylength) |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
45 { |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
46 e = ArrayLengthExp.rewriteOpAssign(this); |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
47 e = e.semantic(sc); |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
48 return e; |
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 if (e1.type.ty == Tpointer && e2.type.isintegral()) | |
62 e = scaleFactor(sc); | |
63 else | |
64 { | |
65 e1 = e1.checkArithmetic(); | |
66 e2 = e2.checkArithmetic(); | |
73 | 67 checkComplexAddAssign(); |
0 | 68 type = e1.type; |
69 typeCombine(sc); | |
70 if (type.isreal() || type.isimaginary()) | |
71 { | |
72 assert(e2.type.isfloating()); | |
73 e2 = e2.castTo(sc, e1.type); | |
74 } | |
75 e = this; | |
76 } | |
77 return e; | |
78 } | |
79 | |
72 | 80 override Expression interpret(InterState istate) |
0 | 81 { |
117 | 82 return interpretAssignCommon(istate, &Min); |
0 | 83 } |
84 | |
72 | 85 override void buildArrayIdent(OutBuffer buf, Expressions arguments) |
0 | 86 { |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
87 AssignExp_buildArrayIdent(buf, arguments, "Min"); |
0 | 88 } |
89 | |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
90 override Expression buildArrayLoop(Parameters fparams) |
0 | 91 { |
123 | 92 return AssignExp_buildArrayLoop!(typeof(this))(fparams); |
0 | 93 } |
94 | |
72 | 95 override Identifier opId() /* For operator overloading */ |
0 | 96 { |
97 return Id.subass; | |
98 } | |
99 | |
72 | 100 override elem* toElem(IRState* irs) |
0 | 101 { |
102 return toElemBin(irs,OPminass); | |
103 } | |
72 | 104 } |