提交 95877bf2 编写于 作者: V VSadov

TupleTypeSymbol

上级 ef026a20
...@@ -813,6 +813,13 @@ ...@@ -813,6 +813,13 @@
<Compile Include="Symbols\SynthesizedSymbols\SynthesizedRegularMethodBase.vb" /> <Compile Include="Symbols\SynthesizedSymbols\SynthesizedRegularMethodBase.vb" />
<Compile Include="Symbols\SynthesizedSymbols\SynthesizedSimpleConstructorSymbol.vb" /> <Compile Include="Symbols\SynthesizedSymbols\SynthesizedSimpleConstructorSymbol.vb" />
<Compile Include="Symbols\SynthesizedSymbols\SynthesizedSimpleMethodSymbol.vb" /> <Compile Include="Symbols\SynthesizedSymbols\SynthesizedSimpleMethodSymbol.vb" />
<Compile Include="Symbols\Tuples\TupleErrorFieldSymbol.vb" />
<Compile Include="Symbols\Tuples\TupleEventSymbol.vb" />
<Compile Include="Symbols\Tuples\TupleFieldSymbol.vb" />
<Compile Include="Symbols\Tuples\TupleMethodSymbol.vb" />
<Compile Include="Symbols\Tuples\TupleParameterSymbol.vb" />
<Compile Include="Symbols\Tuples\TuplePropertySymbol.vb" />
<Compile Include="Symbols\Tuples\TupleTypeSymbol.vb" />
<Compile Include="Symbols\TypedConstant.vb" /> <Compile Include="Symbols\TypedConstant.vb" />
<Compile Include="Symbols\TypeKind.vb" /> <Compile Include="Symbols\TypeKind.vb" />
<Compile Include="Symbols\TypeParameterConstraint.vb" /> <Compile Include="Symbols\TypeParameterConstraint.vb" />
...@@ -824,6 +831,7 @@ ...@@ -824,6 +831,7 @@
<Compile Include="Symbols\UnboundGenericType.vb" /> <Compile Include="Symbols\UnboundGenericType.vb" />
<Compile Include="Symbols\UnsupportedMetadataTypeSymbol.vb" /> <Compile Include="Symbols\UnsupportedMetadataTypeSymbol.vb" />
<Compile Include="Symbols\WellKnownMembers.vb" /> <Compile Include="Symbols\WellKnownMembers.vb" />
<Compile Include="Symbols\Wrapped\WrappedEventSymbol.vb" />
<Compile Include="Symbols\Wrapped\WrappedFieldSymbol.vb" /> <Compile Include="Symbols\Wrapped\WrappedFieldSymbol.vb" />
<Compile Include="Symbols\Wrapped\WrappedMethodSymbol.vb" /> <Compile Include="Symbols\Wrapped\WrappedMethodSymbol.vb" />
<Compile Include="Symbols\Wrapped\WrappedNamedTypeSymbol.vb" /> <Compile Include="Symbols\Wrapped\WrappedNamedTypeSymbol.vb" />
......
...@@ -255,6 +255,25 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols ...@@ -255,6 +255,25 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
End Get End Get
End Property End Property
''' <summary>
''' Is this an event of a tuple type?
''' </summary>
Public Overridable ReadOnly Property IsTupleEvent() As Boolean
Get
Return False
End Get
End Property
''' <summary>
''' If this is an event of a tuple type, return corresponding underlying event from the
''' tuple underlying type. Otherwise, Nothing.
''' </summary>
Public Overridable ReadOnly Property TupleUnderlyingEvent() As EventSymbol
Get
Return Nothing
End Get
End Property
Private ReadOnly Property IEventSymbol_Type As ITypeSymbol Implements IEventSymbol.Type Private ReadOnly Property IEventSymbol_Type As ITypeSymbol Implements IEventSymbol.Type
Get Get
Return Me.Type Return Me.Type
...@@ -313,7 +332,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols ...@@ -313,7 +332,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Return visitor.VisitEvent(Me) Return visitor.VisitEvent(Me)
End Function End Function
Public NotOverridable Overrides Function Equals(obj As Object) As Boolean Public Overrides Function Equals(obj As Object) As Boolean
Dim other As EventSymbol = TryCast(obj, EventSymbol) Dim other As EventSymbol = TryCast(obj, EventSymbol)
If Nothing Is other Then If Nothing Is other Then
Return False Return False
......
...@@ -326,6 +326,26 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols ...@@ -326,6 +326,26 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
End Get End Get
End Property End Property
''' <summary>
''' Is this a field of a tuple type?
''' </summary>
Public Overridable ReadOnly Property IsTupleField() As Boolean
Get
Return False
End Get
End Property
''' <summary>
''' If this is a field of a tuple type, return corresponding underlying field from the
''' tuple underlying type. Otherwise, null. In case of a malformed underlying type
''' the corresponding underlying field might be missing, return null in this case too.
''' </summary>
Public Overridable ReadOnly Property TupleUnderlyingField() As FieldSymbol
Get
Return Nothing
End Get
End Property
Friend Function AsMember(newOwner As NamedTypeSymbol) As FieldSymbol Friend Function AsMember(newOwner As NamedTypeSymbol) As FieldSymbol
Debug.Assert(Me Is Me.OriginalDefinition) Debug.Assert(Me Is Me.OriginalDefinition)
Debug.Assert(newOwner.OriginalDefinition Is Me.ContainingSymbol.OriginalDefinition) Debug.Assert(newOwner.OriginalDefinition Is Me.ContainingSymbol.OriginalDefinition)
......
...@@ -781,6 +781,25 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols ...@@ -781,6 +781,25 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
End Get End Get
End Property End Property
''' <summary>
''' Is this a method of a tuple type?
''' </summary>
Public Overridable ReadOnly Property IsTupleMethod() As Boolean
Get
Return False
End Get
End Property
''' <summary>
''' If this is a method of a tuple type, return corresponding underlying method from the
''' tuple underlying type. Otherwise, Nothing.
''' </summary>
Public Overridable ReadOnly Property TupleUnderlyingMethod() As MethodSymbol
Get
Return Nothing
End Get
End Property
#Region "IMethodSymbol" #Region "IMethodSymbol"
Private ReadOnly Property IMethodSymbol_Arity As Integer Implements IMethodSymbol.Arity Private ReadOnly Property IMethodSymbol_Arity As Integer Implements IMethodSymbol.Arity
......
...@@ -1201,21 +1201,21 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols ...@@ -1201,21 +1201,21 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
End Get End Get
End Property End Property
Public ReadOnly Property TupleElementTypes As ImmutableArray(Of ITypeSymbol) Implements INamedTypeSymbol.TupleElementTypes Private ReadOnly Property INamedTypeSymbol_TupleElementTypes As ImmutableArray(Of ITypeSymbol) Implements INamedTypeSymbol.TupleElementTypes
Get Get
Return Nothing Return StaticCast(Of ITypeSymbol).From(TupleElementTypes())
End Get End Get
End Property End Property
Public ReadOnly Property TupleElementNames As ImmutableArray(Of String) Implements INamedTypeSymbol.TupleElementNames Public ReadOnly Property INamedTypeSymbol_TupleElementNames As ImmutableArray(Of String) Implements INamedTypeSymbol.TupleElementNames
Get Get
Return Nothing Return TupleElementNames
End Get End Get
End Property End Property
Public ReadOnly Property TupleUnderlyingType As INamedTypeSymbol Implements INamedTypeSymbol.TupleUnderlyingType Public ReadOnly Property INamedTypeSymbol_TupleUnderlyingType As INamedTypeSymbol Implements INamedTypeSymbol.TupleUnderlyingType
Get Get
Return Nothing Return TupleUnderlyingType
End Get End Get
End Property End Property
......
...@@ -408,6 +408,26 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols ...@@ -408,6 +408,26 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
End Get End Get
End Property End Property
''' <summary>
''' Is this a property of a tuple type?
''' </summary>
Public Overridable ReadOnly Property IsTupleProperty() As Boolean
Get
Return False
End Get
End Property
''' <summary>
''' If this is a property of a tuple type, return corresponding underlying property from the
''' tuple underlying type. Otherwise, Nothing.
''' </summary>
Public Overridable ReadOnly Property TupleUnderlyingProperty() As PropertySymbol
Get
Return Nothing
End Get
End Property
''' <summary> ''' <summary>
''' Clone the property parameters for the accessor method. The ''' Clone the property parameters for the accessor method. The
''' parameters are cloned (rather than referenced from the property) ''' parameters are cloned (rather than referenced from the property)
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Immutable
Imports System.Globalization
Imports System.Threading
Imports Microsoft.CodeAnalysis
Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
''' <summary>
''' Represents a field of a tuple type (such as (int, byte).Item1)
''' that doesn't have a corresponding backing field within the tuple underlying type.
''' Created in response to an error condition.
''' </summary>
Friend Class TupleErrorFieldSymbol
Inherits SynthesizedFieldSymbol
''' <summary>
''' If this field represents a tuple element (including the name match),
''' id is an index of the element (zero-based).
''' Otherwise, (-1 - [index in members array]);
''' </summary>
Private _tupleFieldId As Integer
Private _locations As ImmutableArray(Of Location)
Private _useSiteDiagnosticInfo As DiagnosticInfo
Public Overrides ReadOnly Property IsTupleField() As Boolean
Get
Return True
End Get
End Property
''' <summary>
''' If this field represents a tuple element (including the name match),
''' id is an index of the element (zero-based).
''' Otherwise, (-1 - [index in members array]);
''' </summary>
Public ReadOnly Property TupleFieldId() As Integer
Get
Return Me._tupleFieldId
End Get
End Property
Public Overrides ReadOnly Property TupleUnderlyingField() As FieldSymbol
Get
Return Nothing
End Get
End Property
Public Overrides ReadOnly Property Locations() As ImmutableArray(Of Location)
Get
Return Me._locations
End Get
End Property
Public Overrides ReadOnly Property DeclaringSyntaxReferences() As ImmutableArray(Of SyntaxReference)
Get
Return Symbol.GetDeclaringSyntaxReferenceHelper(Of VisualBasicSyntaxNode)(Me._locations)
End Get
End Property
Public Overrides ReadOnly Property IsImplicitlyDeclared() As Boolean
Get
Return False
End Get
End Property
Public Sub New(container As NamedTypeSymbol, name As String, tupleFieldId As Integer, location As Location, type As TypeSymbol, useSiteDiagnosticInfo As DiagnosticInfo)
MyBase.New(container, container, type, name)
Debug.Assert(name <> Nothing)
Me._locations = (If((location Is Nothing), ImmutableArray(Of Location).Empty, ImmutableArray.Create(Of Location)(location)))
Me._useSiteDiagnosticInfo = useSiteDiagnosticInfo
Me._tupleFieldId = tupleFieldId
End Sub
Public Overrides ReadOnly Property Type As TypeSymbol
Get
Return Me._type
End Get
End Property
Friend Overrides Function GetUseSiteErrorInfo() As DiagnosticInfo
Return Me._useSiteDiagnosticInfo
End Function
Public Overrides Function GetHashCode() As Integer
Return Hash.Combine(Me.ContainingType.GetHashCode(), Me._tupleFieldId.GetHashCode())
End Function
Public Overrides Function Equals(obj As Object) As Boolean
Return Me.Equals(TryCast(obj, TupleErrorFieldSymbol))
End Function
Public Overloads Function Equals(other As TupleErrorFieldSymbol) As Boolean
Dim flag As Boolean = other Is Me
Return flag OrElse (other IsNot Nothing AndAlso Me._tupleFieldId = other._tupleFieldId AndAlso Me.ContainingType Is other.ContainingType)
End Function
End Class
End Namespace
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Immutable
Imports System.Globalization
Imports System.Threading
Imports Microsoft.CodeAnalysis
Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
''' <summary>
''' Represents an event of a tuple type (such as (int, byte).SomeEvent)
''' that is backed by an event within the tuple underlying type.
''' </summary>
Friend Class TupleEventSymbol
Inherits WrappedEventSymbol
Private _containingType As TupleTypeSymbol
Public Overrides ReadOnly Property IsTupleEvent() As Boolean
Get
Return True
End Get
End Property
Public Overrides ReadOnly Property TupleUnderlyingEvent() As EventSymbol
Get
Return Me._underlyingEvent
End Get
End Property
Public Overrides ReadOnly Property ContainingSymbol() As Symbol
Get
Return Me._containingType
End Get
End Property
Public Overrides ReadOnly Property Type() As TypeSymbol
Get
Return Me._underlyingEvent.Type
End Get
End Property
Public Overrides ReadOnly Property AddMethod() As MethodSymbol
Get
Return Me._containingType.GetTupleMemberSymbolForUnderlyingMember(Of MethodSymbol)(Me._underlyingEvent.AddMethod)
End Get
End Property
Public Overrides ReadOnly Property RemoveMethod() As MethodSymbol
Get
Return Me._containingType.GetTupleMemberSymbolForUnderlyingMember(Of MethodSymbol)(Me._underlyingEvent.RemoveMethod)
End Get
End Property
Friend Overrides ReadOnly Property AssociatedField() As FieldSymbol
Get
Return Me._containingType.GetTupleMemberSymbolForUnderlyingMember(Of FieldSymbol)(Me._underlyingEvent.AssociatedField)
End Get
End Property
Public Overrides ReadOnly Property RaiseMethod As MethodSymbol
Get
Return Me._containingType.GetTupleMemberSymbolForUnderlyingMember(Of MethodSymbol)(Me._underlyingEvent.RaiseMethod)
End Get
End Property
Friend Overrides ReadOnly Property IsExplicitInterfaceImplementation() As Boolean
Get
Return Me._underlyingEvent.IsExplicitInterfaceImplementation
End Get
End Property
Public Overrides ReadOnly Property ExplicitInterfaceImplementations() As ImmutableArray(Of EventSymbol)
Get
Return Me._underlyingEvent.ExplicitInterfaceImplementations
End Get
End Property
Public Sub New(container As TupleTypeSymbol, underlyingEvent As EventSymbol)
MyBase.New(underlyingEvent)
Me._containingType = container
End Sub
Friend Overrides Function GetUseSiteErrorInfo() As DiagnosticInfo
Dim useSiteDiagnostic As DiagnosticInfo = MyBase.GetUseSiteErrorInfo
MyBase.MergeUseSiteErrorInfo(useSiteDiagnostic, Me._underlyingEvent.GetUseSiteErrorInfo())
Return useSiteDiagnostic
End Function
Public Overrides Function GetHashCode() As Integer
Return Me._underlyingEvent.GetHashCode()
End Function
Public Overrides Function Equals(obj As Object) As Boolean
Return Me.Equals(TryCast(obj, TupleEventSymbol))
End Function
Public Overloads Function Equals(other As TupleEventSymbol) As Boolean
Dim flag As Boolean = other Is Me
Return flag OrElse (other IsNot Nothing AndAlso Me._containingType Is other._containingType AndAlso Me._underlyingEvent Is other._underlyingEvent)
End Function
Public Overrides Function GetAttributes() As ImmutableArray(Of VisualBasicAttributeData)
Return Me._underlyingEvent.GetAttributes()
End Function
End Class
End Namespace
\ No newline at end of file
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Immutable
Imports System.Globalization
Imports System.Threading
Imports Microsoft.CodeAnalysis
Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
''' <summary>
''' Represents a non-element field of a tuple type (such as (int, byte).Rest)
''' that is backed by a real field within the tuple underlying type.
''' </summary>
Friend Class TupleFieldSymbol
Inherits WrappedFieldSymbol
Protected _containingTuple As TupleTypeSymbol
Private _tupleFieldId As Integer
Public Overrides ReadOnly Property IsTupleField() As Boolean
Get
Return True
End Get
End Property
Public Overrides ReadOnly Property TupleUnderlyingField() As FieldSymbol
Get
Return Me._underlyingField
End Get
End Property
Public ReadOnly Property TupleFieldId() As Integer
Get
Return Me._tupleFieldId
End Get
End Property
Public Overrides ReadOnly Property AssociatedSymbol() As Symbol
Get
Return Me._containingTuple.GetTupleMemberSymbolForUnderlyingMember(Of Symbol)(Me._underlyingField.AssociatedSymbol)
End Get
End Property
Public Overrides ReadOnly Property ContainingSymbol() As Symbol
Get
Return Me._containingTuple
End Get
End Property
Public Overrides ReadOnly Property CustomModifiers() As ImmutableArray(Of CustomModifier)
Get
Return Me._underlyingField.CustomModifiers
End Get
End Property
Public Overrides ReadOnly Property Type As TypeSymbol
Get
Return Me._underlyingField.Type
End Get
End Property
Public Sub New(container As TupleTypeSymbol, underlyingField As FieldSymbol, tupleFieldId As Integer)
MyBase.New(underlyingField)
Me._containingTuple = container
Me._tupleFieldId = tupleFieldId
End Sub
Public Overrides Function GetAttributes() As ImmutableArray(Of VisualBasicAttributeData)
Return Me._underlyingField.GetAttributes()
End Function
Friend Overrides Function GetUseSiteErrorInfo() As DiagnosticInfo
Dim useSiteDiagnostic As DiagnosticInfo = MyBase.GetUseSiteErrorInfo
MyBase.MergeUseSiteErrorInfo(useSiteDiagnostic, Me._underlyingField.GetUseSiteErrorInfo())
Return useSiteDiagnostic
End Function
Public Overrides Function GetHashCode() As Integer
Return Hash.Combine(Me._containingTuple.GetHashCode(), Me._tupleFieldId.GetHashCode())
End Function
Public Overrides Function Equals(obj As Object) As Boolean
Return Me.Equals(TryCast(obj, TupleFieldSymbol))
End Function
Public Overloads Function Equals(other As TupleFieldSymbol) As Boolean
Dim flag As Boolean = other Is Me
Return flag OrElse (other IsNot Nothing AndAlso Me._tupleFieldId = other._tupleFieldId AndAlso Me._containingTuple Is other._containingTuple)
End Function
End Class
''' <summary>
''' Represents an element field of a tuple type (such as (int, byte).Item1)
''' that is backed by a real field with the same name within the tuple underlying type.
''' </summary>
Friend Class TupleElementFieldSymbol
Inherits TupleFieldSymbol
Private _locations As ImmutableArray(Of Location)
Public Overrides ReadOnly Property Locations() As ImmutableArray(Of Location)
Get
Return Me._locations
End Get
End Property
Public Overrides ReadOnly Property DeclaringSyntaxReferences() As ImmutableArray(Of SyntaxReference)
Get
Return Symbol.GetDeclaringSyntaxReferenceHelper(Of VisualBasicSyntaxNode)(Me._locations)
End Get
End Property
Public Overrides ReadOnly Property IsImplicitlyDeclared() As Boolean
Get
Return False
End Get
End Property
Friend Overrides ReadOnly Property TypeLayoutOffset() As Integer?
Get
Dim flag As Boolean = Me._underlyingField.ContainingType IsNot Me._containingTuple.TupleUnderlyingType
Dim result As Integer?
If flag Then
result = Nothing
Else
result = MyBase.TypeLayoutOffset
End If
Return result
End Get
End Property
Public Overrides ReadOnly Property AssociatedSymbol() As Symbol
Get
Dim flag As Boolean = Me._underlyingField.ContainingType IsNot Me._containingTuple.TupleUnderlyingType
Dim result As Symbol
If flag Then
result = Nothing
Else
result = MyBase.AssociatedSymbol
End If
Return result
End Get
End Property
Public Sub New(container As TupleTypeSymbol, underlyingField As FieldSymbol, tupleFieldId As Integer, location As Location)
MyBase.New(container, underlyingField, tupleFieldId)
Me._locations = (If((location Is Nothing), ImmutableArray(Of Location).Empty, ImmutableArray.Create(Of Location)(location)))
End Sub
End Class
''' <summary>
''' Represents an element field of a tuple type (such as (int a, byte b).a, or (int a, byte b).b)
''' that is backed by a real field with a different name within the tuple underlying type.
''' </summary>
Friend Class TupleRenamedElementFieldSymbol
Inherits TupleElementFieldSymbol
Private _name As String
Public Overrides ReadOnly Property Name() As String
Get
Return Me._name
End Get
End Property
Friend Overrides ReadOnly Property TypeLayoutOffset() As Integer?
Get
Return Nothing
End Get
End Property
Public Overrides ReadOnly Property AssociatedSymbol() As Symbol
Get
Return Nothing
End Get
End Property
Public Sub New(container As TupleTypeSymbol, underlyingField As FieldSymbol, name As String, tupleElementOrdinal As Integer, location As Location)
MyBase.New(container, underlyingField, tupleElementOrdinal, location)
Debug.Assert(name <> Nothing)
Debug.Assert(name <> underlyingField.Name)
Me._name = name
End Sub
End Class
End Namespace
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Immutable
Imports System.Globalization
Imports System.Threading
Imports Microsoft.CodeAnalysis
Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
''' <summary>
''' Represents a method of a tuple type (such as (int, byte).ToString())
''' that is backed by a method within the tuple underlying type.
''' </summary>
Friend Class TupleMethodSymbol
Inherits WrappedMethodSymbol
Private _containingType As TupleTypeSymbol
Private _underlyingMethod As MethodSymbol
Private _typeParameters As ImmutableArray(Of TypeParameterSymbol)
Private _lazyParameters As ImmutableArray(Of ParameterSymbol)
Public Overrides ReadOnly Property IsTupleMethod() As Boolean
Get
Return True
End Get
End Property
Public Overrides ReadOnly Property TupleUnderlyingMethod() As MethodSymbol
Get
Return Me._underlyingMethod.ConstructedFrom
End Get
End Property
Public Overrides ReadOnly Property UnderlyingMethod() As MethodSymbol
Get
Return Me._underlyingMethod
End Get
End Property
Public Overrides ReadOnly Property AssociatedSymbol() As Symbol
Get
Return Me._containingType.GetTupleMemberSymbolForUnderlyingMember(Of Symbol)(Me._underlyingMethod.ConstructedFrom.AssociatedSymbol)
End Get
End Property
Public Overrides ReadOnly Property ContainingSymbol() As Symbol
Get
Return Me._containingType
End Get
End Property
Public Overrides ReadOnly Property ExplicitInterfaceImplementations() As ImmutableArray(Of MethodSymbol)
Get
Return Me._underlyingMethod.ConstructedFrom.ExplicitInterfaceImplementations
End Get
End Property
Public Overrides ReadOnly Property Parameters() As ImmutableArray(Of ParameterSymbol)
Get
Dim isDefault As Boolean = Me._lazyParameters.IsDefault
If isDefault Then
InterlockedOperations.Initialize(Of ParameterSymbol)(Me._lazyParameters, Me.CreateParameters())
End If
Return Me._lazyParameters
End Get
End Property
Public Overrides ReadOnly Property IsSub() As Boolean
Get
Return Me._underlyingMethod.IsSub
End Get
End Property
Public Overrides ReadOnly Property ReturnType() As TypeSymbol
Get
Return Me._underlyingMethod.ReturnType
End Get
End Property
Public Overrides ReadOnly Property ReturnTypeCustomModifiers() As ImmutableArray(Of CustomModifier)
Get
Return Me._underlyingMethod.ReturnTypeCustomModifiers
End Get
End Property
Public Overrides ReadOnly Property TypeArguments() As ImmutableArray(Of TypeSymbol)
Get
Return StaticCast(Of TypeSymbol).From(Me._typeParameters)
End Get
End Property
Public Overrides ReadOnly Property TypeParameters() As ImmutableArray(Of TypeParameterSymbol)
Get
Return Me._typeParameters
End Get
End Property
Public Sub New(container As TupleTypeSymbol, underlyingMethod As MethodSymbol)
Debug.Assert(underlyingMethod.ConstructedFrom Is underlyingMethod)
Me._containingType = container
Me._underlyingMethod = underlyingMethod
' PROTOTYPE: tuples Should alpha rename typeparameters in case a tuple method has any.
Me._typeParameters = Me._underlyingMethod.TypeParameters
End Sub
Private Function CreateParameters() As ImmutableArray(Of ParameterSymbol)
Dim parameters As ImmutableArray(Of ParameterSymbol) = Me._underlyingMethod.Parameters
Dim instance As ArrayBuilder(Of ParameterSymbol) = ArrayBuilder(Of ParameterSymbol).GetInstance(parameters.Length)
Dim enumerator As ImmutableArray(Of ParameterSymbol).Enumerator = parameters.GetEnumerator()
While enumerator.MoveNext()
Dim current As ParameterSymbol = enumerator.Current
instance.Add(New TupleParameterSymbol(Me, current))
End While
Return instance.ToImmutableAndFree()
End Function
Public Overrides Function GetAttributes() As ImmutableArray(Of VisualBasicAttributeData)
Return Me._underlyingMethod.GetAttributes()
End Function
Public Overrides Function GetReturnTypeAttributes() As ImmutableArray(Of VisualBasicAttributeData)
Return Me._underlyingMethod.GetReturnTypeAttributes()
End Function
Friend Overrides Function CalculateLocalSyntaxOffset(localPosition As Integer, localTree As SyntaxTree) As Integer
Throw ExceptionUtilities.Unreachable
End Function
Friend Overrides Function GetUseSiteErrorInfo() As DiagnosticInfo
Dim useSiteDiagnostic As DiagnosticInfo = MyBase.GetUseSiteErrorInfo()
MyBase.MergeUseSiteErrorInfo(useSiteDiagnostic, Me._underlyingMethod.GetUseSiteErrorInfo())
Return useSiteDiagnostic
End Function
Public Overrides Function GetHashCode() As Integer
Return Me._underlyingMethod.ConstructedFrom.GetHashCode()
End Function
Public Overrides Function Equals(obj As Object) As Boolean
Return Me.Equals(TryCast(obj, TupleMethodSymbol))
End Function
Public Overloads Function Equals(other As TupleMethodSymbol) As Boolean
Dim flag As Boolean = other Is Me
Return flag OrElse (other IsNot Nothing AndAlso Me._containingType Is other._containingType AndAlso Me._underlyingMethod.ConstructedFrom Is other._underlyingMethod.ConstructedFrom)
End Function
End Class
End Namespace
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Immutable
Imports System.Globalization
Imports System.Threading
Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
''' <summary>
''' Represents a parameter of a method or a property of a tuple type
''' </summary>
Friend Class TupleParameterSymbol
Inherits WrappedParameterSymbol
Private _container As Symbol
Public Overrides ReadOnly Property ContainingSymbol() As Symbol
Get
Return Me._container
End Get
End Property
Public Sub New(container As Symbol, underlyingParameter As ParameterSymbol)
MyBase.New(underlyingParameter)
Debug.Assert(container IsNot Nothing)
Me._container = container
End Sub
Public Overrides Function GetHashCode() As Integer
Return Me._underlyingParameter.GetHashCode()
End Function
Public Overrides Function Equals(obj As Object) As Boolean
Return Me.Equals(TryCast(obj, TupleParameterSymbol))
End Function
Public Overloads Function Equals(other As TupleParameterSymbol) As Boolean
Dim flag As Boolean = other Is Me
Return flag OrElse (other IsNot Nothing AndAlso Me._container Is other._container AndAlso Me._underlyingParameter Is other._underlyingParameter)
End Function
End Class
End Namespace
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Immutable
Imports System.Globalization
Imports System.Threading
Imports Microsoft.CodeAnalysis
Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
''' <summary>
''' Represents a property of a tuple type (such as (int, byte).SomeProperty)
''' that is backed by a property within the tuple underlying type.
''' </summary>
Friend NotInheritable Class TuplePropertySymbol
Inherits WrappedPropertySymbol
Private _containingType As TupleTypeSymbol
Private _lazyParameters As ImmutableArray(Of ParameterSymbol)
Public Overrides ReadOnly Property IsTupleProperty() As Boolean
Get
Return True
End Get
End Property
Public Overrides ReadOnly Property TupleUnderlyingProperty() As PropertySymbol
Get
Return Me._underlyingProperty
End Get
End Property
Public Overrides ReadOnly Property Type() As TypeSymbol
Get
Return Me._underlyingProperty.Type
End Get
End Property
Public Overrides ReadOnly Property TypeCustomModifiers() As ImmutableArray(Of CustomModifier)
Get
Return Me._underlyingProperty.TypeCustomModifiers
End Get
End Property
Public Overrides ReadOnly Property Parameters() As ImmutableArray(Of ParameterSymbol)
Get
Dim isDefault As Boolean = Me._lazyParameters.IsDefault
If isDefault Then
InterlockedOperations.Initialize(Of ParameterSymbol)(Me._lazyParameters, Me.CreateParameters())
End If
Return Me._lazyParameters
End Get
End Property
Public Overrides ReadOnly Property GetMethod() As MethodSymbol
Get
Return Me._containingType.GetTupleMemberSymbolForUnderlyingMember(Of MethodSymbol)(Me._underlyingProperty.GetMethod)
End Get
End Property
Public Overrides ReadOnly Property SetMethod() As MethodSymbol
Get
Return Me._containingType.GetTupleMemberSymbolForUnderlyingMember(Of MethodSymbol)(Me._underlyingProperty.SetMethod)
End Get
End Property
Friend Overrides ReadOnly Property AssociatedField As FieldSymbol
Get
Return Me._containingType.GetTupleMemberSymbolForUnderlyingMember(Of FieldSymbol)(Me._underlyingProperty.AssociatedField)
End Get
End Property
Public Overrides ReadOnly Property ExplicitInterfaceImplementations() As ImmutableArray(Of PropertySymbol)
Get
Return Me._underlyingProperty.ExplicitInterfaceImplementations
End Get
End Property
Public Overrides ReadOnly Property ContainingSymbol() As Symbol
Get
Return Me._containingType
End Get
End Property
Public Overrides ReadOnly Property IsOverloads As Boolean
Get
Return Me._underlyingProperty.IsOverloads
End Get
End Property
Friend Overrides ReadOnly Property IsMyGroupCollectionProperty As Boolean
Get
Return Me._underlyingProperty.IsMyGroupCollectionProperty
End Get
End Property
Public Sub New(container As TupleTypeSymbol, underlyingProperty As PropertySymbol)
MyBase.New(underlyingProperty)
Me._containingType = container
End Sub
Private Function CreateParameters() As ImmutableArray(Of ParameterSymbol)
Dim parameters As ImmutableArray(Of ParameterSymbol) = Me._underlyingProperty.Parameters
Dim instance As ArrayBuilder(Of ParameterSymbol) = ArrayBuilder(Of ParameterSymbol).GetInstance(parameters.Length)
Dim enumerator As ImmutableArray(Of ParameterSymbol).Enumerator = parameters.GetEnumerator()
While enumerator.MoveNext()
Dim current As ParameterSymbol = enumerator.Current
instance.Add(New TupleParameterSymbol(Me, current))
End While
Return instance.ToImmutableAndFree()
End Function
Friend Overrides Function GetUseSiteErrorInfo() As DiagnosticInfo
Dim useSiteDiagnostic As DiagnosticInfo = MyBase.GetUseSiteErrorInfo
MyBase.MergeUseSiteErrorInfo(useSiteDiagnostic, Me._underlyingProperty.GetUseSiteErrorInfo())
Return useSiteDiagnostic
End Function
Public Overrides Function GetHashCode() As Integer
Return Me._underlyingProperty.GetHashCode()
End Function
Public Overrides Function Equals(obj As Object) As Boolean
Return Me.Equals(TryCast(obj, TuplePropertySymbol))
End Function
Public Overloads Function Equals(other As TuplePropertySymbol) As Boolean
Dim flag As Boolean = other Is Me
Return flag OrElse (other IsNot Nothing AndAlso Me._containingType Is other._containingType AndAlso Me._underlyingProperty Is other._underlyingProperty)
End Function
Public Overrides Function GetAttributes() As ImmutableArray(Of VisualBasicAttributeData)
Return Me._underlyingProperty.GetAttributes()
End Function
End Class
End Namespace
...@@ -399,6 +399,62 @@ Done: ...@@ -399,6 +399,62 @@ Done:
Return result Return result
End Function End Function
Public Overridable ReadOnly Property IsTupleType() As Boolean
Get
Return False
End Get
End Property
Public Overridable ReadOnly Property TupleUnderlyingType() As NamedTypeSymbol
Get
Return Nothing
End Get
End Property
Public Overridable ReadOnly Property TupleElementTypes() As ImmutableArray(Of TypeSymbol)
Get
Return Nothing
End Get
End Property
Public Overridable ReadOnly Property TupleElementNames() As ImmutableArray(Of String)
Get
Return Nothing
End Get
End Property
''' <summary>
''' Verify if the given type can be used to back a tuple type
''' and return cardinality of that tuple type in <paramref name="tupleCardinality"/>.
''' </summary>
''' <param name="tupleCardinality">If method returns true, contains cardinality of the compatible tuple type.</param>
''' <returns></returns>
Public Overridable Function IsTupleCompatible(<Out> ByRef tupleCardinality As Integer) As Boolean
tupleCardinality = 0
Return False
End Function
''' <summary>
''' Verify if the given type can be used to back a tuple type.
''' </summary>
Public Function IsTupleCompatible() As Boolean
Dim countOfItems As Integer
Return IsTupleCompatible(countOfItems)
End Function
''' <summary>
''' Verify if the given type is a tuple of a given cardinality, or can be used to back a tuple type
''' with the given cardinality.
''' </summary>
Public Function IsTupleOrCompatibleWithTupleOfCardinality(targetCardinality As Integer) As Boolean
If (IsTupleType) Then
Return TupleElementTypes.Length = targetCardinality
End If
Dim countOfItems As Integer
Return IsTupleCompatible(countOfItems) AndAlso countOfItems = targetCardinality
End Function
#Region "Use-Site Diagnostics" #Region "Use-Site Diagnostics"
''' <summary> ''' <summary>
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Immutable
Imports System.Globalization
Imports System.Threading
Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
''' <summary>
''' Represents an event that is based on another event.
''' When inheriting from this class, one shouldn't assume that
''' the default behavior it has is appropriate for every case.
''' That behavior should be carefully reviewed and derived type
''' should override behavior as appropriate.
''' </summary>
Friend MustInherit Class WrappedEventSymbol
Inherits EventSymbol
Protected _underlyingEvent As EventSymbol
Public ReadOnly Property UnderlyingEvent() As EventSymbol
Get
Return Me._underlyingEvent
End Get
End Property
Public Overrides ReadOnly Property IsImplicitlyDeclared() As Boolean
Get
Return Me._underlyingEvent.IsImplicitlyDeclared
End Get
End Property
Friend Overrides ReadOnly Property HasSpecialName() As Boolean
Get
Return Me._underlyingEvent.HasSpecialName
End Get
End Property
Public Overrides ReadOnly Property Name() As String
Get
Return Me._underlyingEvent.Name
End Get
End Property
Public Overrides ReadOnly Property Locations() As ImmutableArray(Of Location)
Get
Return Me._underlyingEvent.Locations
End Get
End Property
Public Overrides ReadOnly Property DeclaringSyntaxReferences() As ImmutableArray(Of SyntaxReference)
Get
Return Me._underlyingEvent.DeclaringSyntaxReferences
End Get
End Property
Public Overrides ReadOnly Property DeclaredAccessibility() As Accessibility
Get
Return Me._underlyingEvent.DeclaredAccessibility
End Get
End Property
Public Overrides ReadOnly Property IsShared() As Boolean
Get
Return Me._underlyingEvent.IsShared
End Get
End Property
Public Overrides ReadOnly Property IsOverridable() As Boolean
Get
Return Me._underlyingEvent.IsOverridable
End Get
End Property
Public Overrides ReadOnly Property IsOverrides() As Boolean
Get
Return Me._underlyingEvent.IsOverrides
End Get
End Property
Public Overrides ReadOnly Property IsMustOverride() As Boolean
Get
Return Me._underlyingEvent.IsMustOverride
End Get
End Property
Public Overrides ReadOnly Property IsNotOverridable() As Boolean
Get
Return Me._underlyingEvent.IsNotOverridable
End Get
End Property
Friend Overrides ReadOnly Property ObsoleteAttributeData() As ObsoleteAttributeData
Get
Return Me._underlyingEvent.ObsoleteAttributeData
End Get
End Property
Public Overrides ReadOnly Property IsWindowsRuntimeEvent() As Boolean
Get
Return Me._underlyingEvent.IsWindowsRuntimeEvent
End Get
End Property
Friend Overrides ReadOnly Property HasRuntimeSpecialName() As Boolean
Get
Return Me._underlyingEvent.HasRuntimeSpecialName
End Get
End Property
Public Sub New(underlyingEvent As EventSymbol)
Debug.Assert(underlyingEvent IsNot Nothing)
Me._underlyingEvent = underlyingEvent
End Sub
Public Overrides Function GetDocumentationCommentXml(Optional preferredCulture As CultureInfo = Nothing, Optional expandIncludes As Boolean = False, Optional cancellationToken As CancellationToken = Nothing) As String
Return Me._underlyingEvent.GetDocumentationCommentXml(preferredCulture, expandIncludes, cancellationToken)
End Function
End Class
End Namespace
...@@ -205,6 +205,42 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols ...@@ -205,6 +205,42 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
End Get End Get
End Property End Property
Friend Overrides ReadOnly Property IsMethodKindBasedOnSyntax As Boolean
Get
Return Me.UnderlyingMethod.IsMethodKindBasedOnSyntax
End Get
End Property
Public Overrides ReadOnly Property IsIterator As Boolean
Get
Return Me.UnderlyingMethod.IsIterator
End Get
End Property
Friend Overrides ReadOnly Property Syntax As VisualBasicSyntaxNode
Get
Return Me.UnderlyingMethod.Syntax
End Get
End Property
Public Overrides ReadOnly Property IsOverloads As Boolean
Get
Return Me.UnderlyingMethod.IsOverloads
End Get
End Property
Friend Overrides ReadOnly Property GenerateDebugInfoImpl As Boolean
Get
Return Me.UnderlyingMethod.GenerateDebugInfoImpl
End Get
End Property
Public Overrides ReadOnly Property IsOverridable As Boolean
Get
Return Me.UnderlyingMethod.IsOverridable
End Get
End Property
Friend Overrides Function IsMetadataNewSlot(Optional ignoreInterfaceImplementationChanges As Boolean = False) As Boolean Friend Overrides Function IsMetadataNewSlot(Optional ignoreInterfaceImplementationChanges As Boolean = False) As Boolean
Return Me.UnderlyingMethod.IsMetadataNewSlot(ignoreInterfaceImplementationChanges) Return Me.UnderlyingMethod.IsMetadataNewSlot(ignoreInterfaceImplementationChanges)
End Function End Function
......
...@@ -150,6 +150,36 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols ...@@ -150,6 +150,36 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
End Get End Get
End Property End Property
Friend Overrides ReadOnly Property IsExplicitByRef As Boolean
Get
Return Me._underlyingParameter.IsExplicitByRef
End Get
End Property
Public Overrides ReadOnly Property IsOptional As Boolean
Get
Return Me._underlyingParameter.IsOptional
End Get
End Property
Public Overrides ReadOnly Property HasExplicitDefaultValue As Boolean
Get
Return Me._underlyingParameter.HasExplicitDefaultValue
End Get
End Property
Friend Overrides ReadOnly Property ExplicitDefaultConstantValue(inProgress As SymbolsInProgress(Of ParameterSymbol)) As ConstantValue
Get
Return Me._underlyingParameter.ExplicitDefaultConstantValue(inProgress)
End Get
End Property
Friend Overrides ReadOnly Property HasOptionCompare As Boolean
Get
Return Me._underlyingParameter.HasOptionCompare
End Get
End Property
Protected Sub New(underlyingParameter As ParameterSymbol) Protected Sub New(underlyingParameter As ParameterSymbol)
Debug.Assert(underlyingParameter IsNot Nothing) Debug.Assert(underlyingParameter IsNot Nothing)
Me._underlyingParameter = underlyingParameter Me._underlyingParameter = underlyingParameter
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册