Mercurial > projects > ddmd
comparison dmd/TemplateInstance.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 |
---|---|
142 if (v1.objects.dim != v2.objects.dim) | 142 if (v1.objects.dim != v2.objects.dim) |
143 goto Lnomatch; | 143 goto Lnomatch; |
144 | 144 |
145 for (size_t i = 0; i < v1.objects.dim; i++) | 145 for (size_t i = 0; i < v1.objects.dim; i++) |
146 { | 146 { |
147 if (!match(cast(Object)v1.objects.data[i], cast(Object)v2.objects.data[i], tempdecl, sc)) | 147 if (!match(v1.objects[i], v2.objects[i], tempdecl, sc)) |
148 goto Lnomatch; | 148 goto Lnomatch; |
149 } | 149 } |
150 } | 150 } |
151 //printf("match\n"); | 151 //printf("match\n"); |
152 return true; // match | 152 return true; // match |
354 if (isnested && sc.parent != ti.parent) | 354 if (isnested && sc.parent != ti.parent) |
355 continue; | 355 continue; |
356 } | 356 } |
357 for (size_t j = 0; j < tdtypes.dim; j++) | 357 for (size_t j = 0; j < tdtypes.dim; j++) |
358 { | 358 { |
359 Object o1 = cast(Object)tdtypes.data[j]; | 359 Object o1 = tdtypes[j]; |
360 Object o2 = cast(Object)ti.tdtypes.data[j]; | 360 Object o2 = ti.tdtypes[j]; |
361 if (!match(o1, o2, tempdecl, sc)) | 361 if (!match(o1, o2, tempdecl, sc)) |
362 { | 362 { |
363 goto L1; | 363 goto L1; |
364 } | 364 } |
365 } | 365 } |
706 Objects args = tiargs; | 706 Objects args = tiargs; |
707 for (i = 0; i < args.dim; i++) | 707 for (i = 0; i < args.dim; i++) |
708 { | 708 { |
709 if (i) | 709 if (i) |
710 buf.writeByte(','); | 710 buf.writeByte(','); |
711 Object oarg = cast(Object)args.data[i]; | 711 Object oarg = args[i]; |
712 ObjectToCBuffer(buf, hgs, oarg); | 712 ObjectToCBuffer(buf, hgs, oarg); |
713 } | 713 } |
714 nest--; | 714 nest--; |
715 } | 715 } |
716 buf.writeByte(')'); | 716 buf.writeByte(')'); |
823 //printf("+TemplateInstance.semanticTiargs() %s\n", toChars()); | 823 //printf("+TemplateInstance.semanticTiargs() %s\n", toChars()); |
824 if (!tiargs) | 824 if (!tiargs) |
825 return; | 825 return; |
826 for (size_t j = 0; j < tiargs.dim; j++) | 826 for (size_t j = 0; j < tiargs.dim; j++) |
827 { | 827 { |
828 Object o = cast(Object)tiargs.data[j]; | 828 Object o = tiargs[j]; |
829 Type ta = isType(o); | 829 Type ta = isType(o); |
830 Expression ea = isExpression(o); | 830 Expression ea = isExpression(o); |
831 Dsymbol sa = isDsymbol(o); | 831 Dsymbol sa = isDsymbol(o); |
832 | 832 |
833 //printf("1: tiargs.data[%d] = %p, %p, %p, ea=%p, ta=%p\n", j, o, isDsymbol(o), isTuple(o), ea, ta); | 833 //printf("1: tiargs.data[%d] = %p, %p, %p, ea=%p, ta=%p\n", j, o, isDsymbol(o), isTuple(o), ea, ta); |
1151 Ltd: // td is the new best match | 1151 Ltd: // td is the new best match |
1152 td_ambig = null; | 1152 td_ambig = null; |
1153 td_best = td; | 1153 td_best = td; |
1154 m_best = m; | 1154 m_best = m; |
1155 tdtypes.setDim(dedtypes.dim); | 1155 tdtypes.setDim(dedtypes.dim); |
1156 memcpy(tdtypes.data, dedtypes.data, tdtypes.dim * (void*).sizeof); | 1156 memcpy(tdtypes.ptr, dedtypes.ptr, tdtypes.dim * (void*).sizeof); |
1157 continue; | 1157 continue; |
1158 } | 1158 } |
1159 | 1159 |
1160 if (!td_best) | 1160 if (!td_best) |
1161 { | 1161 { |
1212 //printf("TemplateInstance.declareParameters()\n"); | 1212 //printf("TemplateInstance.declareParameters()\n"); |
1213 for (int i = 0; i < tdtypes.dim; i++) | 1213 for (int i = 0; i < tdtypes.dim; i++) |
1214 { | 1214 { |
1215 TemplateParameter tp = cast(TemplateParameter)tempdecl.parameters.data[i]; | 1215 TemplateParameter tp = cast(TemplateParameter)tempdecl.parameters.data[i]; |
1216 //Object o = cast(Object)tiargs.data[i]; | 1216 //Object o = cast(Object)tiargs.data[i]; |
1217 Object o = cast(Object)tdtypes.data[i]; // initializer for tp | 1217 Object o = tdtypes[i]; // initializer for tp |
1218 | 1218 |
1219 //printf("\ttdtypes[%d] = %p\n", i, o); | 1219 //printf("\ttdtypes[%d] = %p\n", i, o); |
1220 tempdecl.declareParameter(sc, tp, o); | 1220 tempdecl.declareParameter(sc, tp, o); |
1221 } | 1221 } |
1222 } | 1222 } |
1233 /* A nested instance happens when an argument references a local | 1233 /* A nested instance happens when an argument references a local |
1234 * symbol that is on the stack. | 1234 * symbol that is on the stack. |
1235 */ | 1235 */ |
1236 for (size_t i = 0; i < args.dim; i++) | 1236 for (size_t i = 0; i < args.dim; i++) |
1237 { | 1237 { |
1238 Object o = cast(Object)args.data[i]; | 1238 Object o = args[i]; |
1239 Expression ea = isExpression(o); | 1239 Expression ea = isExpression(o); |
1240 Dsymbol sa = isDsymbol(o); | 1240 Dsymbol sa = isDsymbol(o); |
1241 Tuple va = isTuple(o); | 1241 Tuple va = isTuple(o); |
1242 if (ea) | 1242 if (ea) |
1243 { | 1243 { |
1323 string id = tempdecl.ident.toChars(); | 1323 string id = tempdecl.ident.toChars(); |
1324 buf.printf("__T%d%s", id.length, id); ///! | 1324 buf.printf("__T%d%s", id.length, id); ///! |
1325 Objects args = tiargs; | 1325 Objects args = tiargs; |
1326 for (int i = 0; i < args.dim; i++) | 1326 for (int i = 0; i < args.dim; i++) |
1327 { | 1327 { |
1328 Object o = cast(Object)args.data[i]; | 1328 Object o = args[i]; |
1329 Type ta = isType(o); | 1329 Type ta = isType(o); |
1330 Expression ea = isExpression(o); | 1330 Expression ea = isExpression(o); |
1331 Dsymbol sa = isDsymbol(o); | 1331 Dsymbol sa = isDsymbol(o); |
1332 Tuple va = isTuple(o); | 1332 Tuple va = isTuple(o); |
1333 //printf("\to [%d] %p ta %p ea %p sa %p va %p\n", i, o, ta, ea, sa, va); | 1333 //printf("\to [%d] %p ta %p ea %p sa %p va %p\n", i, o, ta, ea, sa, va); |