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

📄 memberaccessexpression.vb

📁 大名鼎鼎的mono是.NET平台的跨平台(支持linux
💻 VB
📖 第 1 页 / 共 3 页
字号:
' ' Visual Basic.Net Compiler' Copyright (C) 2004 - 2007 Rolf Bjarne Kvinge, RKvinge@novell.com' ' This library is free software; you can redistribute it and/or' modify it under the terms of the GNU Lesser General Public' License as published by the Free Software Foundation; either' version 2.1 of the License, or (at your option) any later version.' ' This library is distributed in the hope that it will be useful,' but WITHOUT ANY WARRANTY; without even the implied warranty of' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU' Lesser General Public License for more details.' ' You should have received a copy of the GNU Lesser General Public' License along with this library; if not, write to the Free Software' Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA' ''' <summary>''' MemberAccessExpression ::= [ [ MemberAccessBase ] "." ] IdentifierOrKeyword''' MemberAccessBase ::= Expression | BuiltInTypeName | "Global" | "MyClass" | "MyBase"''' ''' TODO: Is this correct? Is the "." optional in a MemberAccessExpression?''' LAMESPEC: IdentifierOrKeyword should be followed by type parameters...''' MemberAccessExpression ::= [ [ MemberAccessBase ] "." ] IdentifierOrKeyword [ TypeParametersList ]''' </summary>''' <remarks></remarks>Public Class MemberAccessExpression    Inherits Expression    Protected m_First As Expression    Protected m_Second As IdentifierOrKeyword    'Private m_TypeArguments As TypeParameters    Private m_WithStatement As WithStatement    Public Overrides ReadOnly Property AsString() As String        Get            If m_First IsNot Nothing Then                Return m_First.AsString & "." & m_Second.Identifier            Else                Return "." & m_Second.Identifier            End If        End Get    End Property    Public Overrides ReadOnly Property IsConstant() As Boolean        Get            Return Classification.IsConstant        End Get    End Property    Public Overrides ReadOnly Property ConstantValue() As Object        Get            Return Classification.ConstantValue        End Get    End Property    Public Overrides Function ResolveTypeReferences() As Boolean        Dim result As Boolean = True        If m_First IsNot Nothing Then result = m_First.ResolveTypeReferences AndAlso result        If m_Second IsNot Nothing Then result = m_Second.ResolveTypeReferences AndAlso result        ' If m_TypeArguments IsNot Nothing Then result = m_TypeArguments.ResolveTypeReferences AndAlso result        Return result    End Function    Sub New(ByVal Parent As ParsedObject)        MyBase.New(Parent)    End Sub    Sub Init(ByVal First As Expression, ByVal Second As IdentifierOrKeyword)        m_First = First        m_Second = Second    End Sub    Public Overrides Function Clone(Optional ByVal NewParent As ParsedObject = Nothing) As Expression        If NewParent Is Nothing Then NewParent = Me.Parent        Dim result As New MemberAccessExpression(NewParent)        Dim m_First As Expression = Nothing        Dim m_Second As IdentifierOrKeyword = Nothing        '  Dim m_TypeArguments As TypeParameters        If Me.m_First IsNot Nothing Then m_First = Me.m_First.Clone(result)        If Me.m_Second IsNot Nothing Then m_Second = Me.m_Second.Clone(result)        '  If Me.m_TypeArguments IsNot Nothing Then m_TypeArguments = Me.m_TypeArguments.Clone(result)        result.Init(m_First, m_Second)        Return result    End Function    Protected Overrides Function GenerateCodeInternal(ByVal Info As EmitInfo) As Boolean        Dim result As Boolean = True        Select Case Classification.Classification            Case ExpressionClassification.Classifications.MethodGroup                If m_First Is Nothing Then                    Helper.NotImplemented()                Else                    With Classification.AsMethodGroupClassification                        If Info.IsRHS Then                            Dim tmp As ValueClassification = .ReclassifyToValue                            result = tmp.GenerateCode(Info) AndAlso result                        Else                            Helper.NotImplemented()                        End If                    End With                End If            Case ExpressionClassification.Classifications.Variable                If m_First Is Nothing Then                    Helper.NotImplemented()                Else                    With Classification.AsVariableClassification                        result = .GenerateCode(Info) AndAlso result                    End With                End If            Case ExpressionClassification.Classifications.Value                With Classification.AsValueClassification                    result = .GenerateCode(Info) AndAlso result                End With            Case ExpressionClassification.Classifications.PropertyGroup                With Classification.AsPropertyGroup                    If Info.IsRHS Then                        Dim tmp As ValueClassification = .ReclassifyToValue                        result = tmp.GenerateCode(Info) AndAlso result                    Else                        Helper.NotImplemented()                    End If                End With            Case ExpressionClassification.Classifications.LateBoundAccess                If Info.IsLHS Then                    If Info.RHSExpression Is Nothing Then                        LateBoundAccessToExpression.EmitLateCall(Info, Me.Classification.AsLateBoundAccess)                    Else                        Helper.NotImplemented()                    End If                Else                    Helper.NotImplemented()                End If            Case Else                Helper.NotImplemented()        End Select        Return result    End Function    Overrides ReadOnly Property ExpressionType() As Type        Get            Return Classification.GetType(True)        End Get    End Property    Protected Overrides Function ResolveExpressionInternal(ByVal Info As ResolveInfo) As Boolean        Dim result As Boolean = True        '---------------------------------------------------------------------------------------------------------        'A member access expression is used to access a member of an entity. A member access of the form E.I,         'where E is an expression, a built-in type, the keyword Global, or omitted and I is an identifier with an         'optional type argument list, is evaluated and classified as follows:        '---------------------------------------------------------------------------------------------------------        '* If E is omitted, then the expression from the immediately containing With statement is substituted for         '  E and the member access is performed. If there is no containing With statement, a compile-time         '  error occurs.        '---------------------------------------------------------------------------------------------------------        '* If E is a type parameter, then a compile-time error results.        '---------------------------------------------------------------------------------------------------------        '* If E is the keyword Global, and I is the name of an accessible type in the global namespace,         '  then the result is that type.        '---------------------------------------------------------------------------------------------------------        '* If E is classified as a namespace and I is the name of an accessible member of that namespace,         '  then the result is that member. The result is classified as a namespace or a type depending on the member.        '---------------------------------------------------------------------------------------------------------        '* If E is a built-in type or an expression classified as a type, and I is the name of an accessible         '  member of E, then E.I is evaluated and classified as follows:        '** If I is the keyword New, then a compile-time error occurs.        '** If I identifies a type, then the result is that type.        '** If I identifies one or more methods, then the result is a method group with the associated         '   type argument list and no associated instance expression.        '** If I identifies one or more properties, then the result is a property group with no associated         '   instance expression.        '** If I identifies a shared variable, and if the variable is read-only, and the reference occurs         '   outside the shared constructor of the type in which the variable is declared, then the result is the         '   value of the shared variable I in E. Otherwise, the result is the shared variable I in E.        '** If I identifies a shared event, the result is an event access with no associated instance expression.        '** If I identifies a constant, then the result is the value of that constant.        '** If I identifies an enumeration member, then the result is the value of that enumeration member.        '** Otherwise, E.I is an invalid member reference, and a compile-time error occurs.        '---------------------------------------------------------------------------------------------------------        '* If E is classified as a variable or value, the type of which is T, and I is the name of an accessible         '  member of E, then E.I is evaluated and classified as follows:        '** If I is the keyword New and E is an instance expression (Me, MyBase, or MyClass), then the result is         '   a method group representing the instance constructors of the type of E with an associated         '   instance expression of E and no type argument list. Otherwise, a compile-time error occurs.        '** 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 I identifies one or more properties, then the result is a property group with an         '   associated instance expression of E.        '** 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.        '** If I identifies an event, the result is an event access with an associated instance expression of E.        '** If I identifies a constant, then the result is the value of that constant.        '** If I identifies an enumeration member, then the result is the value of that enumeration member.        '** 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.        '** Otherwise, E.I is an invalid member reference, and a compile-time error occurs.        '---------------------------------------------------------------------------------------------------------        'If the member access expression includes a type argument list, then only types or methods         'with the same arity as the type argument list are considered.        'When a member access expression begins with the keyword Global, the keyword represents the outermost         'unnamed namespace, which is useful in situations where a declaration shadows an enclosing namespace. The         'Global keyword allows "escaping" out to the outermost namespace in that situation.         '---------------------------------------------------------------------------------------------------------        Dim Name As String = m_Second.Name        Helper.Assert(Name IsNot Nothing AndAlso Name <> "")        If m_First IsNot Nothing Then            result = m_First.ResolveExpression(Info) AndAlso result        Else            '* If E is omitted, then the expression from the immediately containing With statement is substituted for            '  E and the member access is performed. If there is no containing With statement, a compile-time             '  error occurs.            m_WithStatement = Me.FindFirstParentOfCodeBlock(Of WithStatement)()            If m_WithStatement Is Nothing Then                Helper.AddError()                Return False            Else                m_First = m_WithStatement.WithVariableExpression                ' Helper.Assert(m_First.IsResolved)

⌨️ 快捷键说明

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