Changeset 635
- Timestamp:
- 08/28/10 03:51:12 (14 years ago)
- Files:
-
- branches/dmd-1.x/src/template.c (modified) (1 diff)
- trunk/src/template.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmd-1.x/src/template.c
r632 r635 948 948 if (ethis) 949 949 { 950 950 for (size_t i = 0; i < parameters->dim; i++) 951 951 { TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; 952 952 TemplateThisParameter *ttp = tp->isTemplateThisParameter(); 953 953 if (ttp) 954 954 { MATCH m; 955 955 956 956 Type *t = new TypeIdentifier(0, ttp->ident); 957 957 m = ethis->type->deduceType(paramscope, t, parameters, &dedtypes); 958 958 if (!m) 959 959 goto Lnomatch; 960 960 if (m < match) 961 961 match = m; // pick worst match 962 962 } 963 963 } 964 964 } 965 965 #endif 966 966 967 967 // Loop through the function parameters 968 for ( i = 0; i < nfparams;i++)968 for (size_t parami = 0; parami < nfparams; parami++) 969 969 { 970 970 /* Skip over function parameters which wound up 971 971 * as part of a template tuple parameter. 972 972 */ 973 if (i == fptupindex) 974 { if (fptupindex == nfparams - 1) 975 break; 973 if (parami == fptupindex) 974 continue; 975 /* Set i = index into function arguments 976 * Function parameters correspond to function arguments as follows. 977 * Note that tuple_dim may be zero, and there may be default or 978 * variadic arguments at the end. 979 * arg [0..fptupindex] == param[0..fptupindex] 980 * arg [fptupindex..fptupindex+tuple_dim] == param[fptupindex] 981 * arg[fputupindex+dim.. ] == param[fptupindex+1.. ] 982 */ 983 i = parami; 984 if (fptupindex >= 0 && parami > fptupindex) 976 985 i += tuple_dim - 1; 977 continue; 978 } 979 980 Parameter *fparam = Parameter::getNth(fparameters, i); 986 987 Parameter *fparam = Parameter::getNth(fparameters, parami); 981 988 982 989 if (i >= nfargs) // if not enough arguments 983 990 { 984 991 if (fparam->defaultArg) 985 992 { /* Default arguments do not participate in template argument 986 993 * deduction. 987 994 */ 988 995 goto Lmatch; 989 996 } 990 997 } 991 998 else 992 999 { Expression *farg = (Expression *)fargs->data[i]; 993 1000 #if 0 994 1001 printf("\tfarg->type = %s\n", farg->type->toChars()); 995 1002 printf("\tfparam->type = %s\n", fparam->type->toChars()); 996 1003 #endif 997 1004 Type *argtype = farg->type; 998 1005 999 1006 #if DMDV2 1000 1007 /* Allow string literals which are type [] to match with [dim] trunk/src/template.c
r632 r635 1072 1072 mod |= MODconst; 1073 1073 if (stc & STCwild) 1074 1074 mod |= MODwild; 1075 1075 // Fix mod 1076 1076 if (mod & MODimmutable) 1077 1077 mod = MODimmutable; 1078 1078 if (mod & MODconst) 1079 1079 mod &= ~STCwild; 1080 1080 if (tthis->mod != mod) 1081 1081 { 1082 1082 if (!MODimplicitConv(tthis->mod, mod)) 1083 1083 goto Lnomatch; 1084 1084 if (MATCHconst < match) 1085 1085 match = MATCHconst; 1086 1086 } 1087 1087 } 1088 1088 } 1089 1089 #endif 1090 1090 1091 1091 // Loop through the function parameters 1092 for ( i = 0; i < nfparams;i++)1092 for (size_t parami = 0; parami < nfparams; parami++) 1093 1093 { 1094 1094 /* Skip over function parameters which wound up 1095 1095 * as part of a template tuple parameter. 1096 1096 */ 1097 if (i == fptupindex) 1098 { if (fptupindex == nfparams - 1) 1099 break; 1097 if (parami == fptupindex) 1098 continue; 1099 /* Set i = index into function arguments 1100 * Function parameters correspond to function arguments as follows. 1101 * Note that tuple_dim may be zero, and there may be default or 1102 * variadic arguments at the end. 1103 * arg [0..fptupindex] == param[0..fptupindex] 1104 * arg [fptupindex..fptupindex+tuple_dim] == param[fptupindex] 1105 * arg[fputupindex+dim.. ] == param[fptupindex+1.. ] 1106 */ 1107 i = parami; 1108 if (fptupindex >= 0 && parami > fptupindex) 1100 1109 i += tuple_dim - 1; 1101 continue; 1102 } 1103 1104 Parameter *fparam = Parameter::getNth(fparameters, i); 1110 1111 Parameter *fparam = Parameter::getNth(fparameters, parami); 1105 1112 1106 1113 if (i >= nfargs) // if not enough arguments 1107 1114 { 1108 1115 if (fparam->defaultArg) 1109 1116 { /* Default arguments do not participate in template argument 1110 1117 * deduction. 1111 1118 */ 1112 1119 goto Lmatch; 1113 1120 } 1114 1121 } 1115 1122 else 1116 1123 { Expression *farg = (Expression *)fargs->data[i]; 1117 1124 #if 0 1118 1125 printf("\tfarg->type = %s\n", farg->type->toChars()); 1119 1126 printf("\tfparam->type = %s\n", fparam->type->toChars()); 1120 1127 #endif 1121 1128 Type *argtype = farg->type; 1122 1129 1123 1130 #if DMDV2 1124 1131 /* Allow string literals which are type [] to match with [dim]
