comparison dmd/StructLiteralExp.d @ 64:4290d870944a

More fixes
author korDen
date Mon, 23 Aug 2010 20:29:15 +0400
parents cab4c37afb89
children f708f0452e81
comparison
equal deleted inserted replaced
63:cab4c37afb89 64:4290d870944a
1 module dmd.StructLiteralExp; 1 module dmd.StructLiteralExp;
2 2
3 import dmd.Expression; 3 import dmd.Expression;
4 import dmd.MOD;
5 import dmd.TypeStruct;
4 import dmd.expression.Util; 6 import dmd.expression.Util;
5 import dmd.ErrorExp; 7 import dmd.ErrorExp;
6 import dmd.Dsymbol; 8 import dmd.Dsymbol;
7 import dmd.VarDeclaration; 9 import dmd.VarDeclaration;
8 import dmd.StructDeclaration; 10 import dmd.StructDeclaration;
215 assert(false); 217 assert(false);
216 } 218 }
217 219
218 bool canThrow() 220 bool canThrow()
219 { 221 {
220 assert(false); 222 return arrayExpressionCanThrow(elements);
221 } 223 }
222 224
223 MATCH implicitConvTo(Type t) 225 MATCH implicitConvTo(Type t)
224 { 226 {
225 assert(false); 227 static if (false) {
228 printf("StructLiteralExp.implicitConvTo(this=%.*s, type=%.*s, t=%.*s)\n",
229 toChars(), type.toChars(), t.toChars());
230 }
231 MATCH m = Expression.implicitConvTo(t);
232 if (m != MATCHnomatch)
233 return m;
234 if (type.ty == t.ty && type.ty == Tstruct && (cast(TypeStruct)type).sym == (cast(TypeStruct)t).sym)
235 {
236 m = MATCHconst;
237 for (int i = 0; i < elements.dim; i++)
238 {
239 Expression e = cast(Expression)elements.data[i];
240 Type te = e.type;
241 if (t.mod == 0)
242 te = te.mutableOf();
243 else
244 {
245 assert(t.mod == MODinvariant);
246 te = te.invariantOf();
247 }
248 MATCH m2 = e.implicitConvTo(te);
249 //printf("\t%s => %s, match = %d\n", e.toChars(), te.toChars(), m2);
250 if (m2 < m)
251 m = m2;
252 }
253 }
254 return m;
226 } 255 }
227 256
228 int inlineCost(InlineCostState* ics) 257 int inlineCost(InlineCostState* ics)
229 { 258 {
230 assert(false); 259 assert(false);