Mercurial > projects > ddmd
comparison dmd/StructInitializer.d @ 79:43073c7c7769
updated to 2.035
also implemented a few missing functions
still crashes in Import.importAll though
author | Trass3r |
---|---|
date | Mon, 30 Aug 2010 03:57:51 +0200 |
parents | 2e2a5c3f943a |
children | be2ab491772e |
comparison
equal
deleted
inserted
replaced
78:b98fa8a4bf04 | 79:43073c7c7769 |
---|---|
106 i--; | 106 i--; |
107 continue; | 107 continue; |
108 } | 108 } |
109 else | 109 else |
110 { | 110 { |
111 s = cast(Dsymbol)ad.fields.data[fieldi]; | 111 s = ad.fields[fieldi]; |
112 } | 112 } |
113 } | 113 } |
114 else | 114 else |
115 { | 115 { |
116 //s = ad.symtab.lookup(id); | 116 //s = ad.symtab.lookup(id); |
127 if (fieldi >= ad.fields.dim) | 127 if (fieldi >= ad.fields.dim) |
128 { | 128 { |
129 s.error("is not a per-instance initializable field"); | 129 s.error("is not a per-instance initializable field"); |
130 break; | 130 break; |
131 } | 131 } |
132 if (s == cast(Dsymbol)ad.fields.data[fieldi]) | 132 if (s == ad.fields[fieldi]) |
133 break; | 133 break; |
134 } | 134 } |
135 } | 135 } |
136 if (s && (v = s.isVarDeclaration()) !is null) | 136 if (s && (v = s.isVarDeclaration()) !is null) |
137 { | 137 { |
241 //printf("vars[%d] = %s\n", i, v.toChars()); | 241 //printf("vars[%d] = %s\n", i, v.toChars()); |
242 | 242 |
243 for (j = 0; 1; j++) | 243 for (j = 0; 1; j++) |
244 { | 244 { |
245 assert(j < dts.dim); | 245 assert(j < dts.dim); |
246 //printf(" adfield[%d] = %s\n", j, ((VarDeclaration *)ad.fields.data[j]).toChars()); | 246 //printf(" adfield[%d] = %s\n", j, ((VarDeclaration *)ad.fields[j]).toChars()); |
247 if (cast(VarDeclaration)ad.fields.data[j] == v) | 247 if (cast(VarDeclaration)ad.fields[j] == v) // TODO: check if 'is' needs to be used here |
248 { | 248 { |
249 if (dts.data[j]) | 249 if (dts.data[j]) |
250 error(loc, "field %s of %s already initialized", v.toChars(), ad.toChars()); | 250 error(loc, "field %s of %s already initialized", v.toChars(), ad.toChars()); |
251 dts.data[j] = cast(void*)val.toDt(); | 251 dts.data[j] = cast(void*)val.toDt(); |
252 break; | 252 break; |
257 dt = null; | 257 dt = null; |
258 pdtend = &dt; | 258 pdtend = &dt; |
259 offset = 0; | 259 offset = 0; |
260 for (j = 0; j < dts.dim; j++) | 260 for (j = 0; j < dts.dim; j++) |
261 { | 261 { |
262 VarDeclaration v = cast(VarDeclaration)ad.fields.data[j]; | 262 VarDeclaration v = cast(VarDeclaration)ad.fields[j]; |
263 | 263 |
264 d = cast(dt_t*)dts.data[j]; | 264 d = cast(dt_t*)dts.data[j]; |
265 if (!d) | 265 if (!d) |
266 { | 266 { |
267 // An instance specific initializer was not provided. | 267 // An instance specific initializer was not provided. |
282 if (k == dts.dim) // didn't find any overlap | 282 if (k == dts.dim) // didn't find any overlap |
283 { | 283 { |
284 v.type.toDt(&d); | 284 v.type.toDt(&d); |
285 break; | 285 break; |
286 } | 286 } |
287 VarDeclaration v2 = cast(VarDeclaration)ad.fields.data[k]; | 287 VarDeclaration v2 = cast(VarDeclaration)ad.fields[k]; |
288 | 288 |
289 if (v2.offset < offset2 && dts.data[k]) | 289 if (v2.offset < offset2 && dts.data[k]) |
290 break; // overlap | 290 break; // overlap |
291 } | 291 } |
292 } | 292 } |