annotate dmd/CmpExp.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 52188e7e3fb5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
1 module dmd.CmpExp;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 79
diff changeset
3 import dmd.common;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
4 import dmd.Expression;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
5 import dmd.Identifier;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
6 import dmd.backend.elem;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
7 import dmd.InterState;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
8 import dmd.Loc;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
9 import dmd.TOK;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
10 import dmd.Scope;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
11 import dmd.IRState;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.Id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.TY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.ErrorExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.IntegerExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.MATCH;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.BinExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.WANT;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.GlobalExpressions;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 import dmd.expression.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 import dmd.codegen.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 import dmd.expression.Cmp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 import dmd.backend.RTLSYM;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 import dmd.backend.TYM;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 import dmd.backend.OPER;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
30 import dmd.backend.rel;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
31
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
32 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
33
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 class CmpExp : BinExp
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 {
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
36 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
37
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 this(TOK op, Loc loc, Expression e1, Expression e2)
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
39 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 115
diff changeset
40 register();
e3afd1303184 Many small bugs fixed
korDen
parents: 115
diff changeset
41
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 super(loc, op, CmpExp.sizeof, e1, e2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
45 override Expression semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 version (LOGSEMANTIC) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 printf("CmpExp.semantic('%s')\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 if (type)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 BinExp.semanticp(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56
79
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
57 Type t1 = e1.type.toBasetype();
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
58 Type t2 = e2.type.toBasetype();
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
59 if (t1.ty == Tclass && e2.op == TOKnull ||
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
60 t2.ty == Tclass && e1.op == TOKnull)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 error("do not use null when comparing class types");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 e = op_overload(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 if (e)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 if (!e.type.isscalar() && e.type.equals(e1.type))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 error("recursive opCmp expansion");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 e = new ErrorExp();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 e = new CmpExp(op, loc, e, new IntegerExp(loc, 0, Type.tint32));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80
79
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
81 // Disallow comparing T[]==T and T==T[]
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
82 if (e1.op == TOKslice && t1.ty == Tarray && e2.implicitConvTo(t1.nextOf()) ||
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
83 e2.op == TOKslice && t2.ty == Tarray && e1.implicitConvTo(t2.nextOf()))
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
84 {
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
85 incompatibleTypes();
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
86 return new ErrorExp();
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
87 }
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
88
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 typeCombine(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 type = Type.tboolean;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 // Special handling for array comparisons
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 t1 = e1.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 t2 = e2.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 if ((t1.ty == Tarray || t1.ty == Tsarray || t1.ty == Tpointer) &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 (t2.ty == Tarray || t2.ty == Tsarray || t2.ty == Tpointer))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 if (t1.nextOf().implicitConvTo(t2.nextOf()) < MATCHconst &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 t2.nextOf().implicitConvTo(t1.nextOf()) < MATCHconst &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 (t1.nextOf().ty != Tvoid && t2.nextOf().ty != Tvoid))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 error("array comparison type mismatch, %s vs %s", t1.nextOf().toChars(), t2.nextOf().toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 e = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 else if (t1.ty == Tstruct || t2.ty == Tstruct ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 (t1.ty == Tclass && t2.ty == Tclass))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 if (t2.ty == Tstruct)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 error("need member function opCmp() for %s %s to compare", t2.toDsymbol(sc).kind(), t2.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 error("need member function opCmp() for %s %s to compare", t1.toDsymbol(sc).kind(), t1.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 e = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 /// static if (true) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 else if (t1.iscomplex() || t2.iscomplex())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 error("compare not defined for complex operands");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 e = new ErrorExp();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 /// }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 e1.rvalue();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 e2.rvalue();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 e = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 //printf("CmpExp: %s, type = %s\n", e.toChars(), e.type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
131 override Expression optimize(int result)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 //printf("CmpExp::optimize() %s\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 e1 = e1.optimize(WANTvalue | (result & WANTinterpret));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 e2 = e2.optimize(WANTvalue | (result & WANTinterpret));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 Expression e1 = fromConstInitializer(result, this.e1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 Expression e2 = fromConstInitializer(result, this.e2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 e = Cmp(op, type, e1, e2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 if (e is EXP_CANT_INTERPRET)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 e = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
148 override Expression interpret(InterState istate)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 {
115
6caaf0256da1 + interpretation of (non-assign) binary expressions
Trass3r
parents: 114
diff changeset
150 return interpretCommon2(istate, &Cmp);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
153 override int isBit()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
158 override bool isCommutative()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 return true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
163 override Identifier opId()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 return Id.cmp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
168 override elem* toElem(IRState* irs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 elem *e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 OPER eop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 Type t1 = e1.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 Type t2 = e2.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 switch (op)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 case TOKlt: eop = OPlt; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 case TOKgt: eop = OPgt; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 case TOKle: eop = OPle; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 case TOKge: eop = OPge; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 case TOKequal: eop = OPeqeq; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 case TOKnotequal: eop = OPne; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 // NCEG floating point compares
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 case TOKunord: eop = OPunord; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 case TOKlg: eop = OPlg; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 case TOKleg: eop = OPleg; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 case TOKule: eop = OPule; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 case TOKul: eop = OPul; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 case TOKuge: eop = OPuge; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 case TOKug: eop = OPug; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 case TOKue: eop = OPue; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 dump(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 if (!t1.isfloating())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199 // Convert from floating point compare to equivalent
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 // integral compare
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 eop = cast(OPER)rel_integral(eop);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 if (cast(int)eop > 1 && t1.ty == Tclass && t2.ty == Tclass)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 static if (true) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 elem *ec1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 elem *ec2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 ec1 = e1.toElem(irs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 ec2 = e2.toElem(irs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 e = el_bin(OPcall,TYint,el_var(rtlsym[RTLSYM_OBJ_CMP]),el_param(ec1, ec2));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214 e = el_bin(eop, TYint, e, el_long(TYint, 0));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 else if (cast(int)eop > 1 &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 (t1.ty == Tarray || t1.ty == Tsarray) &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 (t2.ty == Tarray || t2.ty == Tsarray))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 elem* ea1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 elem* ea2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 elem* ep;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 Type telement = t1.nextOf().toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 int rtlfunc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 ea1 = e1.toElem(irs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 ea1 = array_toDarray(t1, ea1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 ea2 = e2.toElem(irs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 ea2 = array_toDarray(t2, ea2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 ep = el_params(telement.arrayOf().getInternalTypeInfo(null).toElem(irs),
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 ea2, ea1, null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 rtlfunc = RTLSYM_ARRAYCMP2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 ep = el_params(telement.getInternalTypeInfo(null).toElem(irs), ea2, ea1, null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 rtlfunc = RTLSYM_ARRAYCMP;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 e = el_bin(OPcall, TYint, el_var(rtlsym[rtlfunc]), ep);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 e = el_bin(eop, TYint, e, el_long(TYint, 0));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 el_setLoc(e,loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 if (cast(int)eop <= 1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 /* The result is determinate, create:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 * (e1 , e2) , eop
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 e = toElemBin(irs,OPcomma);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 e = el_bin(OPcomma,e.Ety,e,el_long(e.Ety,cast(int)eop));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 e = toElemBin(irs,eop);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260