Mercurial > projects > ddmd
annotate dmd/MinAssignExp.d @ 178:e3afd1303184
Many small bugs fixed
Made all classes derive from TObject to detect memory leaks (functionality is disabled for now)
Began work on overriding backend memory allocations (to avoid memory leaks)
author | korDen |
---|---|
date | Sun, 17 Oct 2010 07:42:00 +0400 |
parents | 60bb0fe4563e |
children | b0d41ff5e0df |
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 { | |
178 | 27 register(); |
0 | 28 super(loc, TOK.TOKminass, MinAssignExp.sizeof, e1, e2); |
29 } | |
30 | |
72 | 31 override Expression semantic(Scope sc) |
0 | 32 { |
33 Expression e; | |
34 | |
35 if (type) | |
36 return this; | |
37 | |
38 BinExp.semantic(sc); | |
39 e2 = resolveProperties(sc, e2); | |
40 | |
41 e = op_overload(sc); | |
42 if (e) | |
43 return e; | |
44 | |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
45 if (e1.op == TOKarraylength) |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
46 { |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
47 e = ArrayLengthExp.rewriteOpAssign(this); |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
48 e = e.semantic(sc); |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
49 return e; |
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 |
0 | 52 if (e1.op == TOKslice) |
53 { // T[] -= ... | |
54 typeCombine(sc); | |
55 type = e1.type; | |
56 return arrayOp(sc); | |
57 } | |
58 | |
59 e1 = e1.modifiableLvalue(sc, e1); | |
60 e1.checkScalar(); | |
61 e1.checkNoBool(); | |
62 if (e1.type.ty == Tpointer && e2.type.isintegral()) | |
63 e = scaleFactor(sc); | |
64 else | |
65 { | |
66 e1 = e1.checkArithmetic(); | |
67 e2 = e2.checkArithmetic(); | |
73 | 68 checkComplexAddAssign(); |
0 | 69 type = e1.type; |
70 typeCombine(sc); | |
71 if (type.isreal() || type.isimaginary()) | |
72 { | |
73 assert(e2.type.isfloating()); | |
74 e2 = e2.castTo(sc, e1.type); | |
75 } | |
76 e = this; | |
77 } | |
78 return e; | |
79 } | |
80 | |
72 | 81 override Expression interpret(InterState istate) |
0 | 82 { |
117 | 83 return interpretAssignCommon(istate, &Min); |
0 | 84 } |
85 | |
72 | 86 override void buildArrayIdent(OutBuffer buf, Expressions arguments) |
0 | 87 { |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
88 AssignExp_buildArrayIdent(buf, arguments, "Min"); |
0 | 89 } |
90 | |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
91 override Expression buildArrayLoop(Parameters fparams) |
0 | 92 { |
123 | 93 return AssignExp_buildArrayLoop!(typeof(this))(fparams); |
0 | 94 } |
95 | |
72 | 96 override Identifier opId() /* For operator overloading */ |
0 | 97 { |
98 return Id.subass; | |
99 } | |
100 | |
72 | 101 override elem* toElem(IRState* irs) |
0 | 102 { |
103 return toElemBin(irs,OPminass); | |
104 } | |
72 | 105 } |