Changeset 318
- Timestamp:
- 12/29/09 11:03:50 (15 years ago)
- Files:
-
- branches/dmd-1.x/src/aggregate.h (modified) (1 diff)
- branches/dmd-1.x/src/struct.c (modified) (1 diff)
- trunk/src/aggregate.h (modified) (1 diff)
- trunk/src/struct.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmd-1.x/src/aggregate.h
r243 r318 114 114 { 115 115 } 116 116 117 117 AnonymousAggregateDeclaration *isAnonymousAggregateDeclaration() { return this; } 118 118 }; 119 119 120 120 struct StructDeclaration : AggregateDeclaration 121 121 { 122 122 int zeroInit; // !=0 if initialize with 0 fill 123 123 #if DMDV2 124 124 int hasIdentityAssign; // !=0 if has identity opAssign 125 125 FuncDeclaration *cpctor; // generated copy-constructor, if any 126 126 127 127 FuncDeclarations postblits; // Array of postblit functions 128 128 FuncDeclaration *postblit; // aggregate postblit 129 129 #endif 130 130 131 131 StructDeclaration(Loc loc, Identifier *id); 132 132 Dsymbol *syntaxCopy(Dsymbol *s); 133 133 void semantic(Scope *sc); 134 Dsymbol *search(Loc, Identifier *ident, int flags); 134 135 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 135 136 char *mangle(); 136 137 const char *kind(); 137 138 #if DMDV1 138 139 Expression *cloneMembers(); 139 140 #endif 140 141 #if DMDV2 141 142 int needOpAssign(); 142 143 FuncDeclaration *buildOpAssign(Scope *sc); 143 144 FuncDeclaration *buildPostBlit(Scope *sc); 144 145 FuncDeclaration *buildCpCtor(Scope *sc); 145 146 #endif 146 147 void toDocBuffer(OutBuffer *buf); 147 148 148 149 PROT getAccess(Dsymbol *smember); // determine access to smember 149 150 150 151 void toObjFile(int multiobj); // compile to .obj file 151 152 void toDt(dt_t **pdt); 152 153 void toDebug(); // to symbolic debug info 153 154 branches/dmd-1.x/src/struct.c
r304 r318 433 433 } 434 434 } 435 435 } 436 436 437 437 /* Look for special member functions. 438 438 */ 439 439 #if DMDV2 440 440 ctor = (CtorDeclaration *)search(0, Id::ctor, 0); 441 441 #endif 442 442 inv = (InvariantDeclaration *)search(0, Id::classInvariant, 0); 443 443 aggNew = (NewDeclaration *)search(0, Id::classNew, 0); 444 444 aggDelete = (DeleteDeclaration *)search(0, Id::classDelete, 0); 445 445 446 446 if (sc->func) 447 447 { 448 448 semantic2(sc); 449 449 semantic3(sc); 450 450 } 451 451 } 452 452 453 Dsymbol *StructDeclaration::search(Loc loc, Identifier *ident, int flags) 454 { 455 //printf("%s.StructDeclaration::search('%s')\n", toChars(), ident->toChars()); 456 457 if (scope) 458 semantic(scope); 459 460 if (!members || !symtab) 461 { 462 error("is forward referenced when looking for '%s'", ident->toChars()); 463 return NULL; 464 } 465 466 return ScopeDsymbol::search(loc, ident, flags); 467 } 468 453 469 void StructDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 454 470 { int i; 455 471 456 472 buf->printf("%s ", kind()); 457 473 if (!isAnonymous()) 458 474 buf->writestring(toChars()); 459 475 if (!members) 460 476 { 461 477 buf->writeByte(';'); 462 478 buf->writenl(); 463 479 return; 464 480 } 465 481 buf->writenl(); 466 482 buf->writeByte('{'); 467 483 buf->writenl(); 468 484 for (i = 0; i < members->dim; i++) 469 485 { 470 486 Dsymbol *s = (Dsymbol *)members->data[i]; 471 487 472 488 buf->writestring(" "); trunk/src/aggregate.h
r260 r318 115 115 } 116 116 117 117 AnonymousAggregateDeclaration *isAnonymousAggregateDeclaration() { return this; } 118 118 }; 119 119 120 120 struct StructDeclaration : AggregateDeclaration 121 121 { 122 122 int zeroInit; // !=0 if initialize with 0 fill 123 123 #if DMDV2 124 124 int hasIdentityAssign; // !=0 if has identity opAssign 125 125 FuncDeclaration *cpctor; // generated copy-constructor, if any 126 126 FuncDeclaration *eq; // bool opEquals(ref const T), if any 127 127 128 128 FuncDeclarations postblits; // Array of postblit functions 129 129 FuncDeclaration *postblit; // aggregate postblit 130 130 #endif 131 131 132 132 StructDeclaration(Loc loc, Identifier *id); 133 133 Dsymbol *syntaxCopy(Dsymbol *s); 134 134 void semantic(Scope *sc); 135 Dsymbol *search(Loc, Identifier *ident, int flags); 135 136 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 136 137 char *mangle(); 137 138 const char *kind(); 138 139 #if DMDV1 139 140 Expression *cloneMembers(); 140 141 #endif 141 142 #if DMDV2 142 143 int needOpAssign(); 143 144 int needOpEquals(); 144 145 FuncDeclaration *buildOpAssign(Scope *sc); 145 146 FuncDeclaration *buildOpEquals(Scope *sc); 146 147 FuncDeclaration *buildPostBlit(Scope *sc); 147 148 FuncDeclaration *buildCpCtor(Scope *sc); 148 149 #endif 149 150 void toDocBuffer(OutBuffer *buf); 150 151 151 152 PROT getAccess(Dsymbol *smember); // determine access to smember 152 153 153 154 void toObjFile(int multiobj); // compile to .obj file 154 155 void toDt(dt_t **pdt); trunk/src/struct.c
r260 r318 537 537 } 538 538 } 539 539 } 540 540 541 541 /* Look for special member functions. 542 542 */ 543 543 #if DMDV2 544 544 ctor = search(0, Id::ctor, 0); 545 545 #endif 546 546 inv = (InvariantDeclaration *)search(0, Id::classInvariant, 0); 547 547 aggNew = (NewDeclaration *)search(0, Id::classNew, 0); 548 548 aggDelete = (DeleteDeclaration *)search(0, Id::classDelete, 0); 549 549 550 550 if (sc->func) 551 551 { 552 552 semantic2(sc); 553 553 semantic3(sc); 554 554 } 555 555 } 556 556 557 Dsymbol *StructDeclaration::search(Loc loc, Identifier *ident, int flags) 558 { 559 //printf("%s.StructDeclaration::search('%s')\n", toChars(), ident->toChars()); 560 561 if (scope) 562 semantic(scope); 563 564 if (!members || !symtab) 565 { 566 error("is forward referenced when looking for '%s'", ident->toChars()); 567 return NULL; 568 } 569 570 return ScopeDsymbol::search(loc, ident, flags); 571 } 572 557 573 void StructDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 558 574 { int i; 559 575 560 576 buf->printf("%s ", kind()); 561 577 if (!isAnonymous()) 562 578 buf->writestring(toChars()); 563 579 if (!members) 564 580 { 565 581 buf->writeByte(';'); 566 582 buf->writenl(); 567 583 return; 568 584 } 569 585 buf->writenl(); 570 586 buf->writeByte('{'); 571 587 buf->writenl(); 572 588 for (i = 0; i < members->dim; i++) 573 589 { 574 590 Dsymbol *s = (Dsymbol *)members->data[i]; 575 591 576 592 buf->writestring(" ");
