Mercurial > projects > ddmd
annotate dmd/MinAssignExp.d @ 187:b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
author | Abscissa |
---|---|
date | Tue, 07 Jun 2011 23:37:34 -0400 |
parents | e3afd1303184 |
children |
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 | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
23 import dmd.DDMDExtensions; |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
24 |
0 | 25 class MinAssignExp : BinExp |
26 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
27 mixin insertMemberExtension!(typeof(this)); |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
28 |
0 | 29 this(Loc loc, Expression e1, Expression e2) |
30 { | |
178 | 31 register(); |
0 | 32 super(loc, TOK.TOKminass, MinAssignExp.sizeof, e1, e2); |
33 } | |
34 | |
72 | 35 override Expression semantic(Scope sc) |
0 | 36 { |
37 Expression e; | |
38 | |
39 if (type) | |
40 return this; | |
41 | |
42 BinExp.semantic(sc); | |
43 e2 = resolveProperties(sc, e2); | |
44 | |
45 e = op_overload(sc); | |
46 if (e) | |
47 return e; | |
48 | |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
49 if (e1.op == TOKarraylength) |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
50 { |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
51 e = ArrayLengthExp.rewriteOpAssign(this); |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
52 e = e.semantic(sc); |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
53 return e; |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
54 } |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
55 |
0 | 56 if (e1.op == TOKslice) |
57 { // T[] -= ... | |
58 typeCombine(sc); | |
59 type = e1.type; | |
60 return arrayOp(sc); | |
61 } | |
62 | |
63 e1 = e1.modifiableLvalue(sc, e1); | |
64 e1.checkScalar(); | |
65 e1.checkNoBool(); | |
66 if (e1.type.ty == Tpointer && e2.type.isintegral()) | |
67 e = scaleFactor(sc); | |
68 else | |
69 { | |
70 e1 = e1.checkArithmetic(); | |
71 e2 = e2.checkArithmetic(); | |
73 | 72 checkComplexAddAssign(); |
0 | 73 type = e1.type; |
74 typeCombine(sc); | |
75 if (type.isreal() || type.isimaginary()) | |
76 { | |
77 assert(e2.type.isfloating()); | |
78 e2 = e2.castTo(sc, e1.type); | |
79 } | |
80 e = this; | |
81 } | |
82 return e; | |
83 } | |
84 | |
72 | 85 override Expression interpret(InterState istate) |
0 | 86 { |
117 | 87 return interpretAssignCommon(istate, &Min); |
0 | 88 } |
89 | |
72 | 90 override void buildArrayIdent(OutBuffer buf, Expressions arguments) |
0 | 91 { |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
92 AssignExp_buildArrayIdent(buf, arguments, "Min"); |
0 | 93 } |
94 | |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
95 override Expression buildArrayLoop(Parameters fparams) |
0 | 96 { |
123 | 97 return AssignExp_buildArrayLoop!(typeof(this))(fparams); |
0 | 98 } |
99 | |
72 | 100 override Identifier opId() /* For operator overloading */ |
0 | 101 { |
102 return Id.subass; | |
103 } | |
104 | |
72 | 105 override elem* toElem(IRState* irs) |
0 | 106 { |
107 return toElemBin(irs,OPminass); | |
108 } | |
72 | 109 } |