Mercurial > projects > ddmd
comparison dmd/StructDeclaration.d @ 85:8e69d041a99d
Previous commit didn't compile. Fixed.
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Mon, 30 Aug 2010 16:16:30 +0100 |
parents | be2ab491772e |
children | 23280d154c5b |
comparison
equal
deleted
inserted
replaced
84:be2ab491772e | 85:8e69d041a99d |
---|---|
320 | 320 |
321 //printf("-StructDeclaration.semantic(this=%p, '%s')\n", this, toChars()); | 321 //printf("-StructDeclaration.semantic(this=%p, '%s')\n", this, toChars()); |
322 | 322 |
323 // Determine if struct is all zeros or not | 323 // Determine if struct is all zeros or not |
324 zeroInit = true; | 324 zeroInit = true; |
325 foreach (Dsymbol s; fields) | 325 foreach (VarDeclaration vd; fields) |
326 { | 326 { |
327 VarDeclaration vd = s.isVarDeclaration(); | |
328 if (vd && !vd.isDataseg()) | 327 if (vd && !vd.isDataseg()) |
329 { | 328 { |
330 if (vd.init) | 329 if (vd.init) |
331 { | 330 { |
332 // Should examine init to see if it is really all 0's | 331 // Should examine init to see if it is really all 0's |
393 goto Lneed; | 392 goto Lneed; |
394 | 393 |
395 /* If any of the fields need an opAssign, then we | 394 /* If any of the fields need an opAssign, then we |
396 * need it too. | 395 * need it too. |
397 */ | 396 */ |
398 foreach (Dsymbol s; fields) | 397 foreach (VarDeclaration v; fields) |
399 { | 398 { |
400 VarDeclaration v = s.isVarDeclaration(); | |
401 assert(v && v.storage_class & STC.STCfield); | 399 assert(v && v.storage_class & STC.STCfield); |
402 if (v.storage_class & STC.STCref) | 400 if (v.storage_class & STC.STCref) |
403 continue; | 401 continue; |
404 Type tv = v.type.toBasetype(); | 402 Type tv = v.type.toBasetype(); |
405 while (tv.ty == TY.Tsarray) | 403 while (tv.ty == TY.Tsarray) |
496 } | 494 } |
497 else | 495 else |
498 { /* Do memberwise copy | 496 { /* Do memberwise copy |
499 */ | 497 */ |
500 //printf("\tmemberwise copy\n"); | 498 //printf("\tmemberwise copy\n"); |
501 foreach (Dsymbol s; fields) | 499 foreach (VarDeclaration v; fields) |
502 { | 500 { |
503 VarDeclaration v = s.isVarDeclaration(); | |
504 assert(v && v.storage_class & STC.STCfield); | 501 assert(v && v.storage_class & STC.STCfield); |
505 // this.v = s.v; | 502 // this.v = s.v; |
506 AssignExp ec = new AssignExp(Loc(0), new DotVarExp(Loc(0), new ThisExp(Loc(0)), v, 0), new DotVarExp(Loc(0), new IdentifierExp(Loc(0), Id.p), v, 0)); | 503 AssignExp ec = new AssignExp(Loc(0), new DotVarExp(Loc(0), new ThisExp(Loc(0)), v, 0), new DotVarExp(Loc(0), new IdentifierExp(Loc(0), Id.p), v, 0)); |
507 ec.op = TOK.TOKblit; | 504 ec.op = TOK.TOKblit; |
508 e = Expression.combine(e, ec); | 505 e = Expression.combine(e, ec); |
546 FuncDeclaration buildPostBlit(Scope sc) | 543 FuncDeclaration buildPostBlit(Scope sc) |
547 { | 544 { |
548 //printf("StructDeclaration.buildPostBlit() %s\n", toChars()); | 545 //printf("StructDeclaration.buildPostBlit() %s\n", toChars()); |
549 Expression e = null; | 546 Expression e = null; |
550 | 547 |
551 foreach (Dsymbol s; fields) | 548 foreach (VarDeclaration v; fields) |
552 { | 549 { |
553 VarDeclaration v = s.isVarDeclaration(); | |
554 assert(v && v.storage_class & STC.STCfield); | 550 assert(v && v.storage_class & STC.STCfield); |
555 if (v.storage_class & STC.STCref) | 551 if (v.storage_class & STC.STCref) |
556 continue; | 552 continue; |
557 Type tv = v.type.toBasetype(); | 553 Type tv = v.type.toBasetype(); |
558 size_t dim = 1; | 554 size_t dim = 1; |