Mercurial > projects > ldc
comparison dmd/func.c @ 1640:9bf06e02070b
Merge DMD 1.057.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Mon, 08 Mar 2010 21:39:20 +0100 |
parents | 44b145be2ef5 |
children |
comparison
equal
deleted
inserted
replaced
1639:41145d30acb8 | 1640:9bf06e02070b |
---|---|
638 Statement *s2 = new ExpStatement(loc, e); | 638 Statement *s2 = new ExpStatement(loc, e); |
639 frequire = new CompoundStatement(loc, s1, s2); | 639 frequire = new CompoundStatement(loc, s1, s2); |
640 fdrequire = fd; | 640 fdrequire = fd; |
641 } | 641 } |
642 | 642 |
643 if (!outId && f->nextOf()->toBasetype()->ty != Tvoid) | |
644 outId = Id::result; // provide a default | |
645 | |
643 if (fensure) | 646 if (fensure) |
644 { /* out (result) { ... } | 647 { /* out (result) { ... } |
645 * becomes: | 648 * becomes: |
646 * tret __ensure(ref tret result) { ... } | 649 * tret __ensure(ref tret result) { ... } |
647 * __ensure(result); | 650 * __ensure(result); |
648 */ | 651 */ |
649 if (!outId && f->nextOf()->toBasetype()->ty != Tvoid) | |
650 outId = Id::result; // provide a default | |
651 | |
652 Loc loc = fensure->loc; | 652 Loc loc = fensure->loc; |
653 Parameters *arguments = new Parameters(); | 653 Parameters *arguments = new Parameters(); |
654 Parameter *a = NULL; | 654 Parameter *a = NULL; |
655 if (outId) | 655 if (outId) |
656 { a = new Parameter(STCref, f->nextOf(), outId, NULL); | 656 { a = new Parameter(STCref, f->nextOf(), outId, NULL); |
770 // Declare 'this' | 770 // Declare 'this' |
771 AggregateDeclaration *ad = isThis(); | 771 AggregateDeclaration *ad = isThis(); |
772 if (ad) | 772 if (ad) |
773 { VarDeclaration *v; | 773 { VarDeclaration *v; |
774 | 774 |
775 if (isFuncLiteralDeclaration() && isNested()) | 775 if (isFuncLiteralDeclaration() && isNested() && !sc->intypeof) |
776 { | 776 { |
777 error("literals cannot be class members"); | 777 error("function literals cannot be class members"); |
778 return; | 778 return; |
779 } | 779 } |
780 else | 780 else |
781 { | 781 { |
782 assert(!isNested()); // can't be both member and nested | 782 assert(!isNested() || sc->intypeof); // can't be both member and nested |
783 assert(ad->handle); | 783 assert(ad->handle); |
784 v = new ThisDeclaration(loc, ad->handle); | 784 v = new ThisDeclaration(loc, ad->handle); |
785 v->storage_class |= STCparameter | STCin; | 785 v->storage_class |= STCparameter | STCin; |
786 v->semantic(sc2); | 786 v->semantic(sc2); |
787 if (!sc2->insert(v)) | 787 if (!sc2->insert(v)) |
2626 return (tok == TOKdelegate) ? (char*)"delegate" : (char*)"function"; | 2626 return (tok == TOKdelegate) ? (char*)"delegate" : (char*)"function"; |
2627 } | 2627 } |
2628 | 2628 |
2629 void FuncLiteralDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) | 2629 void FuncLiteralDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) |
2630 { | 2630 { |
2631 static Identifier *idfunc; | 2631 buf->writestring(kind()); |
2632 static Identifier *iddel; | 2632 buf->writeByte(' '); |
2633 | 2633 type->toCBuffer(buf, NULL, hgs); |
2634 if (!idfunc) | |
2635 idfunc = new Identifier("function", 0); | |
2636 if (!iddel) | |
2637 iddel = new Identifier("delegate", 0); | |
2638 | |
2639 type->toCBuffer(buf, ((tok == TOKdelegate) ? iddel : idfunc), hgs); | |
2640 bodyToCBuffer(buf, hgs); | 2634 bodyToCBuffer(buf, hgs); |
2641 } | 2635 } |
2642 | 2636 |
2643 | 2637 |
2644 /********************************* CtorDeclaration ****************************/ | 2638 /********************************* CtorDeclaration ****************************/ |