@@ -397,3 +397,69 @@ std::string IRGenMangler::mangleSymbolNameForGenericEnvironment(
397397 appendGenericSignature (genericSig);
398398 return finalize ();
399399}
400+
401+ std::string
402+ IRGenMangler::mangleExtendedExistentialTypeShape (bool isUnique,
403+ CanGenericSignature genSig,
404+ CanExistentialType type,
405+ unsigned metatypeDepth) {
406+ beginMangling ();
407+
408+ appendExtendedExistentialTypeShape (genSig, type, metatypeDepth);
409+
410+ // If this is non-unique, add a suffix to avoid accidental misuse
411+ // (and to make it easier to analyze in an image).
412+ if (!isUnique)
413+ appendOperator (" Mq" );
414+
415+ return finalize ();
416+ }
417+
418+ std::string
419+ IRGenMangler::mangleExtendedExistentialTypeShapeForUniquing (
420+ CanGenericSignature genSig,
421+ CanExistentialType type,
422+ unsigned metatypeDepth) {
423+ beginManglingWithoutPrefix ();
424+ appendExtendedExistentialTypeShape (genSig, type, metatypeDepth);
425+ return finalize ();
426+ }
427+ void
428+ IRGenMangler::appendExtendedExistentialTypeShape (CanGenericSignature genSig,
429+ CanExistentialType type,
430+ unsigned metatypeDepth) {
431+ // Append the requirement signature of the existential.
432+ auto &ctx = type->getASTContext ();
433+ auto reqSig = ctx.getOpenedArchetypeSignature (type, genSig);
434+ appendGenericSignature (reqSig, genSig);
435+
436+ // Append the generalization signature.
437+ if (genSig) appendGenericSignature (genSig);
438+
439+ // Append the type expression, if we have metatypes.
440+ // Metatypes are called out because they're currently the only
441+ // type expression we support.
442+ if (metatypeDepth) {
443+ assert (reqSig.getGenericParams ().size () == 1 );
444+ Type type = reqSig.getGenericParams ()[0 ];
445+ for (unsigned i = 0 ; i != metatypeDepth; ++i)
446+ type = MetatypeType::get (type);
447+ appendType (type, reqSig);
448+ }
449+
450+ // Append the shape operator.
451+ if (!genSig) {
452+ appendOperator (metatypeDepth ? " Xh" : " Xg" );
453+ } else {
454+ appendOperator (metatypeDepth ? " XH" : " XG" );
455+ }
456+
457+ // Append the value storage.
458+ if (metatypeDepth)
459+ appendOperator (" m" );
460+ else if (type->requiresClass ())
461+ appendOperator (" c" );
462+ else
463+ appendOperator (" o" );
464+ }
465+
0 commit comments