Changeset 801
- Timestamp:
- 12/12/10 08:43:49 (14 years ago)
- Files:
-
- branches/dmd-1.x/src/template.c (modified) (9 diffs)
- trunk/src/template.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmd-1.x/src/template.c
r784 r801 196 196 } 197 197 else if (e1) 198 198 { 199 199 #if 0 200 200 if (e1 && e2) 201 201 { 202 202 printf("match %d\n", e1->equals(e2)); 203 203 e1->print(); 204 204 e2->print(); 205 205 e1->type->print(); 206 206 e2->type->print(); 207 207 } 208 208 #endif 209 209 if (!e2) 210 210 goto Lnomatch; 211 211 if (!e1->equals(e2)) 212 212 goto Lnomatch; 213 213 } 214 214 else if (s1) 215 215 { 216 //printf("%p %s , %p %s\n", s1, s1->toChars(), s2, s2->toChars());217 if (!s2 || !s1->equals(s2) || s1->parent != s2->parent)216 //printf("%p %s %s, %p %s %s\n", s1, s1->kind(), s1->toChars(), s2, s2->kind(), s2->toChars()); 217 if (!s2) 218 218 { 219 219 goto Lnomatch; 220 220 } 221 if (!s1->equals(s2)) 222 { 221 223 #if DMDV2 222 VarDeclaration *v1 = s1->isVarDeclaration(); 223 VarDeclaration *v2 = s2->isVarDeclaration(); 224 if (v1 && v2 && v1->storage_class & v2->storage_class & STCmanifest) 225 { ExpInitializer *ei1 = v1->init->isExpInitializer(); 226 ExpInitializer *ei2 = v2->init->isExpInitializer(); 227 if (ei1 && ei2 && !ei1->exp->equals(ei2->exp)) 224 VarDeclaration *v1 = s1->isVarDeclaration(); 225 VarDeclaration *v2 = s2->isVarDeclaration(); 226 if (v1 && v2 && v1->storage_class & v2->storage_class & STCmanifest) 227 { ExpInitializer *ei1 = v1->init->isExpInitializer(); 228 ExpInitializer *ei2 = v2->init->isExpInitializer(); 229 if (ei1 && ei2 && !ei1->exp->equals(ei2->exp)) 230 goto Lnomatch; 231 goto Lmatch; 232 } 233 else 234 #endif 228 235 goto Lnomatch; 229 236 } 230 #endif 237 if (s1->parent != s2->parent) 238 { 239 goto Lnomatch; 240 } 231 241 } 232 242 else if (v1) 233 243 { 234 244 if (!v2) 235 245 goto Lnomatch; 236 246 if (v1->objects.dim != v2->objects.dim) 237 247 goto Lnomatch; 238 248 for (size_t i = 0; i < v1->objects.dim; i++) 239 249 { 240 250 if (!match((Object *)v1->objects.data[i], 241 251 (Object *)v2->objects.data[i], 242 252 tempdecl, sc)) 243 253 goto Lnomatch; 244 254 } 245 255 } 256 Lmatch: 246 257 //printf("match\n"); 247 258 return 1; // match 248 259 Lnomatch: 249 260 //printf("nomatch\n"); 250 261 return 0; // nomatch; 262 } 263 264 265 /************************************ 266 * Match an array of them. 267 * This should match what genIdent() does. 268 */ 269 int arrayObjectMatch(Objects *oa1, Objects *oa2, TemplateDeclaration *tempdecl, Scope *sc) 270 { 271 if (oa1 == oa2) 272 return 1; 273 if (oa1->dim != oa2->dim) 274 return 0; 275 for (size_t j = 0; j < oa1->dim; j++) 276 { Object *o1 = (Object *)oa1->data[j]; 277 Object *o2 = (Object *)oa2->data[j]; 278 if (!match(o1, o2, tempdecl, sc)) 279 { 280 return 0; 281 } 282 } 283 return 1; 251 284 } 252 285 253 286 /**************************************** 254 287 */ 255 288 256 289 void ObjectToCBuffer(OutBuffer *buf, HdrGenState *hgs, Object *oarg) 257 290 { 258 291 //printf("ObjectToCBuffer()\n"); 259 292 Type *t = isType(oarg); 260 293 Expression *e = isExpression(oarg); 261 294 Dsymbol *s = isDsymbol(oarg); 262 295 Tuple *v = isTuple(oarg); 263 296 if (t) 264 297 { //printf("\tt: %s ty = %d\n", t->toChars(), t->ty); 265 298 t->toCBuffer(buf, NULL, hgs); 266 299 } 267 300 else if (e) 268 301 e->toCBuffer(buf, hgs); 269 302 else if (s) 270 303 { … … 332 365 printf("\tparameter[%d] = %s : %s\n", i, tp->ident->toChars(), ttp->specType ? ttp->specType->toChars() : ""); 333 366 } 334 367 } 335 368 #endif 336 369 this->loc = loc; 337 370 this->parameters = parameters; 338 371 this->origParameters = parameters; 339 372 this->constraint = constraint; 340 373 this->members = decldefs; 341 374 this->overnext = NULL; 342 375 this->overroot = NULL; 343 376 this->semanticRun = 0; 344 377 this->onemember = NULL; 345 378 } 346 379 347 380 Dsymbol *TemplateDeclaration::syntaxCopy(Dsymbol *) 348 381 { 349 382 //printf("TemplateDeclaration::syntaxCopy()\n"); 350 383 TemplateDeclaration *td; 351 384 TemplateParameters *p; 352 Array *d;353 385 354 386 p = NULL; 355 387 if (parameters) 356 388 { 357 389 p = new TemplateParameters(); 358 390 p->setDim(parameters->dim); 359 391 for (int i = 0; i < p->dim; i++) 360 392 { TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; 361 393 p->data[i] = (void *)tp->syntaxCopy(); 362 394 } 363 395 } 364 396 Expression *e = NULL; 365 397 if (constraint) 366 398 e = constraint->syntaxCopy(); 367 d = Dsymbol::arraySyntaxCopy(members);399 Array *d = Dsymbol::arraySyntaxCopy(members); 368 400 td = new TemplateDeclaration(loc, ident, p, e, d); 369 401 return td; 370 402 } 371 403 372 404 void TemplateDeclaration::semantic(Scope *sc) 373 405 { 374 406 #if LOG 375 407 printf("TemplateDeclaration::semantic(this = %p, id = '%s')\n", this, ident->toChars()); 408 printf("sc->stc = %llx\n", sc->stc); 409 printf("sc->module = %s\n", sc->module->toChars()); 376 410 #endif 377 411 if (semanticRun) 378 412 return; // semantic() already run 379 413 semanticRun = 1; 380 414 381 415 if (sc->func) 382 416 { 383 417 #if DMDV1 384 418 error("cannot declare template at function scope %s", sc->func->toChars()); 385 419 #endif 386 420 } 387 421 388 422 if (/*global.params.useArrayBounds &&*/ sc->module) 389 423 { 390 424 // Generate this function as it may be used 391 425 // when template is instantiated in other modules 392 426 sc->module->toModuleArray(); 393 427 } 394 428 395 429 if (/*global.params.useAssert &&*/ sc->module) … … 928 962 } 929 963 declareParameter(paramscope, tp, t); 930 964 goto L2; 931 965 } 932 966 fptupindex = -1; 933 967 } 934 968 } 935 969 936 970 L1: 937 971 if (nfparams == nfargs) 938 972 ; 939 973 else if (nfargs > nfparams) 940 974 { 941 975 if (fvarargs == 0) 942 976 goto Lnomatch; // too many args, no match 943 977 match = MATCHconvert; // match ... with a conversion 944 978 } 945 979 946 980 L2: 947 981 #if DMDV2 948 // Match 'ethis' to any TemplateThisParameter's949 982 if (ethis) 950 983 { 984 // Match 'ethis' to any TemplateThisParameter's 951 985 for (size_t i = 0; i < parameters->dim; i++) 952 986 { TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; 953 987 TemplateThisParameter *ttp = tp->isTemplateThisParameter(); 954 988 if (ttp) 955 989 { MATCH m; 956 990 957 991 Type *t = new TypeIdentifier(0, ttp->ident); 958 992 m = ethis->type->deduceType(paramscope, t, parameters, &dedtypes); 959 993 if (!m) 960 994 goto Lnomatch; 961 995 if (m < match) 962 996 match = m; // pick worst match 997 } 998 } 999 1000 // Match attributes of ethis against attributes of fd 1001 if (fd->type) 1002 { 1003 Type *tthis = ethis->type; 1004 unsigned mod = fd->type->mod; 1005 StorageClass stc = scope->stc; 1006 if (stc & (STCshared | STCsynchronized)) 1007 mod |= MODshared; 1008 if (stc & STCimmutable) 1009 mod |= MODimmutable; 1010 if (stc & STCconst) 1011 mod |= MODconst; 1012 if (stc & STCwild) 1013 mod |= MODwild; 1014 // Fix mod 1015 if (mod & MODimmutable) 1016 mod = MODimmutable; 1017 if (mod & MODconst) 1018 mod &= ~STCwild; 1019 if (tthis->mod != mod) 1020 { 1021 if (!MODimplicitConv(tthis->mod, mod)) 1022 goto Lnomatch; 1023 if (MATCHconst < match) 1024 match = MATCHconst; 963 1025 } 964 1026 } 965 1027 } 966 1028 #endif 967 1029 968 1030 // Loop through the function parameters 969 1031 for (size_t parami = 0; parami < nfparams; parami++) 970 1032 { 971 1033 /* Skip over function parameters which wound up 972 1034 * as part of a template tuple parameter. 973 1035 */ 974 1036 if (parami == fptupindex) 975 1037 continue; 976 1038 /* Set i = index into function arguments 977 1039 * Function parameters correspond to function arguments as follows. 978 1040 * Note that tuple_dim may be zero, and there may be default or 979 1041 * variadic arguments at the end. 980 1042 * arg [0..fptupindex] == param[0..fptupindex] 981 1043 * arg [fptupindex..fptupindex+tuple_dim] == param[fptupindex] 982 1044 * arg[fputupindex+dim.. ] == param[fptupindex+1.. ] … … 1311 1373 TemplateDeclaration *td_best = NULL; 1312 1374 Objects *tdargs = new Objects(); 1313 1375 TemplateInstance *ti; 1314 1376 FuncDeclaration *fd; 1315 1377 1316 1378 #if 0 1317 1379 printf("TemplateDeclaration::deduceFunctionTemplate() %s\n", toChars()); 1318 1380 printf(" targsi:\n"); 1319 1381 if (targsi) 1320 1382 { for (int i = 0; i < targsi->dim; i++) 1321 1383 { Object *arg = (Object *)targsi->data[i]; 1322 1384 printf("\t%s\n", arg->toChars()); 1323 1385 } 1324 1386 } 1325 1387 printf(" fargs:\n"); 1326 1388 for (int i = 0; i < fargs->dim; i++) 1327 1389 { Expression *arg = (Expression *)fargs->data[i]; 1328 1390 printf("\t%s %s\n", arg->type->toChars(), arg->toChars()); 1329 1391 //printf("\tty = %d\n", arg->type->ty); 1330 1392 } 1393 printf("stc = %llx\n", scope->stc); 1331 1394 #endif 1332 1395 1333 1396 for (TemplateDeclaration *td = this; td; td = td->overnext) 1334 1397 { 1335 1398 if (!td->semanticRun) 1336 1399 { 1337 1400 error("forward reference to template %s", td->toChars()); 1338 1401 goto Lerror; 1339 1402 } 1340 1403 if (!td->onemember || !td->onemember->toAlias()->isFuncDeclaration()) 1341 1404 { 1342 1405 error("is not a function template"); 1343 1406 goto Lerror; 1344 1407 } 1345 1408 1346 1409 MATCH m; 1347 1410 Objects dedargs; 1348 1411 1349 1412 m = td->deduceFunctionTemplateMatch(loc, targsi, ethis, fargs, &dedargs); 1350 1413 //printf("deduceFunctionTemplateMatch = %d\n", m); … … 1605 1668 { 1606 1669 dedtypes->data[i] = (void *)this; 1607 1670 goto Lexact; 1608 1671 } 1609 1672 if (equals(at)) 1610 1673 goto Lexact; 1611 1674 else if (ty == Tclass && at->ty == Tclass) 1612 1675 { 1613 1676 return (MATCH) implicitConvTo(at); 1614 1677 } 1615 1678 else if (ty == Tsarray && at->ty == Tarray && 1616 1679 nextOf()->equals(at->nextOf())) 1617 1680 { 1618 1681 goto Lexact; 1619 1682 } 1620 1683 else 1621 1684 goto Lnomatch; 1622 1685 } 1623 1686 1624 1687 if (ty != tparam->ty) 1625 return implicitConvTo(tparam); 1626 // goto Lnomatch; 1688 { 1689 #if DMDV2 1690 // Can't instantiate AssociativeArray!() without a scope 1691 if (tparam->ty == Taarray && !((TypeAArray*)tparam)->sc) 1692 ((TypeAArray*)tparam)->sc = sc; 1693 #endif 1694 return implicitConvTo(tparam); 1695 } 1627 1696 1628 1697 if (nextOf()) 1629 1698 return nextOf()->deduceType(sc, tparam->nextOf(), parameters, dedtypes); 1630 1699 1631 1700 Lexact: 1632 1701 return MATCHexact; 1633 1702 1634 1703 Lnomatch: 1635 1704 return MATCHnomatch; 1636 1705 1637 1706 #if DMDV2 1638 1707 Lconst: 1639 1708 return MATCHconst; 1640 1709 #endif 1641 1710 } 1642 1711 1643 1712 #if DMDV2 1644 1713 MATCH TypeDArray::deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, 1645 1714 Objects *dedtypes) 1646 1715 { … … 1775 1844 1776 1845 // Extra check that function characteristics must match 1777 1846 if (tparam && tparam->ty == Tfunction) 1778 1847 { 1779 1848 TypeFunction *tp = (TypeFunction *)tparam; 1780 1849 if (varargs != tp->varargs || 1781 1850 linkage != tp->linkage) 1782 1851 return MATCHnomatch; 1783 1852 1784 1853 size_t nfargs = Parameter::dim(this->parameters); 1785 1854 size_t nfparams = Parameter::dim(tp->parameters); 1786 1855 1787 1856 /* See if tuple match 1788 1857 */ 1789 1858 if (nfparams > 0 && nfargs >= nfparams - 1) 1790 1859 { 1791 1860 /* See if 'A' of the template parameter matches 'A' 1792 1861 * of the type of the last function parameter. 1793 1862 */ 1794 1863 Parameter *fparam = Parameter::getNth(tp->parameters, nfparams - 1); 1864 assert(fparam); 1865 assert(fparam->type); 1795 1866 if (fparam->type->ty != Tident) 1796 1867 goto L1; 1797 1868 TypeIdentifier *tid = (TypeIdentifier *)fparam->type; 1798 1869 if (tid->idents.dim) 1799 1870 goto L1; 1800 1871 1801 1872 /* Look through parameters to find tuple matching tid->ident 1802 1873 */ 1803 1874 size_t tupi = 0; 1804 1875 for (; 1; tupi++) 1805 1876 { if (tupi == parameters->dim) 1806 1877 goto L1; 1807 1878 TemplateParameter *t = (TemplateParameter *)parameters->data[tupi]; 1808 1879 TemplateTupleParameter *tup = t->isTemplateTupleParameter(); 1809 1880 if (tup && tup->ident->equals(tid->ident)) 1810 1881 break; 1811 1882 } 1812 1883 1813 1884 /* The types of the function arguments [nfparams - 1 .. nfargs] 1814 1885 * now form the tuple argument. … … 2080 2151 goto Lnomatch; 2081 2152 } 2082 2153 else 2083 2154 { 2084 2155 dedtypes->data[j] = s1; 2085 2156 } 2086 2157 } 2087 2158 else if (s1 && s2) 2088 2159 { 2089 2160 if (!s1->equals(s2)) 2090 2161 goto Lnomatch; 2091 2162 } 2092 2163 // BUG: Need to handle tuple parameters 2093 2164 else 2094 2165 goto Lnomatch; 2095 2166 } 2096 2167 } 2097 2168 return Type::deduceType(sc, tparam, parameters, dedtypes); 2098 2169 2099 2170 Lnomatch: 2171 //printf("no match\n"); 2100 2172 return MATCHnomatch; 2101 2173 } 2102 2174 2103 2175 MATCH TypeStruct::deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes) 2104 2176 { 2105 2177 //printf("TypeStruct::deduceType()\n"); 2106 2178 //printf("\tthis->parent = %s, ", sym->parent->toChars()); print(); 2107 2179 //printf("\ttparam = %d, ", tparam->ty); tparam->print(); 2108 2180 2109 2181 /* If this struct is a template struct, and we're matching 2110 2182 * it against a template instance, convert the struct type 2111 2183 * to a template instance, too, and try again. 2112 2184 */ 2113 2185 TemplateInstance *ti = sym->parent->isTemplateInstance(); 2114 2186 2115 2187 if (tparam && tparam->ty == Tinstance) 2116 2188 { 2117 2189 if (ti && ti->toAlias() == sym) 2118 2190 { 2119 2191 TypeInstance *t = new TypeInstance(0, ti); … … 2438 2510 goto Lnomatch; 2439 2511 2440 2512 if (specType && !specType->equals(ttp->specType)) 2441 2513 goto Lnomatch; 2442 2514 2443 2515 return 1; // match 2444 2516 } 2445 2517 2446 2518 Lnomatch: 2447 2519 return 0; 2448 2520 } 2449 2521 2450 2522 /******************************************* 2451 2523 * Match to a particular TemplateParameter. 2452 2524 * Input: 2453 2525 * i i'th argument 2454 2526 * tiargs[] actual arguments to template instance 2455 2527 * parameters[] template parameters 2456 2528 * dedtypes[] deduced arguments to template instance 2457 2529 * *psparam set to symbol declared and initialized to dedtypes[i] 2530 * flags 1: don't do 'toHeadMutable()' 2458 2531 */ 2459 2532 2460 2533 MATCH TemplateTypeParameter::matchArg(Scope *sc, Objects *tiargs, 2461 2534 int i, TemplateParameters *parameters, Objects *dedtypes, 2462 2535 Declaration **psparam, int flags) 2463 2536 { 2464 2537 //printf("TemplateTypeParameter::matchArg()\n"); 2465 2538 Type *t; 2466 2539 Object *oarg; 2467 2540 MATCH m = MATCHexact; 2468 2541 Type *ta; 2469 2542 2470 2543 if (i < tiargs->dim) 2471 2544 oarg = (Object *)tiargs->data[i]; 2472 2545 else 2473 2546 { // Get default argument instead 2474 2547 oarg = defaultArg(loc, sc); 2475 2548 if (!oarg) 2476 2549 { assert(i < dedtypes->dim); 2477 2550 // It might have already been deduced … … 3306 3379 fatal(); 3307 3380 } 3308 3381 return; 3309 3382 } 3310 3383 #if LOG 3311 3384 printf("\n+TemplateInstance::semantic('%s', this=%p)\n", toChars(), this); 3312 3385 #endif 3313 3386 if (inst) // if semantic() was already run 3314 3387 { 3315 3388 #if LOG 3316 3389 printf("-TemplateInstance::semantic('%s', this=%p) already run\n", inst->toChars(), inst); 3317 3390 #endif 3318 3391 return; 3319 3392 } 3320 3393 3321 3394 // get the enclosing template instance from the scope tinst 3322 3395 tinst = sc->tinst; 3323 3396 3324 3397 if (semanticRun != 0) 3325 3398 { 3399 #if LOG 3400 printf("Recursive template expansion\n"); 3401 #endif 3326 3402 error(loc, "recursive template expansion"); 3327 3403 // inst = this; 3328 3404 return; 3329 3405 } 3330 3406 semanticRun = 1; 3331 3407 3332 3408 #if LOG 3333 3409 printf("\tdo semantic\n"); 3334 3410 #endif 3335 3411 if (havetempdecl) 3336 3412 { 3337 3413 assert((size_t)tempdecl->scope > 0x10000); 3338 3414 // Deduce tdtypes 3339 3415 tdtypes.setDim(tempdecl->parameters->dim); 3340 3416 if (!tempdecl->matchWithInstance(this, &tdtypes, 0)) 3341 3417 { 3342 3418 error("incompatible arguments for template instantiation"); 3343 3419 inst = this; 3344 3420 return; 3345 3421 } trunk/src/template.c
r784 r801 197 197 } 198 198 else if (e1) 199 199 { 200 200 #if 0 201 201 if (e1 && e2) 202 202 { 203 203 printf("match %d\n", e1->equals(e2)); 204 204 e1->print(); 205 205 e2->print(); 206 206 e1->type->print(); 207 207 e2->type->print(); 208 208 } 209 209 #endif 210 210 if (!e2) 211 211 goto Lnomatch; 212 212 if (!e1->equals(e2)) 213 213 goto Lnomatch; 214 214 } 215 215 else if (s1) 216 216 { 217 //printf("%p %s, %p %s\n", s1, s1->toChars(), s2, s2->toChars());218 217 if (!s2 || !s1->equals(s2) || s1->parent != s2->parent) 219 218 { 219 if (s2) 220 { 221 VarDeclaration *v1 = s1->isVarDeclaration(); 222 VarDeclaration *v2 = s2->isVarDeclaration(); 223 if (v1 && v2 && v1->storage_class & v2->storage_class & STCmanifest) 224 { ExpInitializer *ei1 = v1->init->isExpInitializer(); 225 ExpInitializer *ei2 = v2->init->isExpInitializer(); 226 if (ei1 && ei2 && ei1->exp->equals(ei2->exp)) 227 goto Lmatch; 228 } 229 } 220 230 goto Lnomatch; 221 231 } 222 232 #if DMDV2 223 233 VarDeclaration *v1 = s1->isVarDeclaration(); 224 234 VarDeclaration *v2 = s2->isVarDeclaration(); 225 235 if (v1 && v2 && v1->storage_class & v2->storage_class & STCmanifest) 226 236 { ExpInitializer *ei1 = v1->init->isExpInitializer(); 227 237 ExpInitializer *ei2 = v2->init->isExpInitializer(); 228 238 if (ei1 && ei2 && !ei1->exp->equals(ei2->exp)) 229 239 goto Lnomatch; 230 240 } 231 241 #endif 232 242 } 233 243 else if (v1) 234 244 { 235 245 if (!v2) 236 246 goto Lnomatch; 237 247 if (v1->objects.dim != v2->objects.dim) 238 248 goto Lnomatch; 239 249 for (size_t i = 0; i < v1->objects.dim; i++) 240 250 { 241 251 if (!match((Object *)v1->objects.data[i], 242 252 (Object *)v2->objects.data[i], 243 253 tempdecl, sc)) 244 254 goto Lnomatch; 245 255 } 246 256 } 257 Lmatch: 247 258 //printf("match\n"); 248 259 return 1; // match 249 260 Lnomatch: 250 261 //printf("nomatch\n"); 251 262 return 0; // nomatch; 252 263 } 253 264 254 265 255 266 /************************************ 256 267 * Match an array of them. 257 268 */ 258 269 int arrayObjectMatch(Objects *oa1, Objects *oa2, TemplateDeclaration *tempdecl, Scope *sc) 259 270 { 260 271 if (oa1 == oa2) 261 272 return 1; 262 273 if (oa1->dim != oa2->dim) 263 274 return 0; 264 275 for (size_t j = 0; j < oa1->dim; j++) 265 276 { Object *o1 = (Object *)oa1->data[j]; 266 277 Object *o2 = (Object *)oa2->data[j]; … … 4686 4697 /* Bugzilla 3043: if the first character of p is a digit this 4687 4698 * causes ambiguity issues because the digits of the two numbers are adjacent. 4688 4699 * Current demanglers resolve this by trying various places to separate the 4689 4700 * numbers until one gets a successful demangle. 4690 4701 * Unfortunately, fixing this ambiguity will break existing binary 4691 4702 * compatibility and the demanglers, so we'll leave it as is. 4692 4703 */ 4693 4704 buf.printf("%zu%s", strlen(p), p); 4694 4705 } 4695 4706 else if (va) 4696 4707 { 4697 4708 assert(i + 1 == args->dim); // must be last one 4698 4709 args = &va->objects; 4699 4710 i = -1; 4700 4711 } 4701 4712 else 4702 4713 assert(0); 4703 4714 } 4704 4715 buf.writeByte('Z'); 4705 4716 id = buf.toChars(); 4706 buf.data = NULL;4717 //buf.data = NULL; // we can free the string after call to idPool() 4707 4718 //printf("\tgenIdent = %s\n", id); 4708 return new Identifier(id, TOKidentifier);4719 return Lexer::idPool(id); 4709 4720 } 4710 4721 4711 4722 4712 4723 /**************************************************** 4713 4724 * Declare parameters of template instance, initialize them with the 4714 4725 * template instance arguments. 4715 4726 */ 4716 4727 4717 4728 void TemplateInstance::declareParameters(Scope *sc) 4718 4729 { 4719 4730 //printf("TemplateInstance::declareParameters()\n"); 4720 4731 for (int i = 0; i < tdtypes.dim; i++) 4721 4732 { 4722 4733 TemplateParameter *tp = (TemplateParameter *)tempdecl->parameters->data[i]; 4723 4734 //Object *o = (Object *)tiargs->data[i]; 4724 4735 Object *o = (Object *)tdtypes.data[i]; // initializer for tp 4725 4736 4726 4737 //printf("\ttdtypes[%d] = %p\n", i, o); 4727 4738 tempdecl->declareParameter(sc, tp, o); 4728 4739 }
