⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 memberaccessexpression.vb

📁 大名鼎鼎的mono是.NET平台的跨平台(支持linux
💻 VB
📖 第 1 页 / 共 3 页
字号:
            If m_Second.IsKeyword AndAlso m_Second.Token.Equals(KS.[New]) Then                If TypeOf m_First Is InstanceExpression Then                    Classification = New MethodGroupClassification(Me, m_First, Nothing, Helper.GetInstanceConstructors(T))                    Return True                Else                    Helper.AddError()                End If            End If            Dim members As Generic.List(Of MemberInfo)            Dim member As MemberCacheEntry            member = Compiler.TypeManager.GetCache(T).LookupFlattened(Name)            If member Is Nothing Then                If Me.File.IsOptionStrictOn = False AndAlso Helper.CompareType(T, Compiler.TypeCache.System_Object) Then                    Classification = New LateBoundAccessClassification(Me, m_First, Nothing, Name)                    Return True                End If                Return Compiler.Report.ShowMessage(Messages.VBNC30456, Me.Location, Name, T.FullName) AndAlso result            End If            members = member.Members            Dim withTypeArgs As IdentifierOrKeywordWithTypeArguments            withTypeArgs = TryCast(m_Second, IdentifierOrKeywordWithTypeArguments)            If withTypeArgs IsNot Nothing Then                members = Helper.FilterByTypeArguments(members, withTypeArgs.TypeArguments)            End If            members = Helper.FilterExternalInaccessible(Me.Compiler, members)            If members.Count = 0 Then                result = Compiler.Report.ShowMessage(Messages.VBNC30456, Me.Location, Name, T.FullName) AndAlso result                If result = False Then Return result            End If            If members.Count > 0 Then                Dim first As Object = members(0)                '** If I identifies one or more methods, then the result is a method group with the associated type                 '   argument list and an associated instance expression of E.                If Helper.IsMethodDeclaration(first) Then                    m_First = m_First.GetObjectReference                    Classification = New MethodGroupClassification(Me, m_First, Nothing, members)                    Return True                End If                '** If I identifies one or more properties, then the result is a property group with an                 '   associated instance expression of E.                If Helper.IsPropertyDeclaration(first) Then                    m_First = m_First.GetObjectReference                    Classification = New PropertyGroupClassification(Me, m_First, members)                    Return True                End If                If members.Count > 1 Then Throw New InternalException(Me)                '** If I identifies a shared variable or an instance variable, and if the variable is read-only,                 '   and the reference occurs outside a constructor of the class in which the variable is declared                 '   appropriate for the kind of variable (shared or instance), then the result is the value of the                 '   variable I in the object referenced by E.                 '   If T is a reference type, then the result is the variable I in the object referenced by E.                 '   Otherwise, if T is a value type and the expression E is classified as a variable, the result is                 '   a variable; otherwise the result is a value.                Dim var As VariableDeclaration = TryCast(first, VariableDeclaration)                Dim fld As FieldInfo = TryCast(first, FieldInfo)                If var IsNot Nothing Then                    Dim constructor As ConstructorDeclaration = Me.FindFirstParent(Of ConstructorDeclaration)()                    If var.Modifiers.Is(ModifierMasks.ReadOnly) AndAlso (constructor Is Nothing OrElse constructor.Modifiers.Is(ModifierMasks.Shared) <> var.Modifiers.Is(ModifierMasks.Shared)) Then                        Classification = New ValueClassification(Me, var)                        Return True                    ElseIf T.IsClass Then                        Classification = New VariableClassification(Me, var)                        Return True                    ElseIf T.IsValueType Then                        If m_First.Classification.IsVariableClassification Then                            Classification = New VariableClassification(Me, var)                            Return True                        ElseIf m_First.Classification.IsValueClassification Then                            Classification = New ValueClassification(Me, var)                            Return True                        Else                            Throw New InternalException(Me)                        End If                    Else                        Throw New InternalException(Me)                    End If                ElseIf fld IsNot Nothing Then                    Dim constructor As ConstructorDeclaration = Me.FindFirstParent(Of ConstructorDeclaration)()                    If fld.IsInitOnly AndAlso (constructor Is Nothing OrElse constructor.Modifiers.Is(ModifierMasks.Shared) <> fld.IsStatic) Then                        If fld.IsStatic Then                            Classification = New ValueClassification(Me, fld, Nothing)                        Else                            Classification = New ValueClassification(Me, fld, m_First)                        End If                        Return True                    ElseIf T.IsClass Then                        If fld.IsStatic Then                            Classification = New VariableClassification(Me, fld, Nothing)                        Else                            Classification = New VariableClassification(Me, fld, m_First)                        End If                        Return True                    ElseIf T.IsValueType Then                        If m_First.Classification.IsVariableClassification Then                            If Not TypeOf m_First Is InstanceExpression Then                                m_First = m_First.GetObjectReference                            End If                            If fld.IsStatic Then                                Classification = New VariableClassification(Me, fld, Nothing)                            Else                                Classification = New VariableClassification(Me, fld, m_First)                            End If                            Return True                        ElseIf m_First.Classification.IsValueClassification Then                            If fld.IsStatic Then                                Classification = New ValueClassification(Me, fld, Nothing)                            Else                                Classification = New ValueClassification(Me, fld, m_First)                            End If                            Return True                        ElseIf m_First.Classification.CanBeValueClassification Then                            m_First = m_First.ReclassifyToValueExpression                            result = m_First.ResolveExpression(ResolveInfo.Default(Info.Compiler)) AndAlso result                            If fld.IsStatic Then                                Classification = New ValueClassification(Me, fld, Nothing)                            Else                                Classification = New ValueClassification(Me, fld, m_First)                            End If                            Return True                        Else                            Throw New InternalException(Me)                        End If                    Else                        Throw New InternalException(Me)                    End If                End If                '** If I identifies an event, the result is an event access with an associated instance expression of E.                If Helper.IsEventDeclaration(first) Then                    Dim red As EventDeclaration = TryCast(first, EventDeclaration)                    If red Is Nothing AndAlso TypeOf first Is EventDescriptor Then                        red = DirectCast(first, EventDescriptor).EventDeclaration                    End If                    If red IsNot Nothing Then                        Classification = New EventAccessClassification(Me, red.EventDescriptor, m_First)                        Return True                    End If                    Dim eInfo As EventInfo = TryCast(first, EventInfo)                    If eInfo IsNot Nothing Then                        Classification = New EventAccessClassification(Me, eInfo, m_First)                        Return True                    End If                End If                '** If I identifies a constant, then the result is the value of that constant.                Dim constant As ConstantDeclaration = TryCast(first, ConstantDeclaration)                If constant IsNot Nothing Then                    Classification = New ValueClassification(Me, constant)                    Return True                End If                '** If I identifies an enumeration member, then the result is the value of that enumeration member.                If Helper.IsEnumFieldDeclaration(first) Then                    Dim em As EnumMemberDeclaration = TryCast(first, EnumMemberDeclaration)                    Dim emfld As FieldInfo = TryCast(first, FieldInfo)                    If em IsNot Nothing Then                        Classification = New ValueClassification(Me, em)                        Return True                    ElseIf emfld IsNot Nothing Then                        Classification = New ValueClassification(Me, emfld, Nothing)                        Return True                    End If                End If                '** If T is Object, then the result is a late-bound member lookup classified as a late-bound access                 '   with an associated instance expression of E.                If T IsNot Nothing Then                    Dim td As TypeDescriptor = TryCast(T, TypeDescriptor)                    Dim compresult As Boolean = False                    If td Is Nothing Then compresult = Helper.CompareType(T, Compiler.TypeCache.System_Object)                    If compresult Then                        Helper.NotImplemented()                    End If                End If                '** Otherwise, E.I is an invalid member reference, and a compile-time error occurs.                Compiler.Report.ShowMessage(Messages.VBNC30456, Me.Location, Name, T.FullName)                result = False            Else                Compiler.Report.ShowMessage(Messages.VBNC30456, Me.Location, Name, T.FullName)                result = False            End If        End If        Compiler.Report.ShowMessage(Messages.VBNC30456, Location, Name, m_First.AsString)        Return False    End Function    Shared Function CreateAndParseTo(ByRef result As Expression) As Boolean        Helper.NotImplemented()    End Function    Shared Function IsUnaryMe(ByVal Tm As tm) As Boolean        Return Tm.CurrentToken.Equals(KS.Dot)    End Function    Shared Function IsBinaryMe(ByVal tm As tm) As Boolean        Return tm.CurrentToken.Equals(KS.Dot)    End Function    ReadOnly Property FirstExpression() As Expression        Get            Return m_First        End Get    End Property    ReadOnly Property SecondExpression() As IdentifierOrKeyword        Get            Return m_Second        End Get    End Property    ReadOnly Property CompleteName() As String        Get            Return m_First.ToString & "." & m_Second.Name        End Get    End Property#If DEBUG Then    Public Overrides Sub Dump(ByVal Dumper As IndentedTextWriter)        If m_First IsNot Nothing Then m_First.Dump(Dumper)        Dumper.Write(".")        Compiler.Dumper.Dump(m_Second)        'If m_TypeArguments IsNot Nothing Then m_TypeArguments.Dump(Dumper)    End Sub#End IfEnd Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -