Mercurial > projects > ldc
comparison dmd/template.c @ 130:a7dfa0ed966c trunk
[svn r134] Merged the DMD 1.024 frontend.
Added std.base64.
author | lindquist |
---|---|
date | Fri, 28 Dec 2007 23:52:40 +0100 |
parents | 70d6113eeb8c |
children | 0ab29b838084 |
comparison
equal
deleted
inserted
replaced
129:8096ba7082db | 130:a7dfa0ed966c |
---|---|
645 * fargs arguments to function | 645 * fargs arguments to function |
646 * Output: | 646 * Output: |
647 * dedargs Expression/Type deduced template arguments | 647 * dedargs Expression/Type deduced template arguments |
648 */ | 648 */ |
649 | 649 |
650 MATCH TemplateDeclaration::deduceMatch(Objects *targsi, Expressions *fargs, | 650 MATCH TemplateDeclaration::deduceFunctionTemplateMatch(Objects *targsi, Expressions *fargs, |
651 Objects *dedargs) | 651 Objects *dedargs) |
652 { | 652 { |
653 size_t i; | 653 size_t i; |
654 size_t nfparams; | 654 size_t nfparams; |
655 size_t nfparams2; | 655 size_t nfparams2; |
660 TypeFunction *fdtype; | 660 TypeFunction *fdtype; |
661 TemplateTupleParameter *tp; | 661 TemplateTupleParameter *tp; |
662 Objects dedtypes; // for T:T*, the dedargs is the T*, dedtypes is the T | 662 Objects dedtypes; // for T:T*, the dedargs is the T*, dedtypes is the T |
663 | 663 |
664 #if 0 | 664 #if 0 |
665 printf("\nTemplateDeclaration::deduceMatch() %s\n", toChars()); | 665 printf("\nTemplateDeclaration::deduceFunctionTemplateMatch() %s\n", toChars()); |
666 for (i = 0; i < fargs->dim; i++) | 666 for (i = 0; i < fargs->dim; i++) |
667 { Expression *e = (Expression *)fargs->data[i]; | 667 { Expression *e = (Expression *)fargs->data[i]; |
668 printf("\tfarg[%d] is %s, type is %s\n", i, e->toChars(), e->type->toChars()); | 668 printf("\tfarg[%d] is %s, type is %s\n", i, e->toChars(), e->type->toChars()); |
669 } | 669 } |
670 #endif | 670 #endif |
983 * Input: | 983 * Input: |
984 * targsi initial list of template arguments | 984 * targsi initial list of template arguments |
985 * fargs arguments to function | 985 * fargs arguments to function |
986 */ | 986 */ |
987 | 987 |
988 FuncDeclaration *TemplateDeclaration::deduce(Scope *sc, Loc loc, | 988 FuncDeclaration *TemplateDeclaration::deduceFunctionTemplate(Scope *sc, Loc loc, |
989 Objects *targsi, Expressions *fargs) | 989 Objects *targsi, Expressions *fargs) |
990 { | 990 { |
991 MATCH m_best = MATCHnomatch; | 991 MATCH m_best = MATCHnomatch; |
992 TemplateDeclaration *td_ambig = NULL; | 992 TemplateDeclaration *td_ambig = NULL; |
993 TemplateDeclaration *td_best = NULL; | 993 TemplateDeclaration *td_best = NULL; |
994 Objects *tdargs = new Objects(); | 994 Objects *tdargs = new Objects(); |
995 TemplateInstance *ti; | 995 TemplateInstance *ti; |
996 FuncDeclaration *fd; | 996 FuncDeclaration *fd; |
997 | 997 |
998 #if 0 | 998 #if 0 |
999 printf("TemplateDeclaration::deduce() %s\n", toChars()); | 999 printf("TemplateDeclaration::deduceFunctionTemplate() %s\n", toChars()); |
1000 printf(" targsi:\n"); | 1000 printf(" targsi:\n"); |
1001 if (targsi) | 1001 if (targsi) |
1002 { for (int i = 0; i < targsi->dim; i++) | 1002 { for (int i = 0; i < targsi->dim; i++) |
1003 { Object *arg = (Object *)targsi->data[i]; | 1003 { Object *arg = (Object *)targsi->data[i]; |
1004 printf("\t%s\n", arg->toChars()); | 1004 printf("\t%s\n", arg->toChars()); |
1026 } | 1026 } |
1027 | 1027 |
1028 MATCH m; | 1028 MATCH m; |
1029 Objects dedargs; | 1029 Objects dedargs; |
1030 | 1030 |
1031 m = td->deduceMatch(targsi, fargs, &dedargs); | 1031 m = td->deduceFunctionTemplateMatch(targsi, fargs, &dedargs); |
1032 //printf("deduceMatch = %d\n", m); | 1032 //printf("deduceFunctionTemplateMatch = %d\n", m); |
1033 if (!m) // if no match | 1033 if (!m) // if no match |
1034 continue; | 1034 continue; |
1035 | 1035 |
1036 if (m < m_best) | 1036 if (m < m_best) |
1037 goto Ltd_best; | 1037 goto Ltd_best; |