comparison dmd/expression/Cat.d @ 84:be2ab491772e

Expressions -> Vector!Expression
author Eldar Insafutdinov <e.insafutdinov@gmail.com>
date Mon, 30 Aug 2010 16:12:19 +0100
parents 544b922227c7
children e28b18c23469
comparison
equal deleted inserted replaced
83:ee670dd808a8 84:be2ab491772e
65 e = es; 65 e = es;
66 } 66 }
67 else 67 else
68 { 68 {
69 // Create an ArrayLiteralExp 69 // Create an ArrayLiteralExp
70 Expressions elements = new Expressions(); 70 auto elements = new Expressions();
71 elements.push(cast(void*)e); 71 elements.push(e);
72 e = new ArrayLiteralExp(e.loc, elements); 72 e = new ArrayLiteralExp(e.loc, elements);
73 } 73 }
74 e.type = type; 74 e.type = type;
75 return e; 75 return e;
76 } 76 }
77 else if (e1.op == TOKstring && e2.op == TOKstring) 77 else if (e1.op == TOKstring && e2.op == TOKstring)
78 { 78 {
79 // Concatenate the strings 79 // Concatenate the strings
80 StringExp es1 = cast(StringExp)e1; 80 auto es1 = cast(StringExp)e1;
81 StringExp es2 = cast(StringExp)e2; 81 auto es2 = cast(StringExp)e2;
82 82
83 size_t len = es1.len + es2.len; 83 size_t len = es1.len + es2.len;
84 int sz = es1.sz; 84 int sz = es1.sz;
85 85
86 if (sz != es2.sz) 86 if (sz != es2.sz)
205 { 205 {
206 ArrayLiteralExp es1; 206 ArrayLiteralExp es1;
207 if (e1.op == TOKarrayliteral) 207 if (e1.op == TOKarrayliteral)
208 { es1 = cast(ArrayLiteralExp)e1; 208 { es1 = cast(ArrayLiteralExp)e1;
209 es1 = new ArrayLiteralExp(es1.loc, cast(Expressions)es1.elements.copy()); 209 es1 = new ArrayLiteralExp(es1.loc, cast(Expressions)es1.elements.copy());
210 es1.elements.push(cast(void*)e2); 210 es1.elements.push(e2);
211 } 211 }
212 else 212 else
213 { 213 {
214 es1 = new ArrayLiteralExp(e1.loc, e2); 214 es1 = new ArrayLiteralExp(e1.loc, e2);
215 } 215 }
227 e2.type.toBasetype().nextOf().equals(e1.type)) 227 e2.type.toBasetype().nextOf().equals(e1.type))
228 { 228 {
229 ArrayLiteralExp es2 = cast(ArrayLiteralExp)e2; 229 ArrayLiteralExp es2 = cast(ArrayLiteralExp)e2;
230 230
231 es2 = new ArrayLiteralExp(es2.loc, cast(Expressions)es2.elements.copy()); 231 es2 = new ArrayLiteralExp(es2.loc, cast(Expressions)es2.elements.copy());
232 es2.elements.shift(cast(void*)e1); 232 es2.elements.shift(e1);
233 e = es2; 233 e = es2;
234 234
235 if (type.toBasetype().ty == Tsarray) 235 if (type.toBasetype().ty == Tsarray)
236 { 236 {
237 e.type = new TypeSArray(e1.type, new IntegerExp(loc, es2.elements.dim, Type.tindex)); 237 e.type = new TypeSArray(e1.type, new IntegerExp(loc, es2.elements.dim, Type.tindex));
252 t = e2.type; 252 t = e2.type;
253 L1: 253 L1:
254 Type tb = t.toBasetype(); 254 Type tb = t.toBasetype();
255 if (tb.ty == Tarray && tb.nextOf().equals(e.type)) 255 if (tb.ty == Tarray && tb.nextOf().equals(e.type))
256 { 256 {
257 Expressions expressions = new Expressions(); 257 auto expressions = new Expressions();
258 expressions.push(cast(void*)e); 258 expressions.push(e);
259 e = new ArrayLiteralExp(loc, expressions); 259 e = new ArrayLiteralExp(loc, expressions);
260 e.type = t; 260 e.type = t;
261 } 261 }
262 if (!e.type.equals(type)) 262 if (!e.type.equals(type))
263 { 263 {