comparison dmd/declaration.c @ 159:5acec6b2eef8 trunk

[svn r175] merged dmd 1.029
author ChristianK
date Thu, 01 May 2008 15:15:28 +0200
parents ccd07d9f2ce9
children d61ce72c39ab
comparison
equal deleted inserted replaced
158:287540c5f05e 159:5acec6b2eef8
665 */ 665 */
666 TypeTuple *tt = (TypeTuple *)tb; 666 TypeTuple *tt = (TypeTuple *)tb;
667 size_t nelems = Argument::dim(tt->arguments); 667 size_t nelems = Argument::dim(tt->arguments);
668 Objects *exps = new Objects(); 668 Objects *exps = new Objects();
669 exps->setDim(nelems); 669 exps->setDim(nelems);
670 Expression *ie = init ? init->toExpression() : NULL;
670 671
671 for (size_t i = 0; i < nelems; i++) 672 for (size_t i = 0; i < nelems; i++)
672 { Argument *arg = Argument::getNth(tt->arguments, i); 673 { Argument *arg = Argument::getNth(tt->arguments, i);
673 674
674 OutBuffer buf; 675 OutBuffer buf;
675 buf.printf("_%s_field_%zu", ident->toChars(), i); 676 buf.printf("_%s_field_%zu", ident->toChars(), i);
676 buf.writeByte(0); 677 buf.writeByte(0);
677 char *name = (char *)buf.extractData(); 678 char *name = (char *)buf.extractData();
678 Identifier *id = new Identifier(name, TOKidentifier); 679 Identifier *id = new Identifier(name, TOKidentifier);
679 680
680 VarDeclaration *v = new VarDeclaration(loc, arg->type, id, NULL); 681 Expression *einit = ie;
682 if (ie && ie->op == TOKtuple)
683 { einit = (Expression *)((TupleExp *)ie)->exps->data[i];
684 }
685 Initializer *ti = init;
686 if (einit)
687 { ti = new ExpInitializer(einit->loc, einit);
688 }
689
690 VarDeclaration *v = new VarDeclaration(loc, arg->type, id, ti);
681 //printf("declaring field %s of type %s\n", v->toChars(), v->type->toChars()); 691 //printf("declaring field %s of type %s\n", v->toChars(), v->type->toChars());
682 v->semantic(sc); 692 v->semantic(sc);
683 693
684 if (sc->scopesym) 694 if (sc->scopesym)
685 { //printf("adding %s to %s\n", v->toChars(), sc->scopesym->toChars()); 695 { //printf("adding %s to %s\n", v->toChars(), sc->scopesym->toChars());
1107 { 1117 {
1108 /* We can do better if there's a way with onstack 1118 /* We can do better if there's a way with onstack
1109 * classes to determine if there's no way the monitor 1119 * classes to determine if there's no way the monitor
1110 * could be set. 1120 * could be set.
1111 */ 1121 */
1112 if (cd->isInterfaceDeclaration()) 1122 //if (cd->isInterfaceDeclaration())
1113 error("interface %s cannot be scope", cd->toChars()); 1123 //error("interface %s cannot be scope", cd->toChars());
1114 if (1 || onstack || cd->dtors.dim) // if any destructors 1124 if (1 || onstack || cd->dtors.dim) // if any destructors
1115 { 1125 {
1116 // delete this; 1126 // delete this;
1117 Expression *ec; 1127 Expression *ec;
1118 1128