mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add manglings for associated types.
This should allow declarations inside protocols to mangle successfully, which is needed by SourceKit to be able to use mangled names as unique decl identifiers. I'm also planning to use mangled protocol decls to name generic curry thunk symbols. This only introduces a mangling for independent associated types. I think we will eventually want to mangle dependent associated types (such as T.AssocType for an archetype T : SomeProtocol) with a non-indexed mangling too, but this doesn't do that yet. Swift SVN r8148
This commit is contained in:
@@ -1307,6 +1307,26 @@ private:
|
||||
return demangleProtocolList();
|
||||
}
|
||||
if (c == 'Q') {
|
||||
if (Mangled.nextIf('P')) {
|
||||
NodePointer proto = demangleProtocolName();
|
||||
if (!proto) return nullptr;
|
||||
NodePointer name = demangleIdentifier();
|
||||
if (!name) return nullptr;
|
||||
NodePointer assocType
|
||||
= Node::makeNodePointer(Node::Kind::AssociatedTypeRef);
|
||||
assocType->push_back_child(proto);
|
||||
assocType->push_back_child(name);
|
||||
Substitutions.push_back({ assocType, IsProtocol::no });
|
||||
return assocType;
|
||||
}
|
||||
if (Mangled.nextIf('Q')) {
|
||||
NodePointer proto = demangleProtocolName();
|
||||
if (!proto) return nullptr;
|
||||
NodePointer selfType = Node::makeNodePointer(Node::Kind::SelfTypeRef);
|
||||
selfType->push_back_child(proto);
|
||||
Substitutions.push_back({ selfType, IsProtocol::no });
|
||||
return selfType;
|
||||
}
|
||||
if (Mangled.nextIf('d')) {
|
||||
size_t depth, index;
|
||||
if (!demangleIndex(depth))
|
||||
@@ -1808,6 +1828,14 @@ void toString(NodePointer pointer, DemanglerPrinter &printer) {
|
||||
case swift::Demangle::Node::Kind::ArchetypeRef:
|
||||
printer << pointer->getText();
|
||||
break;
|
||||
case swift::Demangle::Node::Kind::AssociatedTypeRef:
|
||||
toString(pointer->child_at(0), printer);
|
||||
printer << '.' << pointer->child_at(1)->getText();
|
||||
break;
|
||||
case swift::Demangle::Node::Kind::SelfTypeRef:
|
||||
toString(pointer->child_at(0), printer);
|
||||
printer << ".Self";
|
||||
break;
|
||||
case swift::Demangle::Node::Kind::ProtocolList: {
|
||||
if (pointer->size() == 1) {
|
||||
toString(pointer->child_at(0), printer);
|
||||
|
||||
Reference in New Issue
Block a user