comparison dmd/opover.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 def7a1d494fd
children
comparison
equal deleted inserted replaced
1606:1b24e9c7cc26 1607:207a8a438dea
29 #include "aggregate.h" 29 #include "aggregate.h"
30 #include "template.h" 30 #include "template.h"
31 #include "scope.h" 31 #include "scope.h"
32 32
33 static Expression *build_overload(Loc loc, Scope *sc, Expression *ethis, Expression *earg, Identifier *id); 33 static Expression *build_overload(Loc loc, Scope *sc, Expression *ethis, Expression *earg, Identifier *id);
34 static void inferApplyArgTypesX(Module* from, FuncDeclaration *fstart, Arguments *arguments); 34 static void inferApplyArgTypesX(Module* from, FuncDeclaration *fstart, Parameters *arguments);
35 static int inferApplyArgTypesY(TypeFunction *tf, Arguments *arguments); 35 static int inferApplyArgTypesY(TypeFunction *tf, Parameters *arguments);
36 static void templateResolve(Match *m, TemplateDeclaration *td, Scope *sc, Loc loc, Objects *targsi, Expression *ethis, Expressions *arguments); 36 static void templateResolve(Match *m, TemplateDeclaration *td, Scope *sc, Loc loc, Objects *targsi, Expression *ethis, Expressions *arguments);
37 37
38 /******************************** Expression **************************/ 38 /******************************** Expression **************************/
39 39
40 40
525 * Given array of arguments and an aggregate type, 525 * Given array of arguments and an aggregate type,
526 * if any of the argument types are missing, attempt to infer 526 * if any of the argument types are missing, attempt to infer
527 * them from the aggregate type. 527 * them from the aggregate type.
528 */ 528 */
529 529
530 void inferApplyArgTypes(enum TOK op, Arguments *arguments, Expression *aggr, Module* from) 530 void inferApplyArgTypes(enum TOK op, Parameters *arguments, Expression *aggr, Module* from)
531 { 531 {
532 if (!arguments || !arguments->dim) 532 if (!arguments || !arguments->dim)
533 return; 533 return;
534 534
535 /* Return if no arguments need types. 535 /* Return if no arguments need types.
536 */ 536 */
537 for (size_t u = 0; 1; u++) 537 for (size_t u = 0; 1; u++)
538 { if (u == arguments->dim) 538 { if (u == arguments->dim)
539 return; 539 return;
540 Argument *arg = (Argument *)arguments->data[u]; 540 Parameter *arg = (Parameter *)arguments->data[u];
541 if (!arg->type) 541 if (!arg->type)
542 break; 542 break;
543 } 543 }
544 544
545 AggregateDeclaration *ad; 545 AggregateDeclaration *ad;
546 546
547 Argument *arg = (Argument *)arguments->data[0]; 547 Parameter *arg = (Parameter *)arguments->data[0];
548 Type *taggr = aggr->type; 548 Type *taggr = aggr->type;
549 if (!taggr) 549 if (!taggr)
550 return; 550 return;
551 Type *tab = taggr->toBasetype(); 551 Type *tab = taggr->toBasetype();
552 switch (tab->ty) 552 switch (tab->ty)
556 case Ttuple: 556 case Ttuple:
557 if (arguments->dim == 2) 557 if (arguments->dim == 2)
558 { 558 {
559 if (!arg->type) 559 if (!arg->type)
560 arg->type = Type::tsize_t; // key type 560 arg->type = Type::tsize_t; // key type
561 arg = (Argument *)arguments->data[1]; 561 arg = (Parameter *)arguments->data[1];
562 } 562 }
563 if (!arg->type && tab->ty != Ttuple) 563 if (!arg->type && tab->ty != Ttuple)
564 arg->type = tab->nextOf(); // value type 564 arg->type = tab->nextOf(); // value type
565 break; 565 break;
566 566
569 569
570 if (arguments->dim == 2) 570 if (arguments->dim == 2)
571 { 571 {
572 if (!arg->type) 572 if (!arg->type)
573 arg->type = taa->index; // key type 573 arg->type = taa->index; // key type
574 arg = (Argument *)arguments->data[1]; 574 arg = (Parameter *)arguments->data[1];
575 } 575 }
576 if (!arg->type) 576 if (!arg->type)
577 arg->type = taa->next; // value type 577 arg->type = taa->next; // value type
578 break; 578 break;
579 } 579 }
646 * analogous to func.overloadResolveX(). 646 * analogous to func.overloadResolveX().
647 */ 647 */
648 648
649 int fp3(void *param, FuncDeclaration *f) 649 int fp3(void *param, FuncDeclaration *f)
650 { 650 {
651 Arguments *arguments = (Arguments *)param; 651 Parameters *arguments = (Parameters *)param;
652 TypeFunction *tf = (TypeFunction *)f->type; 652 TypeFunction *tf = (TypeFunction *)f->type;
653 if (inferApplyArgTypesY(tf, arguments) == 1) 653 if (inferApplyArgTypesY(tf, arguments) == 1)
654 return 0; 654 return 0;
655 if (arguments->dim == 0) 655 if (arguments->dim == 0)
656 return 1; 656 return 1;
657 return 0; 657 return 0;
658 } 658 }
659 659
660 static void inferApplyArgTypesX(Module* from, FuncDeclaration *fstart, Arguments *arguments) 660 static void inferApplyArgTypesX(Module* from, FuncDeclaration *fstart, Parameters *arguments)
661 { 661 {
662 overloadApply(from, fstart, &fp3, arguments); 662 overloadApply(from, fstart, &fp3, arguments);
663 } 663 }
664 664
665 #if 0 665 #if 0
666 static void inferApplyArgTypesX(FuncDeclaration *fstart, Arguments *arguments) 666 static void inferApplyArgTypesX(FuncDeclaration *fstart, Parameters *arguments)
667 { 667 {
668 Declaration *d; 668 Declaration *d;
669 Declaration *next; 669 Declaration *next;
670 670
671 for (d = fstart; d; d = next) 671 for (d = fstart; d; d = next)
712 * Returns: 712 * Returns:
713 * 0 match for this function 713 * 0 match for this function
714 * 1 no match for this function 714 * 1 no match for this function
715 */ 715 */
716 716
717 static int inferApplyArgTypesY(TypeFunction *tf, Arguments *arguments) 717 static int inferApplyArgTypesY(TypeFunction *tf, Parameters *arguments)
718 { size_t nparams; 718 { size_t nparams;
719 Argument *p; 719 Parameter *p;
720 720
721 if (Argument::dim(tf->parameters) != 1) 721 if (Parameter::dim(tf->parameters) != 1)
722 goto Lnomatch; 722 goto Lnomatch;
723 p = Argument::getNth(tf->parameters, 0); 723 p = Parameter::getNth(tf->parameters, 0);
724 if (p->type->ty != Tdelegate) 724 if (p->type->ty != Tdelegate)
725 goto Lnomatch; 725 goto Lnomatch;
726 tf = (TypeFunction *)p->type->nextOf(); 726 tf = (TypeFunction *)p->type->nextOf();
727 assert(tf->ty == Tfunction); 727 assert(tf->ty == Tfunction);
728 728
729 /* We now have tf, the type of the delegate. Match it against 729 /* We now have tf, the type of the delegate. Match it against
730 * the arguments, filling in missing argument types. 730 * the arguments, filling in missing argument types.
731 */ 731 */
732 nparams = Argument::dim(tf->parameters); 732 nparams = Parameter::dim(tf->parameters);
733 if (nparams == 0 || tf->varargs) 733 if (nparams == 0 || tf->varargs)
734 goto Lnomatch; // not enough parameters 734 goto Lnomatch; // not enough parameters
735 if (arguments->dim != nparams) 735 if (arguments->dim != nparams)
736 goto Lnomatch; // not enough parameters 736 goto Lnomatch; // not enough parameters
737 737
738 for (size_t u = 0; u < nparams; u++) 738 for (size_t u = 0; u < nparams; u++)
739 { 739 {
740 Argument *arg = (Argument *)arguments->data[u]; 740 Parameter *arg = (Parameter *)arguments->data[u];
741 Argument *param = Argument::getNth(tf->parameters, u); 741 Parameter *param = Parameter::getNth(tf->parameters, u);
742 if (arg->type) 742 if (arg->type)
743 { if (!arg->type->equals(param->type)) 743 { if (!arg->type->equals(param->type))
744 { 744 {
745 /* Cannot resolve argument types. Indicate an 745 /* Cannot resolve argument types. Indicate an
746 * error by setting the number of arguments to 0. 746 * error by setting the number of arguments to 0.