Mercurial > projects > ldc
comparison dmd/func.c @ 1607:207a8a438dea
Merge DMD r253: refactor: Argument => Parameter
---
dmd/arrayop.c | 30 ++++----
dmd/arraytypes.h | 2 +-
dmd/class.c | 8 +-
dmd/declaration.c | 10 ++--
dmd/declaration.h | 16 ++--
dmd/doc.c | 12 ++--
dmd/dsymbol.c | 4 +-
dmd/expression.c | 48 +++++++-------
dmd/expression.h | 32 +++++-----
dmd/func.c | 78 +++++++++++-----------
dmd/init.c | 2 +-
dmd/interpret.c | 8 +-
dmd/mtype.c | 190 ++++++++++++++++++++++++++--------------------------
dmd/mtype.h | 32 +++++-----
dmd/opover.c | 34 +++++-----
dmd/parse.c | 40 ++++++------
dmd/parse.h | 2 +-
dmd/statement.c | 90 +++++++++++++-------------
dmd/statement.h | 14 ++--
dmd/struct.c | 8 +-
dmd/template.c | 30 ++++----
gen/functions.cpp | 10 ++--
gen/functions.h | 2 +-
gen/tocall.cpp | 10 ++--
gen/typinf.cpp | 6 +-
25 files changed, 359 insertions(+), 359 deletions(-)
author | Leandro Lucarella <llucax@gmail.com> |
---|---|
date | Wed, 06 Jan 2010 15:18:20 -0300 |
parents | a413ae7329bf |
children | 679d101395e8 |
comparison
equal
deleted
inserted
replaced
1606:1b24e9c7cc26 | 1607:207a8a438dea |
---|---|
176 { | 176 { |
177 error("%s must be a function", toChars()); | 177 error("%s must be a function", toChars()); |
178 return; | 178 return; |
179 } | 179 } |
180 f = (TypeFunction *)(type); | 180 f = (TypeFunction *)(type); |
181 size_t nparams = Argument::dim(f->parameters); | 181 size_t nparams = Parameter::dim(f->parameters); |
182 | 182 |
183 linkage = sc->linkage; | 183 linkage = sc->linkage; |
184 // if (!parent) | 184 // if (!parent) |
185 { | 185 { |
186 //parent = sc->scopesym; | 186 //parent = sc->scopesym; |
544 case 0: | 544 case 0: |
545 break; | 545 break; |
546 | 546 |
547 case 1: | 547 case 1: |
548 { | 548 { |
549 Argument *arg0 = Argument::getNth(f->parameters, 0); | 549 Parameter *arg0 = Parameter::getNth(f->parameters, 0); |
550 if (arg0->type->ty != Tarray || | 550 if (arg0->type->ty != Tarray || |
551 arg0->type->nextOf()->ty != Tarray || | 551 arg0->type->nextOf()->ty != Tarray || |
552 arg0->type->nextOf()->nextOf()->ty != Tchar || | 552 arg0->type->nextOf()->nextOf()->ty != Tchar || |
553 arg0->storageClass & (STCout | STCref | STClazy)) | 553 arg0->storageClass & (STCout | STCref | STClazy)) |
554 goto Lmainerr; | 554 goto Lmainerr; |
578 { if (f->varargs == 1) | 578 { if (f->varargs == 1) |
579 goto Lassignerr; | 579 goto Lassignerr; |
580 } | 580 } |
581 else | 581 else |
582 { | 582 { |
583 Argument *arg0 = Argument::getNth(f->parameters, 0); | 583 Parameter *arg0 = Parameter::getNth(f->parameters, 0); |
584 Type *t0 = arg0->type->toBasetype(); | 584 Type *t0 = arg0->type->toBasetype(); |
585 Type *tb = sd ? sd->type : cd->type; | 585 Type *tb = sd ? sd->type : cd->type; |
586 if (arg0->type->implicitConvTo(tb) || | 586 if (arg0->type->implicitConvTo(tb) || |
587 (sd && t0->ty == Tpointer && t0->nextOf()->implicitConvTo(tb)) | 587 (sd && t0->ty == Tpointer && t0->nextOf()->implicitConvTo(tb)) |
588 ) | 588 ) |
589 { | 589 { |
590 if (nparams == 1) | 590 if (nparams == 1) |
591 goto Lassignerr; | 591 goto Lassignerr; |
592 Argument *arg1 = Argument::getNth(f->parameters, 1); | 592 Parameter *arg1 = Parameter::getNth(f->parameters, 1); |
593 if (arg1->defaultArg) | 593 if (arg1->defaultArg) |
594 goto Lassignerr; | 594 goto Lassignerr; |
595 } | 595 } |
596 } | 596 } |
597 } | 597 } |
628 */ | 628 */ |
629 if (!outId && f->nextOf()->toBasetype()->ty != Tvoid) | 629 if (!outId && f->nextOf()->toBasetype()->ty != Tvoid) |
630 outId = Id::result; // provide a default | 630 outId = Id::result; // provide a default |
631 | 631 |
632 Loc loc = fensure->loc; | 632 Loc loc = fensure->loc; |
633 Arguments *arguments = new Arguments(); | 633 Parameters *arguments = new Parameters(); |
634 Argument *a = NULL; | 634 Parameter *a = NULL; |
635 if (outId) | 635 if (outId) |
636 { a = new Argument(STCref, f->nextOf(), outId, NULL); | 636 { a = new Parameter(STCref, f->nextOf(), outId, NULL); |
637 arguments->push(a); | 637 arguments->push(a); |
638 } | 638 } |
639 TypeFunction *tf = new TypeFunction(arguments, Type::tvoid, 0, LINKd); | 639 TypeFunction *tf = new TypeFunction(arguments, Type::tvoid, 0, LINKd); |
640 FuncDeclaration *fd = new FuncDeclaration(loc, loc, | 640 FuncDeclaration *fd = new FuncDeclaration(loc, loc, |
641 Id::ensure, STCundefined, tf); | 641 Id::ensure, STCundefined, tf); |
831 #if IN_LLVM | 831 #if IN_LLVM |
832 // LDC make sure argument type is semanticed. | 832 // LDC make sure argument type is semanticed. |
833 // Turns TypeTuple!(int, int) into two int parameters, for instance. | 833 // Turns TypeTuple!(int, int) into two int parameters, for instance. |
834 if (f->parameters) | 834 if (f->parameters) |
835 { | 835 { |
836 for (size_t i = 0; i < Argument::dim(f->parameters); i++) | 836 for (size_t i = 0; i < Parameter::dim(f->parameters); i++) |
837 { Argument *arg = (Argument *)Argument::getNth(f->parameters, i); | 837 { Parameter *arg = (Parameter *)Parameter::getNth(f->parameters, i); |
838 Type* nw = arg->type->semantic(0, sc); | 838 Type* nw = arg->type->semantic(0, sc); |
839 if (arg->type != nw) { | 839 if (arg->type != nw) { |
840 arg->type = nw; | 840 arg->type = nw; |
841 // Examine this index again. | 841 // Examine this index again. |
842 // This is important if it turned into a tuple. | 842 // This is important if it turned into a tuple. |
852 | 852 |
853 // Propagate storage class from tuple parameters to their element-parameters. | 853 // Propagate storage class from tuple parameters to their element-parameters. |
854 if (f->parameters) | 854 if (f->parameters) |
855 { | 855 { |
856 for (size_t i = 0; i < f->parameters->dim; i++) | 856 for (size_t i = 0; i < f->parameters->dim; i++) |
857 { Argument *arg = (Argument *)f->parameters->data[i]; | 857 { Parameter *arg = (Parameter *)f->parameters->data[i]; |
858 | 858 |
859 //printf("[%d] arg->type->ty = %d %s\n", i, arg->type->ty, arg->type->toChars()); | 859 //printf("[%d] arg->type->ty = %d %s\n", i, arg->type->ty, arg->type->toChars()); |
860 if (arg->type->ty == Ttuple) | 860 if (arg->type->ty == Ttuple) |
861 { TypeTuple *t = (TypeTuple *)arg->type; | 861 { TypeTuple *t = (TypeTuple *)arg->type; |
862 size_t dim = Argument::dim(t->arguments); | 862 size_t dim = Parameter::dim(t->arguments); |
863 for (size_t j = 0; j < dim; j++) | 863 for (size_t j = 0; j < dim; j++) |
864 { Argument *narg = Argument::getNth(t->arguments, j); | 864 { Parameter *narg = Parameter::getNth(t->arguments, j); |
865 narg->storageClass = arg->storageClass; | 865 narg->storageClass = arg->storageClass; |
866 } | 866 } |
867 } | 867 } |
868 } | 868 } |
869 } | 869 } |
870 | 870 |
871 /* Declare all the function parameters as variables | 871 /* Declare all the function parameters as variables |
872 * and install them in parameters[] | 872 * and install them in parameters[] |
873 */ | 873 */ |
874 size_t nparams = Argument::dim(f->parameters); | 874 size_t nparams = Parameter::dim(f->parameters); |
875 if (nparams) | 875 if (nparams) |
876 { /* parameters[] has all the tuples removed, as the back end | 876 { /* parameters[] has all the tuples removed, as the back end |
877 * doesn't know about tuples | 877 * doesn't know about tuples |
878 */ | 878 */ |
879 parameters = new Dsymbols(); | 879 parameters = new Dsymbols(); |
880 parameters->reserve(nparams); | 880 parameters->reserve(nparams); |
881 for (size_t i = 0; i < nparams; i++) | 881 for (size_t i = 0; i < nparams; i++) |
882 { | 882 { |
883 Argument *arg = Argument::getNth(f->parameters, i); | 883 Parameter *arg = Parameter::getNth(f->parameters, i); |
884 Identifier *id = arg->ident; | 884 Identifier *id = arg->ident; |
885 if (!id) | 885 if (!id) |
886 { | 886 { |
887 /* Generate identifier for un-named parameter, | 887 /* Generate identifier for un-named parameter, |
888 * because we need it later on. | 888 * because we need it later on. |
911 // Declare the tuple symbols and put them in the symbol table, | 911 // Declare the tuple symbols and put them in the symbol table, |
912 // but not in parameters[]. | 912 // but not in parameters[]. |
913 if (f->parameters) | 913 if (f->parameters) |
914 { | 914 { |
915 for (size_t i = 0; i < f->parameters->dim; i++) | 915 for (size_t i = 0; i < f->parameters->dim; i++) |
916 { Argument *arg = (Argument *)f->parameters->data[i]; | 916 { Parameter *arg = (Parameter *)f->parameters->data[i]; |
917 | 917 |
918 if (!arg->ident) | 918 if (!arg->ident) |
919 continue; // never used, so ignore | 919 continue; // never used, so ignore |
920 if (arg->type->ty == Ttuple) | 920 if (arg->type->ty == Ttuple) |
921 { TypeTuple *t = (TypeTuple *)arg->type; | 921 { TypeTuple *t = (TypeTuple *)arg->type; |
922 size_t dim = Argument::dim(t->arguments); | 922 size_t dim = Parameter::dim(t->arguments); |
923 Objects *exps = new Objects(); | 923 Objects *exps = new Objects(); |
924 exps->setDim(dim); | 924 exps->setDim(dim); |
925 for (size_t j = 0; j < dim; j++) | 925 for (size_t j = 0; j < dim; j++) |
926 { Argument *narg = Argument::getNth(t->arguments, j); | 926 { Parameter *narg = Parameter::getNth(t->arguments, j); |
927 assert(narg->ident); | 927 assert(narg->ident); |
928 VarDeclaration *v = sc2->search(0, narg->ident, NULL)->isVarDeclaration(); | 928 VarDeclaration *v = sc2->search(0, narg->ident, NULL)->isVarDeclaration(); |
929 assert(v); | 929 assert(v); |
930 Expression *e = new VarExp(v->loc, v); | 930 Expression *e = new VarExp(v->loc, v); |
931 exps->data[j] = (void *)e; | 931 exps->data[j] = (void *)e; |
1983 { | 1983 { |
1984 tf = (TypeFunction *)type; | 1984 tf = (TypeFunction *)type; |
1985 | 1985 |
1986 //printf("tf = %s, args = %s\n", tf->deco, ((Expression *)arguments->data[0])->type->deco); | 1986 //printf("tf = %s, args = %s\n", tf->deco, ((Expression *)arguments->data[0])->type->deco); |
1987 error(loc, "%s does not match parameter types (%s)", | 1987 error(loc, "%s does not match parameter types (%s)", |
1988 Argument::argsTypesToChars(tf->parameters, tf->varargs), | 1988 Parameter::argsTypesToChars(tf->parameters, tf->varargs), |
1989 buf.toChars()); | 1989 buf.toChars()); |
1990 return m.anyf; // as long as it's not a FuncAliasDeclaration | 1990 return m.anyf; // as long as it's not a FuncAliasDeclaration |
1991 } | 1991 } |
1992 else | 1992 else |
1993 { | 1993 { |
1995 TypeFunction *t1 = (TypeFunction *)m.lastf->type; | 1995 TypeFunction *t1 = (TypeFunction *)m.lastf->type; |
1996 TypeFunction *t2 = (TypeFunction *)m.nextf->type; | 1996 TypeFunction *t2 = (TypeFunction *)m.nextf->type; |
1997 | 1997 |
1998 error(loc, "called with argument types:\n\t(%s)\nmatches both:\n\t%s%s\nand:\n\t%s%s", | 1998 error(loc, "called with argument types:\n\t(%s)\nmatches both:\n\t%s%s\nand:\n\t%s%s", |
1999 buf.toChars(), | 1999 buf.toChars(), |
2000 m.lastf->toPrettyChars(), Argument::argsTypesToChars(t1->parameters, t1->varargs), | 2000 m.lastf->toPrettyChars(), Parameter::argsTypesToChars(t1->parameters, t1->varargs), |
2001 m.nextf->toPrettyChars(), Argument::argsTypesToChars(t2->parameters, t2->varargs)); | 2001 m.nextf->toPrettyChars(), Parameter::argsTypesToChars(t2->parameters, t2->varargs)); |
2002 #else | 2002 #else |
2003 error(loc, "overloads %s and %s both match argument list for %s", | 2003 error(loc, "overloads %s and %s both match argument list for %s", |
2004 m.lastf->type->toChars(), | 2004 m.lastf->type->toChars(), |
2005 m.nextf->type->toChars(), | 2005 m.nextf->type->toChars(), |
2006 m.lastf->toChars()); | 2006 m.lastf->toChars()); |
2032 * as g() is. | 2032 * as g() is. |
2033 */ | 2033 */ |
2034 | 2034 |
2035 TypeFunction *tf = (TypeFunction *)type; | 2035 TypeFunction *tf = (TypeFunction *)type; |
2036 TypeFunction *tg = (TypeFunction *)g->type; | 2036 TypeFunction *tg = (TypeFunction *)g->type; |
2037 size_t nfparams = Argument::dim(tf->parameters); | 2037 size_t nfparams = Parameter::dim(tf->parameters); |
2038 size_t ngparams = Argument::dim(tg->parameters); | 2038 size_t ngparams = Parameter::dim(tg->parameters); |
2039 MATCH match = MATCHexact; | 2039 MATCH match = MATCHexact; |
2040 | 2040 |
2041 /* If both functions have a 'this' pointer, and the mods are not | 2041 /* If both functions have a 'this' pointer, and the mods are not |
2042 * the same and g's is not const, then this is less specialized. | 2042 * the same and g's is not const, then this is less specialized. |
2043 */ | 2043 */ |
2056 */ | 2056 */ |
2057 Expressions args; | 2057 Expressions args; |
2058 args.setDim(nfparams); | 2058 args.setDim(nfparams); |
2059 for (int u = 0; u < nfparams; u++) | 2059 for (int u = 0; u < nfparams; u++) |
2060 { | 2060 { |
2061 Argument *p = Argument::getNth(tf->parameters, u); | 2061 Parameter *p = Parameter::getNth(tf->parameters, u); |
2062 Expression *e; | 2062 Expression *e; |
2063 if (p->storageClass & (STCref | STCout)) | 2063 if (p->storageClass & (STCref | STCout)) |
2064 { | 2064 { |
2065 e = new IdentifierExp(0, p->ident); | 2065 e = new IdentifierExp(0, p->ident); |
2066 e->type = p->type; | 2066 e->type = p->type; |
2391 | 2391 |
2392 // | 2392 // |
2393 // LDC: Adjusted to give argument info to the runtime function decl. | 2393 // LDC: Adjusted to give argument info to the runtime function decl. |
2394 // | 2394 // |
2395 | 2395 |
2396 FuncDeclaration *FuncDeclaration::genCfunc(Arguments *args, Type *treturn, const char *name) | 2396 FuncDeclaration *FuncDeclaration::genCfunc(Parameters *args, Type *treturn, const char *name) |
2397 { | 2397 { |
2398 return genCfunc(args, treturn, Lexer::idPool(name)); | 2398 return genCfunc(args, treturn, Lexer::idPool(name)); |
2399 } | 2399 } |
2400 | 2400 |
2401 FuncDeclaration *FuncDeclaration::genCfunc(Arguments *args, Type *treturn, Identifier *id) | 2401 FuncDeclaration *FuncDeclaration::genCfunc(Parameters *args, Type *treturn, Identifier *id) |
2402 { | 2402 { |
2403 FuncDeclaration *fd; | 2403 FuncDeclaration *fd; |
2404 TypeFunction *tf; | 2404 TypeFunction *tf; |
2405 Dsymbol *s; | 2405 Dsymbol *s; |
2406 static DsymbolTable *st = NULL; | 2406 static DsymbolTable *st = NULL; |
2573 } | 2573 } |
2574 | 2574 |
2575 | 2575 |
2576 /********************************* CtorDeclaration ****************************/ | 2576 /********************************* CtorDeclaration ****************************/ |
2577 | 2577 |
2578 CtorDeclaration::CtorDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs) | 2578 CtorDeclaration::CtorDeclaration(Loc loc, Loc endloc, Parameters *arguments, int varargs) |
2579 : FuncDeclaration(loc, endloc, Id::ctor, STCundefined, NULL) | 2579 : FuncDeclaration(loc, endloc, Id::ctor, STCundefined, NULL) |
2580 { | 2580 { |
2581 this->arguments = arguments; | 2581 this->arguments = arguments; |
2582 this->varargs = varargs; | 2582 this->varargs = varargs; |
2583 //printf("CtorDeclaration(loc = %s) %s\n", loc.toChars(), toChars()); | 2583 //printf("CtorDeclaration(loc = %s) %s\n", loc.toChars(), toChars()); |
2593 f->frequire = frequire ? frequire->syntaxCopy() : NULL; | 2593 f->frequire = frequire ? frequire->syntaxCopy() : NULL; |
2594 f->fensure = fensure ? fensure->syntaxCopy() : NULL; | 2594 f->fensure = fensure ? fensure->syntaxCopy() : NULL; |
2595 f->fbody = fbody ? fbody->syntaxCopy() : NULL; | 2595 f->fbody = fbody ? fbody->syntaxCopy() : NULL; |
2596 assert(!fthrows); // deprecated | 2596 assert(!fthrows); // deprecated |
2597 | 2597 |
2598 f->arguments = Argument::arraySyntaxCopy(arguments); | 2598 f->arguments = Parameter::arraySyntaxCopy(arguments); |
2599 return f; | 2599 return f; |
2600 } | 2600 } |
2601 | 2601 |
2602 | 2602 |
2603 void CtorDeclaration::semantic(Scope *sc) | 2603 void CtorDeclaration::semantic(Scope *sc) |
2648 FuncDeclaration::semantic(sc); | 2648 FuncDeclaration::semantic(sc); |
2649 | 2649 |
2650 sc->pop(); | 2650 sc->pop(); |
2651 | 2651 |
2652 // See if it's the default constructor | 2652 // See if it's the default constructor |
2653 if (cd && varargs == 0 && Argument::dim(arguments) == 0) | 2653 if (cd && varargs == 0 && Parameter::dim(arguments) == 0) |
2654 cd->defaultCtor = this; | 2654 cd->defaultCtor = this; |
2655 } | 2655 } |
2656 | 2656 |
2657 const char *CtorDeclaration::kind() | 2657 const char *CtorDeclaration::kind() |
2658 { | 2658 { |
2681 | 2681 |
2682 | 2682 |
2683 void CtorDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) | 2683 void CtorDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) |
2684 { | 2684 { |
2685 buf->writestring("this"); | 2685 buf->writestring("this"); |
2686 Argument::argsToCBuffer(buf, hgs, arguments, varargs); | 2686 Parameter::argsToCBuffer(buf, hgs, arguments, varargs); |
2687 bodyToCBuffer(buf, hgs); | 2687 bodyToCBuffer(buf, hgs); |
2688 } | 2688 } |
2689 | 2689 |
2690 /********************************* PostBlitDeclaration ****************************/ | 2690 /********************************* PostBlitDeclaration ****************************/ |
2691 | 2691 |
3214 bodyToCBuffer(buf, hgs); | 3214 bodyToCBuffer(buf, hgs); |
3215 } | 3215 } |
3216 | 3216 |
3217 /********************************* NewDeclaration ****************************/ | 3217 /********************************* NewDeclaration ****************************/ |
3218 | 3218 |
3219 NewDeclaration::NewDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs) | 3219 NewDeclaration::NewDeclaration(Loc loc, Loc endloc, Parameters *arguments, int varargs) |
3220 : FuncDeclaration(loc, endloc, Id::classNew, STCstatic, NULL) | 3220 : FuncDeclaration(loc, endloc, Id::classNew, STCstatic, NULL) |
3221 { | 3221 { |
3222 this->arguments = arguments; | 3222 this->arguments = arguments; |
3223 this->varargs = varargs; | 3223 this->varargs = varargs; |
3224 } | 3224 } |
3229 | 3229 |
3230 f = new NewDeclaration(loc, endloc, NULL, varargs); | 3230 f = new NewDeclaration(loc, endloc, NULL, varargs); |
3231 | 3231 |
3232 FuncDeclaration::syntaxCopy(f); | 3232 FuncDeclaration::syntaxCopy(f); |
3233 | 3233 |
3234 f->arguments = Argument::arraySyntaxCopy(arguments); | 3234 f->arguments = Parameter::arraySyntaxCopy(arguments); |
3235 | 3235 |
3236 return f; | 3236 return f; |
3237 } | 3237 } |
3238 | 3238 |
3239 | 3239 |
3257 type = type->semantic(loc, sc); | 3257 type = type->semantic(loc, sc); |
3258 assert(type->ty == Tfunction); | 3258 assert(type->ty == Tfunction); |
3259 | 3259 |
3260 // Check that there is at least one argument of type size_t | 3260 // Check that there is at least one argument of type size_t |
3261 TypeFunction *tf = (TypeFunction *)type; | 3261 TypeFunction *tf = (TypeFunction *)type; |
3262 if (Argument::dim(tf->parameters) < 1) | 3262 if (Parameter::dim(tf->parameters) < 1) |
3263 { | 3263 { |
3264 error("at least one argument of type size_t expected"); | 3264 error("at least one argument of type size_t expected"); |
3265 } | 3265 } |
3266 else | 3266 else |
3267 { | 3267 { |
3268 Argument *a = Argument::getNth(tf->parameters, 0); | 3268 Parameter *a = Parameter::getNth(tf->parameters, 0); |
3269 if (!a->type->equals(Type::tsize_t)) | 3269 if (!a->type->equals(Type::tsize_t)) |
3270 error("first argument must be type size_t, not %s", a->type->toChars()); | 3270 error("first argument must be type size_t, not %s", a->type->toChars()); |
3271 } | 3271 } |
3272 | 3272 |
3273 FuncDeclaration::semantic(sc); | 3273 FuncDeclaration::semantic(sc); |
3294 } | 3294 } |
3295 | 3295 |
3296 void NewDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) | 3296 void NewDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) |
3297 { | 3297 { |
3298 buf->writestring("new"); | 3298 buf->writestring("new"); |
3299 Argument::argsToCBuffer(buf, hgs, arguments, varargs); | 3299 Parameter::argsToCBuffer(buf, hgs, arguments, varargs); |
3300 bodyToCBuffer(buf, hgs); | 3300 bodyToCBuffer(buf, hgs); |
3301 } | 3301 } |
3302 | 3302 |
3303 | 3303 |
3304 /********************************* DeleteDeclaration ****************************/ | 3304 /********************************* DeleteDeclaration ****************************/ |
3305 | 3305 |
3306 DeleteDeclaration::DeleteDeclaration(Loc loc, Loc endloc, Arguments *arguments) | 3306 DeleteDeclaration::DeleteDeclaration(Loc loc, Loc endloc, Parameters *arguments) |
3307 : FuncDeclaration(loc, endloc, Id::classDelete, STCstatic, NULL) | 3307 : FuncDeclaration(loc, endloc, Id::classDelete, STCstatic, NULL) |
3308 { | 3308 { |
3309 this->arguments = arguments; | 3309 this->arguments = arguments; |
3310 } | 3310 } |
3311 | 3311 |
3315 | 3315 |
3316 f = new DeleteDeclaration(loc, endloc, NULL); | 3316 f = new DeleteDeclaration(loc, endloc, NULL); |
3317 | 3317 |
3318 FuncDeclaration::syntaxCopy(f); | 3318 FuncDeclaration::syntaxCopy(f); |
3319 | 3319 |
3320 f->arguments = Argument::arraySyntaxCopy(arguments); | 3320 f->arguments = Parameter::arraySyntaxCopy(arguments); |
3321 | 3321 |
3322 return f; | 3322 return f; |
3323 } | 3323 } |
3324 | 3324 |
3325 | 3325 |
3341 type = type->semantic(loc, sc); | 3341 type = type->semantic(loc, sc); |
3342 assert(type->ty == Tfunction); | 3342 assert(type->ty == Tfunction); |
3343 | 3343 |
3344 // Check that there is only one argument of type void* | 3344 // Check that there is only one argument of type void* |
3345 TypeFunction *tf = (TypeFunction *)type; | 3345 TypeFunction *tf = (TypeFunction *)type; |
3346 if (Argument::dim(tf->parameters) != 1) | 3346 if (Parameter::dim(tf->parameters) != 1) |
3347 { | 3347 { |
3348 error("one argument of type void* expected"); | 3348 error("one argument of type void* expected"); |
3349 } | 3349 } |
3350 else | 3350 else |
3351 { | 3351 { |
3352 Argument *a = Argument::getNth(tf->parameters, 0); | 3352 Parameter *a = Parameter::getNth(tf->parameters, 0); |
3353 if (!a->type->equals(Type::tvoid->pointerTo())) | 3353 if (!a->type->equals(Type::tvoid->pointerTo())) |
3354 error("one argument of type void* expected, not %s", a->type->toChars()); | 3354 error("one argument of type void* expected, not %s", a->type->toChars()); |
3355 } | 3355 } |
3356 | 3356 |
3357 FuncDeclaration::semantic(sc); | 3357 FuncDeclaration::semantic(sc); |
3383 } | 3383 } |
3384 | 3384 |
3385 void DeleteDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) | 3385 void DeleteDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) |
3386 { | 3386 { |
3387 buf->writestring("delete"); | 3387 buf->writestring("delete"); |
3388 Argument::argsToCBuffer(buf, hgs, arguments, 0); | 3388 Parameter::argsToCBuffer(buf, hgs, arguments, 0); |
3389 bodyToCBuffer(buf, hgs); | 3389 bodyToCBuffer(buf, hgs); |
3390 } | 3390 } |
3391 | 3391 |
3392 | 3392 |
3393 | 3393 |