@@ -8223,123 +8223,10 @@ extern (C++) class TemplateInstance : ScopeDsymbol
82238223 */
82248224 final Identifier genIdent (Objects* args)
82258225 {
8226- TemplateDeclaration tempdecl = this .tempdecl.isTemplateDeclaration();
8227- assert (tempdecl);
8228-
82298226 // printf("TemplateInstance.genIdent('%s')\n", tempdecl.ident.toChars());
8227+ assert (args is tiargs);
82308228 OutBuffer buf;
8231-
8232- const id = tempdecl.ident.toString();
8233- // Use "__U" for the symbols declared inside template constraint.
8234- const char T = members ? ' T' : ' U' ;
8235- buf.printf(" __%c%u%.*s" , T, cast (int )id.length, cast (int )id.length, id.ptr);
8236-
8237- size_t nparams = tempdecl.parameters.dim - (tempdecl.isVariadic() ? 1 : 0 );
8238- for (size_t i = 0 ; i < args.dim; i++ )
8239- {
8240- RootObject o = (* args)[i];
8241- Type ta = isType(o);
8242- Expression ea = isExpression(o);
8243- Dsymbol sa = isDsymbol(o);
8244- Tuple va = isTuple(o);
8245- // printf("\to [%d] %p ta %p ea %p sa %p va %p\n", i, o, ta, ea, sa, va);
8246- if (i < nparams && (* tempdecl.parameters)[i].specialization())
8247- buf.writeByte(' H' ); // https://issues.dlang.org/show_bug.cgi?id=6574
8248- if (ta)
8249- {
8250- buf.writeByte(' T' );
8251- if (ta.deco)
8252- buf.writestring(ta.deco);
8253- else
8254- {
8255- debug
8256- {
8257- if (! global.errors)
8258- printf(" ta = %d, %s\n " , ta.ty, ta.toChars());
8259- }
8260- assert (global.errors);
8261- }
8262- }
8263- else if (ea)
8264- {
8265- // Don't interpret it yet, it might actually be an alias template parameter.
8266- // Only constfold manifest constants, not const/immutable lvalues, see https://issues.dlang.org/show_bug.cgi?id=17339.
8267- enum keepLvalue = true ;
8268- ea = ea.optimize(WANTvalue, keepLvalue);
8269- if (ea.op == TOKvar)
8270- {
8271- sa = (cast (VarExp)ea).var;
8272- ea = null ;
8273- goto Lsa;
8274- }
8275- if (ea.op == TOKthis)
8276- {
8277- sa = (cast (ThisExp)ea).var;
8278- ea = null ;
8279- goto Lsa;
8280- }
8281- if (ea.op == TOKfunction)
8282- {
8283- if ((cast (FuncExp)ea).td)
8284- sa = (cast (FuncExp)ea).td;
8285- else
8286- sa = (cast (FuncExp)ea).fd;
8287- ea = null ;
8288- goto Lsa;
8289- }
8290- buf.writeByte(' V' );
8291- if (ea.op == TOKtuple)
8292- {
8293- ea.error(" tuple is not a valid template value argument" );
8294- continue ;
8295- }
8296- // Now that we know it is not an alias, we MUST obtain a value
8297- uint olderr = global.errors;
8298- ea = ea.ctfeInterpret();
8299- if (ea.op == TOKerror || olderr != global.errors)
8300- continue ;
8301-
8302- /* Use deco that matches what it would be for a function parameter
8303- */
8304- buf.writestring(ea.type.deco);
8305- mangleToBuffer(ea, &buf);
8306- }
8307- else if (sa)
8308- {
8309- Lsa:
8310- buf.writeByte(' S' );
8311- sa = sa.toAlias();
8312- Declaration d = sa.isDeclaration();
8313- if (d && (! d.type || ! d.type.deco))
8314- {
8315- error(" forward reference of %s %s" , d.kind(), d.toChars());
8316- continue ;
8317- }
8318-
8319- OutBuffer bufsa;
8320- mangleToBuffer(sa, &bufsa);
8321- auto s = bufsa.peekSlice();
8322-
8323- /* https://issues.dlang.org/show_bug.cgi?id=3043
8324- * If the first character of p is a digit this
8325- * causes ambiguity issues because the digits of the two numbers are adjacent.
8326- * Current demanglers resolve this by trying various places to separate the
8327- * numbers until one gets a successful demangle.
8328- * Unfortunately, fixing this ambiguity will break existing binary
8329- * compatibility and the demanglers, so we'll leave it as is.
8330- */
8331- buf.printf(" %u%.*s" , cast (uint )s.length, cast (int )s.length, s.ptr);
8332- }
8333- else if (va)
8334- {
8335- assert (i + 1 == args.dim); // must be last one
8336- args = &va.objects;
8337- i = - cast (size_t )1 ;
8338- }
8339- else
8340- assert (0 );
8341- }
8342- buf.writeByte(' Z' );
8229+ mangleToBuffer(this , &buf);
83438230 // printf("\tgenIdent = %s\n", buf.peekString());
83448231 return Identifier.idPool(buf.peekSlice());
83458232 }
0 commit comments