comparison dmd/Type.d @ 121:347de076ad34

TemplateParameters -> Vector
author Eldar Insafutdinov <e.insafutdinov@gmail.com>
date Thu, 02 Sep 2010 22:41:12 +0100
parents e28b18c23469
children 60bb0fe4563e
comparison
equal deleted inserted replaced
120:46ef67271ef3 121:347de076ad34
98 * Return -1 if not found. 98 * Return -1 if not found.
99 */ 99 */
100 100
101 int templateIdentifierLookup(Identifier id, TemplateParameters parameters) 101 int templateIdentifierLookup(Identifier id, TemplateParameters parameters)
102 { 102 {
103 for (size_t i = 0; i < parameters.dim; i++) 103 foreach (size_t i, TemplateParameter tp; parameters)
104 { 104 {
105 TemplateParameter tp = cast(TemplateParameter)parameters.data[i];
106
107 if (tp.ident.equals(id)) 105 if (tp.ident.equals(id))
108 return i; 106 return i;
109 } 107 }
110 return -1; 108 return -1;
111 } 109 }
1891 /* Need a loc to go with the semantic routine. 1889 /* Need a loc to go with the semantic routine.
1892 */ 1890 */
1893 Loc loc; 1891 Loc loc;
1894 if (parameters.dim) 1892 if (parameters.dim)
1895 { 1893 {
1896 TemplateParameter tp = cast(TemplateParameter)parameters.data[0]; 1894 auto tp = parameters[0];
1897 loc = tp.loc; 1895 loc = tp.loc;
1898 } 1896 }
1899 1897
1900 /* BUG: what if tparam is a template instance, that 1898 /* BUG: what if tparam is a template instance, that
1901 * has as an argument another Tident? 1899 * has as an argument another Tident?
1903 tparam = tparam.semantic(loc, sc); 1901 tparam = tparam.semantic(loc, sc);
1904 assert(tparam.ty != Tident); 1902 assert(tparam.ty != Tident);
1905 return deduceType(sc, tparam, parameters, dedtypes); 1903 return deduceType(sc, tparam, parameters, dedtypes);
1906 } 1904 }
1907 1905
1908 TemplateParameter tp = cast(TemplateParameter)parameters.data[i]; 1906 auto tp = parameters[i];
1909 1907
1910 // Found the corresponding parameter tp 1908 // Found the corresponding parameter tp
1911 if (!tp.isTemplateTypeParameter()) 1909 if (!tp.isTemplateTypeParameter())
1912 goto Lnomatch; 1910 goto Lnomatch;
1913 Type tt = this; 1911 Type tt = this;