internal Microsoft.Cci.INamedTypeReference Translate(NamedTypeSymbol namedTypeSymbol, bool needDeclaration) { System.Diagnostics.Debug.Assert(ReferenceEquals(namedTypeSymbol, namedTypeSymbol.OriginalDefinition) || !namedTypeSymbol.Equals(namedTypeSymbol.OriginalDefinition)); if (!ReferenceEquals(namedTypeSymbol, namedTypeSymbol.OriginalDefinition)) { // generic instantiation for sure System.Diagnostics.Debug.Assert(!needDeclaration); return namedTypeSymbol; } else if (!needDeclaration) { object reference; Microsoft.Cci.INamedTypeReference typeRef; NamedTypeSymbol container = namedTypeSymbol.ContainingType; if (namedTypeSymbol.Arity > 0) { if (genericInstanceMap.TryGetValue(namedTypeSymbol, out reference)) { return (Microsoft.Cci.INamedTypeReference)reference; } if (container != null) { if (IsGenericType(container)) { // Container is a generic instance too. typeRef = new SpecializedGenericNestedTypeInstanceReference(namedTypeSymbol); } else { typeRef = new GenericNestedTypeInstanceReference(namedTypeSymbol); } } else { typeRef = new GenericNamespaceTypeInstanceReference(namedTypeSymbol); } genericInstanceMap.Add(namedTypeSymbol, typeRef); return typeRef; } else if (IsGenericType(container)) { System.Diagnostics.Debug.Assert(container != null); if (genericInstanceMap.TryGetValue(namedTypeSymbol, out reference)) { return (Microsoft.Cci.INamedTypeReference)reference; } typeRef = new SpecializedNestedTypeReference(namedTypeSymbol); genericInstanceMap.Add(namedTypeSymbol, typeRef); return typeRef; } } return namedTypeSymbol; }
internal Microsoft.Cci.INamedTypeReference Translate(NamedTypeSymbol namedTypeSymbol, bool needDeclaration) { System.Diagnostics.Debug.Assert(ReferenceEquals(namedTypeSymbol, namedTypeSymbol.OriginalDefinition) || !namedTypeSymbol.Equals(namedTypeSymbol.OriginalDefinition)); if (!ReferenceEquals(namedTypeSymbol, namedTypeSymbol.OriginalDefinition)) { // generic instantiation for sure System.Diagnostics.Debug.Assert(!needDeclaration); return(namedTypeSymbol); } else if (!needDeclaration) { object reference; Microsoft.Cci.INamedTypeReference typeRef; NamedTypeSymbol container = namedTypeSymbol.ContainingType; if (namedTypeSymbol.Arity > 0) { if (genericInstanceMap.TryGetValue(namedTypeSymbol, out reference)) { return((Microsoft.Cci.INamedTypeReference)reference); } if (container != null) { if (IsGenericType(container)) { // Container is a generic instance too. typeRef = new SpecializedGenericNestedTypeInstanceReference(namedTypeSymbol); } else { typeRef = new GenericNestedTypeInstanceReference(namedTypeSymbol); } } else { typeRef = new GenericNamespaceTypeInstanceReference(namedTypeSymbol); } genericInstanceMap.Add(namedTypeSymbol, typeRef); return(typeRef); } else if (IsGenericType(container)) { System.Diagnostics.Debug.Assert(container != null); if (genericInstanceMap.TryGetValue(namedTypeSymbol, out reference)) { return((Microsoft.Cci.INamedTypeReference)reference); } typeRef = new SpecializedNestedTypeReference(namedTypeSymbol); genericInstanceMap.Add(namedTypeSymbol, typeRef); return(typeRef); } } return(namedTypeSymbol); }