comparison dmd/TemplateDeclaration.d @ 113:3482c73a991b

More cleanup for arrays
author Eldar Insafutdinov <e.insafutdinov@gmail.com>
date Tue, 31 Aug 2010 23:57:32 +0100
parents 12c0c84d13fd
children e28b18c23469
comparison
equal deleted inserted replaced
112:3f02152c5e68 113:3482c73a991b
85 Objects args = v.objects; 85 Objects args = v.objects;
86 for (size_t i = 0; i < args.dim; i++) 86 for (size_t i = 0; i < args.dim; i++)
87 { 87 {
88 if (i) 88 if (i)
89 buf.writeByte(','); 89 buf.writeByte(',');
90 Object o = cast(Object)args.data[i]; 90 Object o = args[i];
91 ObjectToCBuffer(buf, hgs, o); 91 ObjectToCBuffer(buf, hgs, o);
92 } 92 }
93 } 93 }
94 else if (!oarg) 94 else if (!oarg)
95 { 95 {
535 /* Any parameter left without a type gets the type of 535 /* Any parameter left without a type gets the type of
536 * its corresponding arg 536 * its corresponding arg
537 */ 537 */
538 for (int i = 0; i < dedtypes_dim; i++) 538 for (int i = 0; i < dedtypes_dim; i++)
539 { 539 {
540 if (!dedtypes.data[i]) 540 if (!dedtypes[i])
541 { 541 {
542 assert(i < ti.tiargs.dim); 542 assert(i < ti.tiargs.dim);
543 dedtypes.data[i] = ti.tiargs.data[i]; 543 dedtypes[i] = ti.tiargs[i];
544 } 544 }
545 } 545 }
546 } 546 }
547 547
548 version (DMDV2) { 548 version (DMDV2) {
764 declareParameter(paramscope, tp, t); 764 declareParameter(paramscope, tp, t);
765 } 765 }
766 else 766 else
767 n = nargsi; 767 n = nargsi;
768 768
769 memcpy(dedargs.data, targsi.data, n * (*dedargs.data).sizeof); 769 memcpy(dedargs.ptr, targsi.ptr, n * (*dedargs.ptr).sizeof);
770 770
771 for (size_t i = 0; i < n; i++) 771 for (size_t i = 0; i < n; i++)
772 { 772 {
773 assert(i < parameters.dim); 773 assert(i < parameters.dim);
774 TemplateParameter tp2 = cast(TemplateParameter)parameters.data[i]; 774 auto tp2 = cast(TemplateParameter)parameters.data[i];
775 MATCH m; 775 MATCH m;
776 Declaration sparam = null; 776 Declaration sparam = null;
777 777
778 m = tp2.matchArg(paramscope, dedargs, i, parameters, dedtypes, &sparam); 778 m = tp2.matchArg(paramscope, dedargs, i, parameters, dedtypes, &sparam);
779 //printf("\tdeduceType m = %d\n", m); 779 //printf("\tdeduceType m = %d\n", m);
1057 1057
1058 /* Fill in any missing arguments with their defaults. 1058 /* Fill in any missing arguments with their defaults.
1059 */ 1059 */
1060 for (size_t i = nargsi; i < dedargs.dim; i++) 1060 for (size_t i = nargsi; i < dedargs.dim; i++)
1061 { 1061 {
1062 TemplateParameter tp2 = cast(TemplateParameter)parameters.data[i]; 1062 auto tp2 = cast(TemplateParameter)parameters.data[i];
1063 //printf("tp2[%d] = %s\n", i, tp2.ident.toChars()); 1063 //printf("tp2[%d] = %s\n", i, tp2.ident.toChars());
1064 /* For T:T*, the dedargs is the T*, dedtypes is the T 1064 /* For T:T*, the dedargs is the T*, dedtypes is the T
1065 * But for function templates, we really need them to match 1065 * But for function templates, we really need them to match
1066 */ 1066 */
1067 Object oarg = cast(Object)dedargs.data[i]; 1067 Object oarg = dedargs[i];
1068 Object oded = cast(Object)dedtypes.data[i]; 1068 Object oded = dedtypes[i];
1069 //printf("1dedargs[%d] = %p, dedtypes[%d] = %p\n", i, oarg, i, oded); 1069 //printf("1dedargs[%d] = %p, dedtypes[%d] = %p\n", i, oarg, i, oded);
1070 //if (oarg) printf("oarg: %s\n", oarg.toChars()); 1070 //if (oarg) printf("oarg: %s\n", oarg.toChars());
1071 //if (oded) printf("oded: %s\n", oded.toChars()); 1071 //if (oded) printf("oded: %s\n", oded.toChars());
1072 if (!oarg) 1072 if (!oarg)
1073 { 1073 {
1231 td_ambig = null; 1231 td_ambig = null;
1232 assert(cast(size_t)cast(void*)td.scope_ > 0x10000); 1232 assert(cast(size_t)cast(void*)td.scope_ > 0x10000);
1233 td_best = td; 1233 td_best = td;
1234 m_best = m; 1234 m_best = m;
1235 tdargs.setDim(dedargs.dim); 1235 tdargs.setDim(dedargs.dim);
1236 memcpy(tdargs.data, dedargs.data, tdargs.dim * (void*).sizeof); 1236 memcpy(tdargs.ptr, dedargs.ptr, tdargs.dim * (void*).sizeof);
1237 continue; 1237 continue;
1238 } 1238 }
1239 if (!td_best) 1239 if (!td_best)
1240 { 1240 {
1241 if (!(flags & 1)) 1241 if (!(flags & 1))
1272 { 1272 {
1273 for (int i = 0; i < args.dim; i++) 1273 for (int i = 0; i < args.dim; i++)
1274 { 1274 {
1275 if (i) 1275 if (i)
1276 bufa.writeByte(','); 1276 bufa.writeByte(',');
1277 Object oarg = cast(Object)args.data[i]; 1277 Object oarg = args[i];
1278 ObjectToCBuffer(bufa, &hgs, oarg); 1278 ObjectToCBuffer(bufa, &hgs, oarg);
1279 } 1279 }
1280 } 1280 }
1281 1281
1282 scope OutBuffer buf = new OutBuffer(); 1282 scope OutBuffer buf = new OutBuffer();