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