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

📄 assemblydeclaration.vb

📁 大名鼎鼎的mono是.NET平台的跨平台(支持linux
💻 VB
📖 第 1 页 / 共 3 页
字号:
            'vbnc.Helper.Assert(result = (Report.Errors = 0))        Next        result = m_Attributes.ResolveTypeReferences AndAlso result        vbnc.Helper.Assert(result = (Report.Errors = 0))        Return result    End Function    Private Overloads Function ResolveTypeReferences(ByVal Type As TypeDeclaration) As Boolean        Dim result As Boolean = True        result = Type.ResolveTypeReferences AndAlso result        'vbnc.Helper.Assert(result = (Report.Errors = 0))        If result = False Then Return result        For Each Member As ParsedObject In Type.Members            Dim NestedType As TypeDeclaration = TryCast(Member, TypeDeclaration)            If NestedType IsNot Nothing Then                result = ResolveTypeReferences(NestedType) AndAlso result            Else                result = Member.ResolveTypeReferences() AndAlso result            End If            If result = False Then Return result            'vbnc.Helper.Assert(result = (Report.Errors = 0))        Next        Return result    End Function    Function CreateImplicitMembers() As Boolean        Dim result As Boolean = True        For Each Type As TypeDeclaration In Me.Types#If EXTENDEDDEBUG Then            Dim iCount As Integer            iCount += 1            Compiler.Report.WriteLine(vbnc.Report.ReportLevels.Debug, "CreateImplicitMembers " & Type.FullName & " (" & iCount & " of " & m_TypeDeclarations.Length & " types)")#End If            Dim tmp As IHasImplicitMembers = TryCast(Type, IHasImplicitMembers)            If tmp IsNot Nothing Then result = tmp.CreateImplicitMembers AndAlso result            result = CreateImplicitMembers(Type) AndAlso result        Next        Return result    End Function    Private Function CreateImplicitMembers(ByVal Type As TypeDeclaration) As Boolean        Dim result As Boolean = True        For Each NestedType As TypeDeclaration In Type.Members.GetSpecificMembers(Of TypeDeclaration)()            result = CreateImplicitMembers(NestedType) AndAlso result        Next        For Each Member As IHasImplicitMembers In Type.Members.GetSpecificMembers(Of IHasImplicitMembers)()            result = Member.CreateImplicitMembers() AndAlso result        Next        Return result    End Function    Function ResolveMembers() As Boolean        Dim result As Boolean = True        For Each type As TypeDeclaration In m_TypeDeclarations#If EXTENDEDDEBUG Then            Dim iCount As Integer            iCount += 1            Compiler.Report.WriteLine(vbnc.Report.ReportLevels.Debug, "ResolveMembers " & type.FullName & " (" & iCount & " of " & m_TypeDeclarations.Length & " types)")#End If            result = ResolveMembers(type) AndAlso result        Next        Return result    End Function    Private Shared Function ResolveMembers(ByVal Type As TypeDeclaration) As Boolean        Dim result As Boolean = True        For Each n As IBaseObject In Type.Members.GetSpecificMembers(Of IBaseObject)()            Dim nType As TypeDeclaration = TryCast(n, TypeDeclaration)            Dim nMember As INonTypeMember = TryCast(n, INonTypeMember)            If nType IsNot Nothing Then                result = ResolveMembers(nType) AndAlso result            ElseIf nMember IsNot Nothing Then                'Resolve all non-type members.                result = nMember.ResolveMember(ResolveInfo.Default(Type.Compiler)) AndAlso result            Else                Helper.Stop() '?            End If        Next        Return result    End Function    ''' <summary>    ''' - Types are defined with the reflection.emit namespace.     ''' - Only classes, modules, structures, interfaces, enums, delegates and eventnos (not a type by itself, bu an event might declare a new delegate). They are only defined, nothing else.    ''' - Classes, modules, structures, interfaces, enums,  delegates and events should implement IDefinable.DefineType()    ''' </summary>    ''' <returns></returns>    ''' <remarks></remarks>    Function DefineTypes() As Boolean        Dim result As Boolean = True        For Each type As TypeDeclaration In m_TypeDeclarations#If EXTENDEDDEBUG Then            Dim iCount As Integer            iCount += 1            Compiler.Report.WriteLine(vbnc.Report.ReportLevels.Debug, "DefineTypes " & type.FullName & " (" & iCount & " of " & m_TypeDeclarations.Length & " types)")#End If            result = DefineType(type) AndAlso result        Next        Return result    End Function    ''' <summary>    ''' - Base classes for classes, modules, structures, enums, interfaces and delegates are set.    ''' - Implemented interfaces for classes are set.    ''' - Type parameters for classes and structures are set.    ''' - Classes, modules, structures, interfaces, enums,  delegates and events should implement IDefinable.DefineTypeHierarchy()    ''' </summary>    ''' <returns></returns>    ''' <remarks></remarks>    Function DefineTypeHierarchy() As Boolean        Dim result As Boolean = True        For Each type As TypeDeclaration In m_TypeDeclarations#If EXTENDEDDEBUG Then            Dim iCount As Integer            iCount += 1            Compiler.Report.WriteLine(vbnc.Report.ReportLevels.Debug, "DefineTypeHierarchy " & type.FullName & " (" & iCount & " of " & m_TypeDeclarations.Length & " types)")#End If            result = DefineTypeHierarchy(type) AndAlso result        Next        Return result    End Function    Function DefineTypeParameters() As Boolean        Dim result As Boolean = True        For Each type As TypeDeclaration In m_TypeDeclarations#If EXTENDEDDEBUG Then            Dim iCount As Integer            iCount += 1            Compiler.Report.WriteLine(vbnc.Report.ReportLevels.Debug, "DefineTypeParameters " & type.FullName & " (" & iCount & " of " & m_TypeDeclarations.Length & " types)")#End If            result = DefineTypeParameters(type) AndAlso result        Next        Return result    End Function    ''' <summary>    ''' - All the type's members are defined (methods, constructors, properties, fields, events, operators).    ''' </summary>    ''' <returns></returns>    ''' <remarks></remarks>    Function DefineMembers() As Boolean        Dim result As Boolean = True        For Each type As TypeDeclaration In m_TypeDeclarations#If EXTENDEDDEBUG Then            Dim iCount As Integer            iCount += 1            Try                System.Console.ForegroundColor = ConsoleColor.Green            Catch ex As Exception            End Try            Compiler.Report.WriteLine(vbnc.Report.ReportLevels.Debug, "DefineMembers " & type.FullName & " (" & iCount & " of " & m_TypeDeclarations.Length & " types)")            Try                System.Console.ResetColor()            Catch ex As Exception            End Try#End If            result = DefineMembers(type) AndAlso result        Next        Return result    End Function    Function EmitAttributes() As Boolean        Dim result As Boolean = True        If m_Attributes IsNot Nothing Then            result = m_Attributes.GenerateCode(Nothing) AndAlso result        End If        Return result    End Function    ''' <summary>    ''' - All code is emitted for fields with initializers.    ''' - All the code is emitted for each and every method, constructor, operator and property.    ''' - Classes, modules, structures, methods, constructors, properties, events, operators should implement IEmittable.Emit(Info as EmitInfo)    ''' </summary>    ''' <returns></returns>    ''' <remarks></remarks>    Function Emit() As Boolean        Dim result As Boolean = True        result = EmitAttributes() AndAlso result        For Each type As TypeDeclaration In m_TypeDeclarations#If EXTENDEDDEBUG Then            Dim iCount As Integer            iCount += 1            Try                System.Console.ForegroundColor = ConsoleColor.Yellow            Catch ex As Exception            End Try            Compiler.Report.WriteLine(vbnc.Report.ReportLevels.Debug, "Emit " & type.FullName & " (" & iCount & " of " & m_TypeDeclarations.Length & " types)")            Try                System.Console.ResetColor()            Catch ex As Exception            End Try#End If            result = Emit(type) AndAlso result        Next        SetFileVersion()        SetAdditionalAttributes()        Return result    End Function    Sub SetAdditionalAttributes()        Dim cab As CustomAttributeBuilder        If Compiler.CommandLine.Define.IsDefined("DEBUG") Then            cab = New CustomAttributeBuilder(Compiler.TypeCache.System_Diagnostics_DebuggableAttribute__ctor_DebuggingModes, New Object() {System.Diagnostics.DebuggableAttribute.DebuggingModes.DisableOptimizations Or Diagnostics.DebuggableAttribute.DebuggingModes.Default})            Me.Compiler.AssemblyBuilder.SetCustomAttribute(cab)        End If    End Sub    Sub SetFileVersion()        Dim product, productversion, company, copyright, trademark As String        Dim att() As Object        Dim product_att As Reflection.AssemblyProductAttribute = Nothing        Dim productversion_att As Reflection.AssemblyVersionAttribute = Nothing        Dim company_att As Reflection.AssemblyCompanyAttribute = Nothing        Dim copyright_att As Reflection.AssemblyCopyrightAttribute = Nothing        Dim trademark_att As Reflection.AssemblyTrademarkAttribute = Nothing        att = Me.Compiler.AssemblyBuilder.GetCustomAttributes(Compiler.TypeCache.System_Reflection_AssemblyProductAttribute, True)        If att.Length > 0 Then product_att = DirectCast(att(0), AssemblyProductAttribute)        att = Me.Compiler.AssemblyBuilder.GetCustomAttributes(Compiler.TypeCache.System_Reflection_AssemblyVersionAttribute, True)        If att.Length > 0 Then productversion_att = DirectCast(att(0), AssemblyVersionAttribute)        att = Me.Compiler.AssemblyBuilder.GetCustomAttributes(Compiler.TypeCache.System_Reflection_AssemblyCompanyAttribute, True)        If att.Length > 0 Then company_att = DirectCast(att(0), AssemblyCompanyAttribute)        att = Me.Compiler.AssemblyBuilder.GetCustomAttributes(Compiler.TypeCache.System_Reflection_AssemblyCopyrightAttribute, True)        If att.Length > 0 Then copyright_att = DirectCast(att(0), AssemblyCopyrightAttribute)        att = Me.Compiler.AssemblyBuilder.GetCustomAttributes(Compiler.TypeCache.System_Reflection_AssemblyTrademarkAttribute, True)        If att.Length > 0 Then trademark_att = DirectCast(att(0), AssemblyTrademarkAttribute)        If product_att IsNot Nothing Then product = product_att.Product Else product = ""        If productversion_att IsNot Nothing Then productversion = productversion_att.Version Else productversion = ""        If company_att IsNot Nothing Then company = company_att.Company Else company = ""        If copyright_att IsNot Nothing Then copyright = copyright_att.Copyright Else copyright = ""        If trademark_att IsNot Nothing Then trademark = trademark_att.Trademark Else trademark = ""        Me.Compiler.AssemblyBuilder.DefineVersionInfoResource(product, productversion, company, copyright, trademark)    End Sub    Public Function GetName() As AssemblyName        Dim result As New AssemblyName()        Dim keyfile As String = Nothing        Dim keyname As String = Nothing        Dim delaysign As Boolean = False        result.Name = IO.Path.GetFileNameWithoutExtension(Compiler.OutFileName)#If DEBUGREFLECTION Then        Helper.DebugReflection_AppendLine(Helper.GetObjectName(result) & " = New System.Reflection.AssemblyName")        Helper.DebugReflection_AppendLine(Helper.GetObjectName(result) & ".Name = """ & result.Name & """")#End If        If Compiler.CommandLine.KeyFile <> String.Empty Then

⌨️ 快捷键说明

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