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

📄 typedeclaration.vb

📁 大名鼎鼎的mono是.NET平台的跨平台(支持linux
💻 VB
📖 第 1 页 / 共 2 页
字号:
' ' 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' #If DEBUG Then#Const EXTENDEDDEBUG = 0#End If''' <summary>''' TypeDeclaration Hierarchy:''' ''' TypeDeclaration'''   + DelegateDeclaration'''   + EnumDeclaration'''   + ModuleDeclaration'''   - GenericTypeDeclaration'''       + InterfaceDeclaration'''       - PartialTypeDeclaration'''           + ClassDeclaration'''           + StructureDeclaration'''         ''' </summary>''' <remarks></remarks>Public MustInherit Class TypeDeclaration    Inherits MemberDeclaration    Implements IType    Private m_TypeDescriptor As TypeDescriptor    'Information collected during parse phase.    Private m_Members As MemberDeclarations    Private m_Namespace As String    Private m_Name As Token    'Information collected during resolve phase.    Private m_BaseType As Type    Private m_ImplementedTypes As Type()    Private m_DefaultInstanceConstructor As ConstructorDeclaration    Private m_DefaultSharedConstructor As ConstructorDeclaration    Private m_StaticVariables As Generic.List(Of VariableDeclaration)    Private m_BeforeFieldInit As Boolean    'Information collected during define phase.#If ENABLECECIL Then    Private m_CecilType As Mono.Cecil.TypeDefinition    Private m_CecilBaseType As Mono.Cecil.TypeReference#End If    Private m_TypeBuilder As TypeBuilder    'Another hack for another bug in the ms runtime: you cannot create an attribute when the attribute's constructor has a enum parameter and the enum parameter is defined with a typebuilder, it only works if the enum parameter's type is defined with an enumbuilder.    Private m_EnumBuilder As EnumBuilder    Private m_FinalType As Type    Private m_FullName As String    Private m_AddHandlers As New Generic.List(Of AddOrRemoveHandlerStatement)    ReadOnly Property DescriptiveType() As String        Get            If TypeOf Me Is ClassDeclaration Then                Return "class"            ElseIf TypeOf Me Is ModuleDeclaration Then                Return "module"            ElseIf TypeOf Me Is EnumDeclaration Then                Return "enum"            ElseIf TypeOf Me Is StructureDeclaration Then                Return "structure"            ElseIf TypeOf Me Is DelegateDeclaration Then                Return "delegate"            ElseIf TypeOf Me Is InterfaceDeclaration Then                Return "interface"            Else                Return "type"            End If        End Get    End Property    ReadOnly Property AddHandlers() As Generic.List(Of AddOrRemoveHandlerStatement)        Get            Return m_AddHandlers        End Get    End Property    Sub New(ByVal Parent As ParsedObject, ByVal [Namespace] As String)        MyBase.New(Parent)        m_TypeDescriptor = New TypeDescriptor(Me)        m_Namespace = [Namespace]        Helper.Assert(m_Namespace IsNot Nothing)    End Sub    Shadows Sub Init(ByVal CustomAttributes As Attributes, ByVal Modifiers As Modifiers, ByVal Members As MemberDeclarations, ByVal Name As Token, ByVal TypeArgumentCount As Integer)        MyBase.Init(CustomAttributes, Modifiers, Helper.CreateGenericTypename(Name.Name, TypeArgumentCount))        m_Members = Members        m_Name = Name        Helper.Assert(DeclaringType IsNot Nothing OrElse TypeOf Me.Parent Is AssemblyDeclaration)        Helper.Assert(m_Members IsNot Nothing)        Helper.Assert(m_Namespace IsNot Nothing)        'Helper.Assert(m_Name IsNot Nothing)    End Sub    Protected Property BeforeFieldInit() As Boolean        Get            Return m_BeforeFieldInit        End Get        Set(ByVal value As Boolean)            m_BeforeFieldInit = value        End Set    End Property    Protected Friend Property DefaultInstanceConstructor() As ConstructorDeclaration        Get            Return m_DefaultInstanceConstructor        End Get        Set(ByVal value As ConstructorDeclaration)            m_DefaultInstanceConstructor = value        End Set    End Property    Protected Property DefaultSharedConstructor() As ConstructorDeclaration        Get            Return m_DefaultSharedConstructor        End Get        Set(ByVal value As ConstructorDeclaration)            m_DefaultSharedConstructor = value        End Set    End Property    Protected Sub FindDefaultConstructors()        For i As Integer = 0 To Me.Members.Count - 1            Dim member As IMember = Me.Members(i)            Dim ctor As ConstructorDeclaration = TryCast(member, ConstructorDeclaration)            If ctor Is Nothing Then Continue For            Dim isdefault As Boolean            isdefault = False            If ctor.GetParameters.Length = 0 Then                isdefault = True            Else                isdefault = ctor.GetParameters()(0).IsOptional            End If            If isdefault Then                If ctor.IsShared Then                    Helper.Assert(m_DefaultSharedConstructor Is Nothing OrElse m_DefaultSharedConstructor Is ctor)                    m_DefaultSharedConstructor = ctor                Else                    Helper.Assert(m_DefaultInstanceConstructor Is Nothing OrElse m_DefaultInstanceConstructor Is ctor)                    m_DefaultInstanceConstructor = ctor                End If            End If        Next    End Sub    ReadOnly Property [Namespace]() As String Implements IType.Namespace        Get            Helper.Assert(m_Namespace IsNot Nothing)            Return m_Namespace        End Get    End Property    Property ImplementedTypes() As Type()        Get            Return m_ImplementedTypes        End Get        Protected Set(ByVal value As Type())            m_ImplementedTypes = value        End Set    End Property    ReadOnly Property Identifier() As Token        Get            Return m_Name        End Get    End Property    Public ReadOnly Property Created() As Boolean Implements ICreatableType.Created        Get            Helper.Assert(m_TypeBuilder IsNot Nothing)            Return m_TypeBuilder.IsCreated        End Get    End Property    Public Overrides ReadOnly Property IsShared() As Boolean        Get            Return TypeOf Me Is ModuleDeclaration        End Get    End Property    Public Overrides ReadOnly Property MemberDescriptor() As System.Reflection.MemberInfo        Get            Return m_TypeDescriptor        End Get    End Property    Public Overrides ReadOnly Property FullName() As String        Get            If m_FullName Is Nothing Then                If Me.IsNestedType Then                    m_FullName = DeclaringType.FullName & "+" & Me.Name                Else                    If m_Namespace <> "" Then                        m_FullName = m_Namespace & "." & Me.Name                    Else                        m_FullName = Me.Name                    End If                End If            End If            Return m_FullName        End Get    End Property    Overridable Function DefineTypeParameters() As Boolean        Return True    End Function    ''' <summary>    '''     ''' </summary>    ''' <value></value>    ''' <returns></returns>    ''' <remarks></remarks>    Public Property BaseType() As System.Type        Get            Return m_BaseType        End Get        Protected Set(ByVal value As System.Type)            m_BaseType = value            Helper.Assert(m_BaseType IsNot Nothing)        End Set    End Property#If ENABLECECIL Then    ''' <summary>    '''     ''' </summary>    ''' <value></value>    ''' <returns></returns>    ''' <remarks></remarks>    Public Property CecilBaseType() As Mono.Cecil.TypeReference        Get            Return m_CecilBaseType        End Get        Protected Set(ByVal value As Mono.Cecil.TypeReference)            m_CecilBaseType = value            Helper.Assert(m_CecilBaseType IsNot Nothing)        End Set    End Property#End If    Private ReadOnly Property BaseType2() As System.Type Implements IType.BaseType        Get            Return BaseType        End Get    End Property    Public Property Members() As MemberDeclarations        Get            Return m_Members        End Get        Protected Set(ByVal value As MemberDeclarations)            Helper.Assert(TypeOf Me Is PartialTypeDeclaration AndAlso DirectCast(Me, PartialTypeDeclaration).IsPartial)            m_Members = value        End Set    End Property    Private ReadOnly Property Members2() As MemberDeclarations Implements IType.Members        Get            Return m_Members        End Get    End Property    Property EnumBuilder() As EnumBuilder        Get            Return m_EnumBuilder        End Get        Protected Set(ByVal value As EnumBuilder)            m_EnumBuilder = value        End Set    End Property#If ENABLECECIL Then    Public ReadOnly Property CecilType() As Mono.Cecil.TypeDefinition        Get            Return m_ceciltype        End Get    End Property#End If    Public Overridable Property TypeBuilder() As System.Reflection.Emit.TypeBuilder        Get            Return m_TypeBuilder        End Get        Protected Set(ByVal value As System.Reflection.Emit.TypeBuilder)            Compiler.TypeManager.RegisterReflectionType(value, Me.TypeDescriptor)

⌨️ 快捷键说明

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