Mercurial > projects > ddmd
comparison dmd/TemplateDeclaration.d @ 135:af1bebfd96a4 dmd2037
dmd 2.038
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Mon, 13 Sep 2010 22:19:42 +0100 |
parents | 206db751bd4c |
children | e3afd1303184 |
comparison
equal
deleted
inserted
replaced
134:4251f96733f4 | 135:af1bebfd96a4 |
---|---|
795 if (oarg) printf("%s", oarg.toChars()); | 795 if (oarg) printf("%s", oarg.toChars()); |
796 printf("\n"); | 796 printf("\n"); |
797 } | 797 } |
798 } | 798 } |
799 | 799 |
800 if (fd.type) | 800 fparameters = fd.getParameters(&fvarargs); |
801 { | |
802 assert(fd.type.ty == Tfunction); | |
803 TypeFunction fdtype = cast(TypeFunction)fd.type; | |
804 fparameters = fdtype.parameters; | |
805 fvarargs = fdtype.varargs; | |
806 } | |
807 else | |
808 { | |
809 CtorDeclaration fctor = fd.isCtorDeclaration(); | |
810 assert(fctor); | |
811 fparameters = fctor.arguments; | |
812 fvarargs = fctor.varargs; | |
813 } | |
814 | |
815 nfparams = Parameter.dim(fparameters); // number of function parameters | 801 nfparams = Parameter.dim(fparameters); // number of function parameters |
816 nfargs = fargs ? fargs.dim : 0; // number of function arguments | 802 nfargs = fargs ? fargs.dim : 0; // number of function arguments |
817 | 803 |
818 /* Check for match of function arguments with variadic template | 804 /* Check for match of function arguments with variadic template |
819 * parameter, such as: | 805 * parameter, such as: |
1256 /* The best match is td_best with arguments tdargs. | 1242 /* The best match is td_best with arguments tdargs. |
1257 * Now instantiate the template. | 1243 * Now instantiate the template. |
1258 */ | 1244 */ |
1259 assert(cast(size_t)cast(void*)td_best.scope_ > 0x10000); | 1245 assert(cast(size_t)cast(void*)td_best.scope_ > 0x10000); |
1260 ti = new TemplateInstance(loc, td_best, tdargs); | 1246 ti = new TemplateInstance(loc, td_best, tdargs); |
1261 ti.semantic(sc); | 1247 ti.semantic(sc, fargs); |
1262 fd = ti.toAlias().isFuncDeclaration(); | 1248 fd = ti.toAlias().isFuncDeclaration(); |
1263 if (!fd) | 1249 if (!fd) |
1264 goto Lerror; | 1250 goto Lerror; |
1265 return fd; | 1251 return fd; |
1266 | 1252 |
1388 FuncDeclaration fd = onemember && onemember.toAlias() ? | 1374 FuncDeclaration fd = onemember && onemember.toAlias() ? |
1389 onemember.toAlias().isFuncDeclaration() : null; | 1375 onemember.toAlias().isFuncDeclaration() : null; |
1390 if (fd) | 1376 if (fd) |
1391 { | 1377 { |
1392 paramscope.parent = fd; | 1378 paramscope.parent = fd; |
1393 Parameters fparameters; // function parameter list | |
1394 int fvarargs; // function varargs | 1379 int fvarargs; // function varargs |
1395 if (fd.type) | 1380 Parameters fparameters = fd.getParameters(&fvarargs); |
1396 { | |
1397 assert(fd.type.ty == Tfunction); | |
1398 TypeFunction fdtype = cast(TypeFunction )fd.type; | |
1399 fparameters = fdtype.parameters; | |
1400 fvarargs = fdtype.varargs; | |
1401 } | |
1402 else // Constructors don't have type's | |
1403 { CtorDeclaration fctor = fd.isCtorDeclaration(); | |
1404 assert(fctor); | |
1405 fparameters = fctor.arguments; | |
1406 fvarargs = fctor.varargs; | |
1407 } | |
1408 size_t nfparams = Parameter.dim(fparameters); // Num function parameters | 1381 size_t nfparams = Parameter.dim(fparameters); // Num function parameters |
1409 for (int i = 0; i < nfparams; i++) | 1382 for (int i = 0; i < nfparams; i++) |
1410 { | 1383 { |
1411 Parameter fparam = Parameter.getNth(fparameters, i).syntaxCopy(); | 1384 Parameter fparam = Parameter.getNth(fparameters, i).syntaxCopy(); |
1412 if (!fparam.ident) | 1385 if (!fparam.ident) |