public virtual TResult VisitPointerType(IPointerTypeSymbol symbol) { #pragma warning disable CS8717 // A member returning a [MaybeNull] value introduces a null value when 'TResult' is a non-nullable reference type. return(DefaultVisit(symbol)); #pragma warning restore CS8717 // A member returning a [MaybeNull] value introduces a null value when 'TResult' is a non-nullable reference type. }
private static bool CompareTypes(Compilation ca, Compilation cb, ITypeSymbol a, ITypeSymbol b) { if (a.TypeKind != b.TypeKind) { return(false); } switch (a.TypeKind) { case TypeKind.Array: IArrayTypeSymbol arrayA = (IArrayTypeSymbol)a, arrayB = (IArrayTypeSymbol)b; return(arrayA.Rank == arrayB.Rank && arrayA.Sizes.SequenceEqual(arrayB.Sizes) && CompareTypes(ca, cb, arrayA.ElementType, arrayB.ElementType)); case TypeKind.Pointer: IPointerTypeSymbol ptrA = (IPointerTypeSymbol)a, ptrB = (IPointerTypeSymbol)b; return(CompareTypes(ca, cb, ptrA.PointedAtType, ptrB.PointedAtType)); case TypeKind.Class: case TypeKind.Delegate: case TypeKind.Dynamic: case TypeKind.Enum: case TypeKind.Error: case TypeKind.Interface: case TypeKind.Module: case TypeKind.Struct: case TypeKind.TypeParameter: case TypeKind.Unknown: return(GetName(ca, a) == GetName(cb, b)); } throw new ArgumentException("unknown type kind: " + a.TypeKind); }
private int CombineHashCodes(IPointerTypeSymbol x, int currentHash) { return(Hash.Combine( typeof(IPointerTypeSymbol).GetHashCode(), GetHashCode(x.PointedAtType, currentHash) )); }
public static T WithNullability <T>(this T typeSymbol, NullableAnnotation nullability) where T : class, ITypeSymbol { if (typeSymbol == null) { return(null); } if (typeSymbol is TypeSymbolWithNullableAnnotation typeSymbolWithNullability) { // Check if the wrapper already has the same top-level nullability; in that case we don't need to re-create one. if (typeSymbolWithNullability.Nullability == nullability) { return(typeSymbol); } // No reason to wrap a wrapper, so unwrap it typeSymbol = (T)typeSymbolWithNullability.WrappedSymbol; } return(typeSymbol switch { IArrayTypeSymbol arrayTypeSymbol => (ITypeSymbol) new ArrayTypeSymbolWithNullableAnnotation(arrayTypeSymbol, nullability), IDynamicTypeSymbol dynamicTypeSymbol => (ITypeSymbol) new DynamicTypeSymbolWithNullableAnnotation(dynamicTypeSymbol, nullability), INamedTypeSymbol namedTypeSymbol => (ITypeSymbol) new NamedTypeSymbolWithNullableAnnotation(namedTypeSymbol, nullability), IPointerTypeSymbol pointerType => (ITypeSymbol) new PointerTypeSymbolWithNullableAnnotation(pointerType, nullability), ITypeParameterSymbol typeParameterSymbol => (ITypeSymbol) new TypeParameterSymbolWithNullableAnnotation(typeParameterSymbol, nullability), _ => throw ExceptionUtilities.UnexpectedValue(typeSymbol) } as T);
public override TypeSyntax VisitPointerType(IPointerTypeSymbol symbol) { ThrowIfNameOnly(); return(AddInformationTo( SyntaxFactory.PointerType(symbol.PointedAtType.GenerateTypeSyntax()), symbol)); }
private static ISymbol?GetRelevantType(ISymbol?symbol) { return(symbol switch { IPointerTypeSymbol pointer => pointer.PointedAtType, IArrayTypeSymbol arrayType => arrayType.ElementType, _ => symbol });
private static string ToDisplay(this IPointerTypeSymbol @this) { var pointedAtType = @this.PointedAtType; var pointedType = pointedAtType.SimplifyTypeName(); var returnTypeName = $"{pointedType}*"; return(returnTypeName); }
public override void VisitPointerType(IPointerTypeSymbol symbol) { symbol.PointedAtType.Accept(this); ReferenceItem.Parts[SyntaxLanguage.VB].Add(new LinkItem { DisplayName = "*", DisplayQualifiedNames = "*", }); }
public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol?symbol) { return(symbol switch { IArrayTypeSymbol a => ContainsAnonymousType(a.ElementType), IPointerTypeSymbol p => ContainsAnonymousType(p.PointedAtType), INamedTypeSymbol n => ContainsAnonymousType(n), _ => false, });
public override bool VisitPointerType(IPointerTypeSymbol symbol) { if (!_visited.Add(symbol)) { return(false); } return(true); }
public override void VisitPointerType(IPointerTypeSymbol symbol) { if (!visited.Add(symbol)) { return; } symbol.PointedAtType.Accept(this); }
public override void VisitPointerType(IPointerTypeSymbol symbol) { if (!_visited.Add(symbol)) { return; } symbol.PointedAtType.Accept(this); }
public override void VisitPointerType(IPointerTypeSymbol symbol) { symbol.PointedAtType.Accept(this.NotFirstVisitor); if (!this.isFirstSymbolVisited) { AddCustomModifiersIfRequired(symbol.CustomModifiers, leadingSpace: true); } AddPunctuation(SyntaxKind.AsteriskToken); }
public override ITypeSymbol VisitPointerType(IPointerTypeSymbol symbol) { var pointedAtType = symbol.PointedAtType.Accept(this); if (pointedAtType != null && pointedAtType.Equals(symbol.PointedAtType)) { return(symbol); } return(typeGenerator.CreatePointerTypeSymbol(pointedAtType)); }
public override async ValueTask <ITypeSymbol> VisitPointerType(IPointerTypeSymbol symbol) { var elementType = await symbol.PointedAtType.Accept(this).ConfigureAwait(false); if (elementType != null && elementType.Equals(symbol.PointedAtType)) { return(symbol); } return(_compilation.CreatePointerTypeSymbol(elementType)); }
public override ITypeSymbol VisitPointerType(IPointerTypeSymbol symbol) { var elementType = symbol.PointedAtType.Accept(this); if (elementType != null && elementType.Equals(symbol.PointedAtType)) { return(symbol); } return(compilation.CreatePointerTypeSymbol(elementType)); }
public static bool IsOrReferencesErrorType(this ITypeSymbol type) { if (!type.ContainingType?.IsOrReferencesErrorType() ?? false) { return(false); } return(type switch { IErrorTypeSymbol => true, IArrayTypeSymbol array => array.ElementType.IsOrReferencesErrorType(), IPointerTypeSymbol pointer => pointer.PointedAtType.IsOrReferencesErrorType(), INamedTypeSymbol named => !named.IsUnboundGenericType && named.TypeArguments.Any(IsOrReferencesErrorType), _ => false, });
public override void VisitPointerType(IPointerTypeSymbol symbol) { var pointer = symbol as PointerTypeSymbol; if ((object)pointer == null) { symbol.PointedAtType.Accept(this.NotFirstVisitor); } else { VisitTypeSymbolWithAnnotations(pointer.PointedAtType); } if (!this.isFirstSymbolVisited) { AddCustomModifiersIfRequired(symbol.CustomModifiers, leadingSpace: true); } AddPunctuation(SyntaxKind.AsteriskToken); }
private static async Task <GraphNodeId> GetPartialForPointerTypeAsync(IPointerTypeSymbol pointerType, GraphNodeIdName nodeName, Solution solution, CancellationToken cancellationToken) { var indirection = 1; while (pointerType.PointedAtType.TypeKind == TypeKind.Pointer) { indirection++; pointerType = (IPointerTypeSymbol)pointerType.PointedAtType; } var partials = new List <GraphNodeId>(); partials.Add(GraphNodeId.GetPartial(CodeQualifiedName.Name, pointerType.PointedAtType.Name)); partials.Add(GraphNodeId.GetPartial(CodeQualifiedName.Indirection, indirection.ToString())); if (pointerType.PointedAtType.ContainingType != null) { partials.Add(await GetPartialForTypeAsync(pointerType.PointedAtType.ContainingType, CodeGraphNodeIdName.ParentType, solution, cancellationToken).ConfigureAwait(false)); } return(GraphNodeId.GetPartial(nodeName, MakeCollectionIfNecessary(false, partials.ToArray()))); }
public override void VisitPointerType(IPointerTypeSymbol symbol) { symbol.PointedAtType.Accept(this); Append("*"); }
public override void VisitPointerType(IPointerTypeSymbol pointerTypeSymbol) { pointerTypeSymbol.PointedAtType.Accept(this); }
public sealed override void VisitPointerType(IPointerTypeSymbol symbol) { Visit(symbol.PointedAtType); }
private static async Task<GraphNodeId> GetPartialForPointerTypeAsync(IPointerTypeSymbol pointerType, GraphNodeIdName nodeName, Solution solution, CancellationToken cancellationToken) { var indirection = 1; while (pointerType.PointedAtType.TypeKind == TypeKind.Pointer) { indirection++; pointerType = (IPointerTypeSymbol)pointerType.PointedAtType; } var partials = new List<GraphNodeId>(); partials.Add(GraphNodeId.GetPartial(CodeQualifiedName.Name, pointerType.PointedAtType.Name)); partials.Add(GraphNodeId.GetPartial(CodeQualifiedName.Indirection, indirection.ToString())); if (pointerType.PointedAtType.ContainingType != null) { partials.Add(await GetPartialForTypeAsync(pointerType.PointedAtType.ContainingType, CodeGraphNodeIdName.ParentType, solution, cancellationToken).ConfigureAwait(false)); } return GraphNodeId.GetPartial(nodeName, MakeCollectionIfNecessary(false, partials.ToArray())); }
public virtual TResult?VisitPointerType(IPointerTypeSymbol symbol) { return(DefaultVisit(symbol)); }
public static void Create(IPointerTypeSymbol symbol, SymbolKeyWriter visitor) { visitor.WriteSymbolKey(symbol.PointedAtType); }
public override void VisitPointerType(IPointerTypeSymbol symbol) { base.VisitPointerType(symbol); }
public override Accessibility VisitPointerType(IPointerTypeSymbol symbol) => symbol.PointedAtType.Accept(this);
private bool PointerTypesAreEquivalent(IPointerTypeSymbol x, IPointerTypeSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol> equivalentTypesWithDifferingAssemblies) { return AreEquivalent(x.PointedAtType, y.PointedAtType, equivalentTypesWithDifferingAssemblies); }
public override IEntity VisitPointerType(IPointerTypeSymbol symbol) => PointerType.Create(cx, symbol);
private bool PointerTypesAreEquivalent(IPointerTypeSymbol x, IPointerTypeSymbol y, Dictionary <INamedTypeSymbol, INamedTypeSymbol> equivalentTypesWithDifferingAssemblies) { return (AreEquivalent(x.CustomModifiers, y.CustomModifiers, equivalentTypesWithDifferingAssemblies) && AreEquivalent(x.PointedAtType, y.PointedAtType, equivalentTypesWithDifferingAssemblies)); }
public override string VisitPointerType(IPointerTypeSymbol symbol) { return(symbol.PointedAtType.Accept(this) + "*"); }
public override void VisitPointerType(IPointerTypeSymbol pointerTypeSymbol) => pointerTypeSymbol.PointedAtType.Accept(this);
public override object VisitPointerType(IPointerTypeSymbol pointerTypeSymbol) { WriteType(SymbolKeyType.PointerType); PointerTypeSymbolKey.Create(pointerTypeSymbol, this); return(null); }
public virtual void VisitPointerType(IPointerTypeSymbol symbol) { DefaultVisit(symbol); }
private static void AppendPointerType(IPointerTypeSymbol symbol, StringBuilder builder) { builder.Append(GetMetadataName(symbol.PointedAtType)); builder.Append('*'); }
public static void Create(IPointerTypeSymbol symbol, SymbolKeyWriter visitor) => visitor.WriteSymbolKey(symbol.PointedAtType);
public override ValueTask VisitPointerType(IPointerTypeSymbol symbol) => symbol.PointedAtType.Accept(this);
public override bool VisitPointerType(IPointerTypeSymbol symbol) { return(Visit(symbol.PointedAtType)); }
private void Visit(IPointerTypeSymbol type) { Visit(type.PointedAtType); builder.Append("*"); }