annotate dmd/CatExp.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 e28b18c23469
children e8a741997ccf
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.CatExp;
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: 72
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.InterState;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
7 import dmd.Loc;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
8 import dmd.Scope;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
9 import dmd.IRState;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
10 import dmd.BinExp;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.TOK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.TY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.MATCH;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.ArrayLiteralExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.StringExp;
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
17 import dmd.ErrorExp;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.WANT;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.Id;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
20 import dmd.GlobalExpressions;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
21
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 import dmd.backend.elem;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 import dmd.backend.TYM;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 import dmd.backend.OPER;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 import dmd.backend.RTLSYM;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 import dmd.codegen.Util;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
28 import dmd.expression.Cat;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
29
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 class CatExp : BinExp
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 this(Loc loc, Expression e1, Expression e2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 super(loc, TOK.TOKcat, CatExp.sizeof, e1, e2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
37 override Expression semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 //printf("CatExp.semantic() %s\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 if (!type)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 BinExp.semanticp(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 e = op_overload(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 if (e)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 Type tb1 = e1.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 Type tb2 = e2.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 /* BUG: Should handle things like:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 * char c;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 * c ~ ' '
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 * ' ' ~ c;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 e1.type.print();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 e2.type.print();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 }
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
63 Type tb1next = tb1.nextOf();
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
64 Type tb2next = tb2.nextOf();
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
65
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 if ((tb1.ty == Tsarray || tb1.ty == Tarray) &&
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
67 e2.implicitConvTo(tb1next) >= MATCHconvert)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 {
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
69 e2 = e2.implicitCastTo(sc, tb1next);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 if (tb2.ty == Tarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 // Make e2 into [e2]
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 e2 = new ArrayLiteralExp(e2.loc, e2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 e2.type = type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 else if ((tb2.ty == Tsarray || tb2.ty == Tarray) &&
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
79 e1.implicitConvTo(tb2next) >= MATCHconvert)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 {
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
81 e1 = e1.implicitCastTo(sc, tb2next);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 if (tb1.ty == Tarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 // Make e1 into [e1]
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 e1 = new ArrayLiteralExp(e1.loc, e1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 e1.type = type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 if ((tb1.ty == Tsarray || tb1.ty == Tarray) &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 (tb2.ty == Tsarray || tb2.ty == Tarray) &&
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
93 (tb1next.mod || tb2next.mod) &&
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
94 (tb1next.mod != tb2next.mod)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 {
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
97 Type t1 = tb1next.mutableOf().constOf().arrayOf();
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
98 Type t2 = tb2next.mutableOf().constOf().arrayOf();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 if (e1.op == TOKstring && !(cast(StringExp)e1).committed)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 e1.type = t1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 e1 = e1.castTo(sc, t1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 if (e2.op == TOKstring && !(cast(StringExp)e2).committed)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 e2.type = t2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 e2 = e2.castTo(sc, t2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 typeCombine(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 type = type.toHeadMutable();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 Type tb = type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 if (tb.ty == Tsarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 type = tb.nextOf().arrayOf();
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
115 if (type.ty == Tarray && tb1next && tb2next &&
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
116 tb1next.mod != tb2next.mod)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 type = type.nextOf().toHeadMutable().arrayOf();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 e1.type.print();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 e2.type.print();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 type.print();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 print();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 Type t1 = e1.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 Type t2 = e2.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 if (e1.op == TOKstring && e2.op == TOKstring)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 e = optimize(WANTvalue);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 else if ((t1.ty == Tarray || t1.ty == Tsarray) &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 (t2.ty == Tarray || t2.ty == Tsarray))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 e = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 //printf("(%s) ~ (%s)\n", e1.toChars(), e2.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 error("Can only concatenate arrays, not (%s ~ %s)",
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 e1.type.toChars(), e2.type.toChars());
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
140 return new ErrorExp();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 e.type = e.type.semantic(loc, sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 return this;
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 optimize(int result)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 //printf("CatExp::optimize(%d) %s\n", result, toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 e1 = e1.optimize(result);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 e2 = e2.optimize(result);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 Expression e = Cat(type, e1, e2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 if (e is EXP_CANT_INTERPRET)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 e = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
160 override Expression interpret(InterState istate)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 {
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
162 Expression e;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
163 Expression e1;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
164 Expression e2;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
165
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
166 version (LOG) {
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
167 printf("CatExp.interpret() %.*s\n", toChars());
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
168 }
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
169 e1 = this.e1.interpret(istate);
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
170 if (e1 is EXP_CANT_INTERPRET)
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
171 {
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
172 goto Lcant;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
173 }
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
174 e2 = this.e2.interpret(istate);
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
175 if (e2 is EXP_CANT_INTERPRET)
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
176 goto Lcant;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
177 return Cat(type, e1, e2);
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
178
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
179 Lcant:
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
180 version (LOG) {
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
181 printf("CatExp.interpret() %.*s CANT\n", toChars());
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
182 }
63
cab4c37afb89 A bunch of implementations
korDen
parents: 0
diff changeset
183 return EXP_CANT_INTERPRET;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
186 override Identifier opId()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 return Id.cat;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
191 override Identifier opId_r()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 return Id.cat_r;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
196 override elem* toElem(IRState* irs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 elem *e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 printf("CatExp::toElem()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 print();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 Type tb1 = e1.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 Type tb2 = e2.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 Type tn;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 ///static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 /// if ((tb1.ty == Tarray || tb1.ty == Tsarray) &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 /// (tb2.ty == Tarray || tb2.ty == Tsarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 /// )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 ///}
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 Type ta = tb1.nextOf() ? e1.type : e2.type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 tn = tb1.nextOf() ? tb1.nextOf() : tb2.nextOf();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 if (e1.op == TOKcat)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 elem* ep;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 CatExp ce = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 int n = 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 ep = eval_Darray(irs, ce.e2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 do
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 n++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 ce = cast(CatExp)ce.e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 ep = el_param(ep, eval_Darray(irs, ce.e2));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 } while (ce.e1.op == TOKcat);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 ep = el_param(ep, eval_Darray(irs, ce.e1));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 static if (true) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 ep = el_params(
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 ep,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 el_long(TYint, n),
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 ta.getTypeInfo(null).toElem(irs),
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 e = el_bin(OPcall, TYdarray, el_var(rtlsym[RTLSYM_ARRAYCATNT]), ep);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 ep = el_params(
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 ep,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 el_long(TYint, n),
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 el_long(TYint, tn.size()),
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 e = el_bin(OPcall, TYdarray, el_var(rtlsym[RTLSYM_ARRAYCATN]), ep);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 elem *e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 elem *e2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 elem *ep;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 e1 = eval_Darray(irs, this.e1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 e2 = eval_Darray(irs, this.e2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 static if (true) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 ep = el_params(e2, e1, ta.getTypeInfo(null).toElem(irs), null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 e = el_bin(OPcall, TYdarray, el_var(rtlsym[RTLSYM_ARRAYCATT]), ep);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261 ep = el_params(el_long(TYint, tn.size()), e2, e1, null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 e = el_bin(OPcall, TYdarray, el_var(rtlsym[RTLSYM_ARRAYCAT]), ep);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 el_setLoc(e,loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 /// static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 /// else if ((tb1.ty == Tarray || tb1.ty == Tsarray) &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 /// e2.type.equals(tb1.next))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 /// {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 /// error("array cat with element not implemented");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 /// e = el_long(TYint, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 /// }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274 /// else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275 /// assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 /// }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
278 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280