@@ -1919,79 +1919,96 @@ NodePointer Demangler::demanglePrivateContextDescriptor() {
1919
1919
1920
1920
NodePointer Demangler::demangleArchetype () {
1921
1921
switch (nextChar ()) {
1922
- case ' a' : {
1923
- NodePointer Ident = popNode (Node::Kind::Identifier);
1924
- NodePointer ArcheTy = popTypeAndGetChild ();
1925
- NodePointer AssocTy = createType (
1926
- createWithChildren (Node::Kind::AssociatedTypeRef, ArcheTy, Ident));
1927
- addSubstitution (AssocTy);
1928
- return AssocTy;
1929
- }
1930
- case ' O' : {
1931
- auto definingContext = popContext ();
1932
- return createWithChild (Node::Kind::OpaqueReturnTypeOf, definingContext);
1933
- }
1934
- case ' o' : {
1935
- auto index = demangleIndex ();
1936
- Vector<NodePointer> boundGenericArgs;
1937
- NodePointer retroactiveConformances;
1938
- if (!demangleBoundGenerics (boundGenericArgs, retroactiveConformances))
1939
- return nullptr ;
1940
- auto Name = popNode ();
1941
- auto opaque = createWithChildren (Node::Kind::OpaqueType, Name,
1942
- createNode (Node::Kind::Index, index));
1943
- auto boundGenerics = createNode (Node::Kind::TypeList);
1944
- for (unsigned i = boundGenericArgs.size (); i-- > 0 ;)
1945
- boundGenerics->addChild (boundGenericArgs[i], *this );
1946
- opaque->addChild (boundGenerics, *this );
1947
- if (retroactiveConformances)
1948
- opaque->addChild (retroactiveConformances, *this );
1949
-
1950
- auto opaqueTy = createType (opaque);
1951
- addSubstitution (opaqueTy);
1952
- return opaqueTy;
1953
- }
1954
- case ' r' : {
1955
- return createType (createNode (Node::Kind::OpaqueReturnType));
1956
- }
1957
- case ' y' : {
1958
- NodePointer T = demangleAssociatedTypeSimple (demangleGenericParamIndex ());
1959
- addSubstitution (T);
1960
- return T;
1961
- }
1962
- case ' z' : {
1963
- NodePointer T = demangleAssociatedTypeSimple (
1964
- getDependentGenericParamType (0 , 0 ));
1965
- addSubstitution (T);
1966
- return T;
1967
- }
1968
- case ' Y' : {
1969
- NodePointer T = demangleAssociatedTypeCompound (
1970
- demangleGenericParamIndex ());
1971
- addSubstitution (T);
1972
- return T;
1973
- }
1974
- case ' Z' : {
1975
- NodePointer T = demangleAssociatedTypeCompound (
1976
- getDependentGenericParamType (0 , 0 ));
1977
- addSubstitution (T);
1978
- return T;
1979
- }
1980
- default :
1922
+ case ' a' : {
1923
+ NodePointer Ident = popNode (Node::Kind::Identifier);
1924
+ NodePointer ArcheTy = popTypeAndGetChild ();
1925
+ NodePointer AssocTy = createType (
1926
+ createWithChildren (Node::Kind::AssociatedTypeRef, ArcheTy, Ident));
1927
+ addSubstitution (AssocTy);
1928
+ return AssocTy;
1929
+ }
1930
+ case ' O' : {
1931
+ auto definingContext = popContext ();
1932
+ return createWithChild (Node::Kind::OpaqueReturnTypeOf, definingContext);
1933
+ }
1934
+ case ' o' : {
1935
+ auto index = demangleIndex ();
1936
+ Vector<NodePointer> boundGenericArgs;
1937
+ NodePointer retroactiveConformances;
1938
+ if (!demangleBoundGenerics (boundGenericArgs, retroactiveConformances))
1981
1939
return nullptr ;
1940
+ auto Name = popNode ();
1941
+ auto opaque = createWithChildren (Node::Kind::OpaqueType, Name,
1942
+ createNode (Node::Kind::Index, index));
1943
+ auto boundGenerics = createNode (Node::Kind::TypeList);
1944
+ for (unsigned i = boundGenericArgs.size (); i-- > 0 ;)
1945
+ boundGenerics->addChild (boundGenericArgs[i], *this );
1946
+ opaque->addChild (boundGenerics, *this );
1947
+ if (retroactiveConformances)
1948
+ opaque->addChild (retroactiveConformances, *this );
1949
+
1950
+ auto opaqueTy = createType (opaque);
1951
+ addSubstitution (opaqueTy);
1952
+ return opaqueTy;
1953
+ }
1954
+ case ' r' : {
1955
+ return createType (createNode (Node::Kind::OpaqueReturnType));
1956
+ }
1957
+
1958
+ case ' x' : {
1959
+ NodePointer T = demangleAssociatedTypeSimple (nullptr );
1960
+ addSubstitution (T);
1961
+ return T;
1962
+ }
1963
+
1964
+ case ' X' : {
1965
+ NodePointer T = demangleAssociatedTypeCompound (nullptr );
1966
+ addSubstitution (T);
1967
+ return T;
1968
+ }
1969
+
1970
+ case ' y' : {
1971
+ NodePointer T = demangleAssociatedTypeSimple (demangleGenericParamIndex ());
1972
+ addSubstitution (T);
1973
+ return T;
1974
+ }
1975
+ case ' Y' : {
1976
+ NodePointer T = demangleAssociatedTypeCompound (
1977
+ demangleGenericParamIndex ());
1978
+ addSubstitution (T);
1979
+ return T;
1980
+ }
1981
+
1982
+ case ' z' : {
1983
+ NodePointer T = demangleAssociatedTypeSimple (
1984
+ getDependentGenericParamType (0 , 0 ));
1985
+ addSubstitution (T);
1986
+ return T;
1987
+ }
1988
+ case ' Z' : {
1989
+ NodePointer T = demangleAssociatedTypeCompound (
1990
+ getDependentGenericParamType (0 , 0 ));
1991
+ addSubstitution (T);
1992
+ return T;
1993
+ }
1994
+ default :
1995
+ return nullptr ;
1982
1996
}
1983
1997
}
1984
1998
1985
- NodePointer Demangler::demangleAssociatedTypeSimple (
1986
- NodePointer GenericParamIdx) {
1987
- NodePointer GPI = createType (GenericParamIdx);
1999
+ NodePointer Demangler::demangleAssociatedTypeSimple (NodePointer Base) {
1988
2000
NodePointer ATName = popAssocTypeName ();
2001
+ NodePointer BaseTy;
2002
+ if (Base) {
2003
+ BaseTy = createType (Base);
2004
+ } else {
2005
+ BaseTy = popNode (Node::Kind::Type);
2006
+ }
1989
2007
return createType (createWithChildren (Node::Kind::DependentMemberType,
1990
- GPI , ATName));
2008
+ BaseTy , ATName));
1991
2009
}
1992
2010
1993
- NodePointer Demangler::demangleAssociatedTypeCompound (
1994
- NodePointer GenericParamIdx) {
2011
+ NodePointer Demangler::demangleAssociatedTypeCompound (NodePointer Base) {
1995
2012
Vector<NodePointer> AssocTyNames (*this , 4 );
1996
2013
bool firstElem = false ;
1997
2014
do {
@@ -2001,15 +2018,19 @@ NodePointer Demangler::demangleAssociatedTypeCompound(
2001
2018
return nullptr ;
2002
2019
AssocTyNames.push_back (AssocTyName, *this );
2003
2020
} while (!firstElem);
2004
-
2005
- NodePointer Base = GenericParamIdx;
2021
+
2022
+ NodePointer BaseTy;
2023
+ if (Base)
2024
+ BaseTy = createType (Base);
2025
+ else
2026
+ BaseTy = popNode (Node::Kind::Type);
2006
2027
2007
2028
while (NodePointer AssocTy = AssocTyNames.pop_back_val ()) {
2008
2029
NodePointer depTy = createNode (Node::Kind::DependentMemberType);
2009
- depTy = addChild (depTy, createType (Base) );
2010
- Base = addChild (depTy, AssocTy);
2030
+ depTy = addChild (depTy, BaseTy );
2031
+ BaseTy = createType ( addChild (depTy, AssocTy) );
2011
2032
}
2012
- return createType (Base) ;
2033
+ return BaseTy ;
2013
2034
}
2014
2035
2015
2036
NodePointer Demangler::popAssocTypeName () {
0 commit comments