Mercurial > projects > ddmd
comparison dmd/TemplateDeclaration.d @ 94:3a0b150c9841
Objects -> Vector!Object iteration 1
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Mon, 30 Aug 2010 23:00:34 +0100 |
parents | 39648eb578f6 |
children | a1cf34da9ebe |
comparison
equal
deleted
inserted
replaced
93:df6d0f967680 | 94:3a0b150c9841 |
---|---|
595 ti.tiargs.setDim(parameters.dim); | 595 ti.tiargs.setDim(parameters.dim); |
596 for (int i = 0; i < ti.tiargs.dim; i++) | 596 for (int i = 0; i < ti.tiargs.dim; i++) |
597 { | 597 { |
598 TemplateParameter tp = cast(TemplateParameter)parameters.data[i]; | 598 TemplateParameter tp = cast(TemplateParameter)parameters.data[i]; |
599 | 599 |
600 void* p = tp.dummyArg(); | 600 auto p = tp.dummyArg(); |
601 if (p) | 601 if (p) |
602 ti.tiargs.data[i] = p; | 602 ti.tiargs[i] = p; |
603 else | 603 else |
604 ti.tiargs.setDim(i); | 604 ti.tiargs.setDim(i); |
605 } | 605 } |
606 | 606 |
607 // Temporary Array to hold deduced types | 607 // Temporary Array to hold deduced types |
708 goto Lnomatch; | 708 goto Lnomatch; |
709 | 709 |
710 /* The extra initial template arguments | 710 /* The extra initial template arguments |
711 * now form the tuple argument. | 711 * now form the tuple argument. |
712 */ | 712 */ |
713 Tuple t = new Tuple(); | 713 auto t = new Tuple(); |
714 assert(parameters.dim); | 714 assert(parameters.dim); |
715 dedargs.data[parameters.dim - 1] = cast(void*)t; | 715 dedargs[parameters.dim - 1] = t; |
716 | 716 |
717 tuple_dim = nargsi - n; | 717 tuple_dim = nargsi - n; |
718 t.objects.setDim(tuple_dim); | 718 t.objects.setDim(tuple_dim); |
719 for (size_t i = 0; i < tuple_dim; i++) | 719 for (size_t i = 0; i < tuple_dim; i++) |
720 { | 720 { |
721 t.objects.data[i] = cast(void*)targsi.data[n + i]; | 721 t.objects[i] = targsi[n + i]; |
722 } | 722 } |
723 declareParameter(paramscope, tp, t); | 723 declareParameter(paramscope, tp, t); |
724 } | 724 } |
725 else | 725 else |
726 n = nargsi; | 726 n = nargsi; |
783 */ | 783 */ |
784 if (tp) // if variadic | 784 if (tp) // if variadic |
785 { | 785 { |
786 if (nfparams == 0 && nfargs != 0) // if no function parameters | 786 if (nfparams == 0 && nfargs != 0) // if no function parameters |
787 { | 787 { |
788 Tuple t = new Tuple(); | 788 auto t = new Tuple(); |
789 //printf("t = %p\n", t); | 789 //printf("t = %p\n", t); |
790 dedargs.data[parameters.dim - 1] = cast(void*)t; | 790 dedargs[parameters.dim - 1] = t; |
791 declareParameter(paramscope, tp, t); | 791 declareParameter(paramscope, tp, t); |
792 goto L2; | 792 goto L2; |
793 } | 793 } |
794 else if (nfargs < nfparams - 1) | 794 else if (nfargs < nfparams - 1) |
795 goto L1; | 795 goto L1; |
813 goto Lnomatch; // go with variadic template | 813 goto Lnomatch; // go with variadic template |
814 | 814 |
815 /* The types of the function arguments | 815 /* The types of the function arguments |
816 * now form the tuple argument. | 816 * now form the tuple argument. |
817 */ | 817 */ |
818 Tuple t = new Tuple(); | 818 auto t = new Tuple(); |
819 dedargs.data[parameters.dim - 1] = cast(void*)t; | 819 dedargs[parameters.dim - 1] = t; |
820 | 820 |
821 tuple_dim = nfargs - (nfparams - 1); | 821 tuple_dim = nfargs - (nfparams - 1); |
822 t.objects.setDim(tuple_dim); | 822 t.objects.setDim(tuple_dim); |
823 for (size_t i = 0; i < tuple_dim; i++) | 823 for (size_t i = 0; i < tuple_dim; i++) |
824 { | 824 { |
825 auto farg = fargs[fptupindex + i]; | 825 auto farg = fargs[fptupindex + i]; |
826 t.objects.data[i] = cast(void*)farg.type; | 826 t.objects[i] = farg.type; |
827 } | 827 } |
828 declareParameter(paramscope, tp, t); | 828 declareParameter(paramscope, tp, t); |
829 goto L2; | 829 goto L2; |
830 } | 830 } |
831 fptupindex = -1; | 831 fptupindex = -1; |
1036 { | 1036 { |
1037 /* The specialization can work as long as afterwards | 1037 /* The specialization can work as long as afterwards |
1038 * the oded == oarg | 1038 * the oded == oarg |
1039 */ | 1039 */ |
1040 Declaration sparam; | 1040 Declaration sparam; |
1041 dedargs.data[i] = cast(void*)oded; | 1041 dedargs[i] = oded; |
1042 MATCH m2 = tp2.matchArg(paramscope, dedargs, i, parameters, dedtypes, &sparam, 0); | 1042 MATCH m2 = tp2.matchArg(paramscope, dedargs, i, parameters, dedtypes, &sparam, 0); |
1043 //printf("m2 = %d\n", m2); | 1043 //printf("m2 = %d\n", m2); |
1044 if (!m2) | 1044 if (!m2) |
1045 goto Lnomatch; | 1045 goto Lnomatch; |
1046 if (m2 < match) | 1046 if (m2 < match) |
1047 match = m2; // pick worst match | 1047 match = m2; // pick worst match |
1048 if (dedtypes.data[i] !is cast(void*)oded) | 1048 if (dedtypes[i] !is oded) |
1049 error("specialization not allowed for deduced parameter %s", tp2.ident.toChars()); | 1049 error("specialization not allowed for deduced parameter %s", tp2.ident.toChars()); |
1050 } | 1050 } |
1051 } | 1051 } |
1052 else | 1052 else |
1053 { | 1053 { |
1054 oded = tp2.defaultArg(loc, paramscope); | 1054 oded = tp2.defaultArg(loc, paramscope); |
1055 if (!oded) | 1055 if (!oded) |
1056 goto Lnomatch; | 1056 goto Lnomatch; |
1057 } | 1057 } |
1058 declareParameter(paramscope, tp2, oded); | 1058 declareParameter(paramscope, tp2, oded); |
1059 dedargs.data[i] = cast(void*)oded; | 1059 dedargs[i] = oded; |
1060 } | 1060 } |
1061 } | 1061 } |
1062 | 1062 |
1063 version (DMDV2) { | 1063 version (DMDV2) { |
1064 if (constraint) | 1064 if (constraint) |