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

📄 genericconstraint2.vb

📁 大名鼎鼎的mono是.NET平台的跨平台(支持linux
💻 VB
📖 第 1 页 / 共 3 页
字号:
Imports SystemImports System.CollectionsImports System.ReflectionNamespace GenericConstraint2    Public Interface IBaseObject        ReadOnly Property Assembly() As AssemblyDeclaration        Property Location() As Span        Property Parent() As IBaseObject        ReadOnly Property Compiler() As Compiler        ReadOnly Property FullName() As String        Function ResolveCode(ByVal Info As ResolveInfo) As Boolean        Function Define() As Boolean        Function GenerateCode(ByVal Info As EmitInfo) As Boolean        Function FindFirstParent(Of T As Class)() As T#If DEBUG Then    Sub Dump(ByVal Dumper As IndentedTextWriter)    ReadOnly Property ObjectID() As Integer#End If    End Interface    Public Class TypeDeclaration    End Class    Public Class AssemblyDeclaration    End Class    Public Class Span    End Class    Public Class ResolveInfo    End Class    Public Class EmitInfo    End Class    Public Class IndentedTextWriter    End Class    Public Class ParsedObject        Inherits BaseObject    End Class    Public Class tm    End Class    Public Class Report    End Class    Public MustInherit Class BaseObject        Implements IBaseObject        ''' <summary>        ''' The parent of this object        ''' </summary>        ''' <remarks></remarks>        Private m_Parent As IBaseObject        ''' <summary>        ''' The location in the source of this object.        ''' </summary>        ''' <remarks></remarks>        Private m_Location As Span        ''' <summary>        ''' The location in the source of this object.        ''' </summary>        ''' <value></value>        ''' <remarks></remarks>        Friend Property Location() As Span Implements IBaseObject.Location            Get                Return m_Location            End Get            Set(ByVal value As Span)                m_Location = value            End Set        End Property        Sub New()        End Sub        Overridable ReadOnly Property FullName() As String Implements IBaseObject.FullName            Get                'Dim nameable As INameable = TryCast(Me, INameable)                'Helper.Assert(nameable IsNot Nothing)                'Dim nstpparent As IBaseObject = Me.FindFirstParent(Of IType)()                'If TypeOf Me Is TypeParameter Then Return Nothing                'If nstpparent IsNot Nothing Then                '    If TypeOf nstpparent Is IType Then                '        Return nstpparent.FullName & "+" & nameable.Name                '    Else                '        Return nstpparent.FullName & "." & nameable.Name                '    End If                'Else                '    Return nameable.Name                'End If            End Get        End Property        Friend Function FindTypeParent() As TypeDeclaration            'Return Me.FindFirstParent(Of TypeDeclaration)()        End Function        Friend Function FindMethod() As IBaseObject            'Dim found As IBaseObject            'found = FindFirstParent(Of IMethod)()            'If found Is Nothing Then found = FindFirstParent(Of IPropertyMember)()            'Return found        End Function        Function FindFirstParent(Of T As Class)() As T Implements IBaseObject.FindFirstParent            'Dim found As T = TryCast(Parent, T)            'If found IsNot Nothing Then            '    Return found            'ElseIf Parent Is Nothing Then            '    Return Nothing            'Else            '    Return Parent.FindFirstParent(Of T)()            'End If        End Function        Function FindFirstParent(Of T1 As {BaseObject}, T2 As {BaseObject})() As IBaseObject 'Implements IBaseObject.FindFirstParent            'Dim found As IBaseObject = TryCast(Parent, T1)            'If found Is Nothing Then found = TryCast(Parent, T2)            'If found IsNot Nothing Then            '    Return found            'ElseIf Parent Is Nothing Then            '    Return Nothing            'Else            '    Return Parent.FindFirstParent(Of T1, T2)()            'End If        End Function        ''' <summary>        ''' Create a new base object with the specified Parent.        ''' </summary>        Protected Sub New(ByVal Parent As IBaseObject)            '            m_Parent = Parent            '            If m_Parent IsNot Nothing AndAlso tm IsNot Nothing AndAlso tm.IsCurrentTokenValid Then m_Location = tm.CurrentToken.Location            '#If DEBUG Then            '        Helper.Assert(Parent IsNot Me)            '        Helper.Assert(Parent IsNot Nothing OrElse TypeOf Me Is Compiler OrElse TypeOf Me Is Modifiers)            '        'Make sure there aren't any circular references.            '        Dim tmp As IBaseObject = Parent            '        Do While tmp IsNot Nothing            '            tmp = tmp.Parent            '            Helper.Assert(tmp IsNot Me)            '        Loop            '#End If        End Sub        ''' <summary>        ''' Create a new base object with the specified Parent.        ''' </summary>        Protected Sub New(ByVal Parent As IBaseObject, ByVal Location As Span)            '            m_Parent = Parent            '            m_Location = Location            '#If DEBUG Then            '        Helper.Assert(Parent IsNot Me)            '        Helper.Assert(Parent IsNot Nothing OrElse TypeOf Me Is Compiler OrElse TypeOf Me Is Modifiers)            '        'Make sure there aren't any circular references.            '        Dim tmp As IBaseObject = Parent            '        Do While tmp IsNot Nothing            '            tmp = tmp.Parent            '            Helper.Assert(tmp IsNot Me)            '        Loop            '#End If        End Sub        Property Parent() As BaseObject            Get                '     Return DirectCast(Me.pParent, BaseObject)            End Get            Set(ByVal value As BaseObject)                '   m_Parent = value            End Set        End Property        ''' <summary>        ''' The parent of this type. Is nothing if this type is an assembly.        ''' </summary>        ''' <value></value>        ''' <remarks></remarks>        Private Property pParent() As IBaseObject Implements IBaseObject.Parent            Get                'Dim tmpPTD As PartialTypeDeclaration = TryCast(m_Parent, PartialTypeDeclaration)                'If tmpPTD IsNot Nothing AndAlso tmpPTD.IsPartial AndAlso tmpPTD.IsMainPartialDeclaration = False Then                '    Helper.Assert(tmpPTD.MainPartialDeclaration IsNot Nothing)                '    m_Parent = tmpPTD.MainPartialDeclaration                '    'Compiler.Report.WriteLine(vbnc.Report.ReportLevels.Debug, "Parent of " & Me.GetType.ToString & " set to " & CObj(m_Parent).GetType.ToString)                'End If                'Return m_Parent            End Get            Set(ByVal value As IBaseObject)                'm_Parent = value            End Set        End Property        ReadOnly Property ParentAsParsedObject() As ParsedObject            Get                'Return DirectCast(Me.Parent, ParsedObject)            End Get        End Property        ''' <summary>        ''' Get the current compiling assembly.        ''' </summary>        Friend Overridable ReadOnly Property Assembly() As AssemblyDeclaration Implements IBaseObject.Assembly            Get                'If TypeOf Me Is AssemblyDeclaration Then                '    Return DirectCast(Me, AssemblyDeclaration)                'ElseIf TypeOf Me Is Compiler Then                '    Return DirectCast(Me, Compiler).theAss                'Else                '    Helper.Assert(m_Parent IsNot Nothing)                '    Return m_Parent.Assembly                'End If            End Get        End Property        Friend ReadOnly Property Report() As Report            Get                '         Return Compiler.Report            End Get        End Property        ''' <summary>        ''' Get the compiler compiling right now.        ''' </summary>        Overridable ReadOnly Property Compiler() As Compiler Implements IBaseObject.Compiler            Get                'If TypeOf m_Parent Is Compiler Then                '    Return DirectCast(m_Parent, Compiler)                'ElseIf TypeOf Me Is Compiler Then                '    Return DirectCast(Me, vbnc.Compiler)                'Else                '    Helper.Assert(m_Parent IsNot Nothing)                '    Return m_Parent.Compiler                'End If            End Get        End Property        ''' <summary>        ''' Get the token manager used for quick token management.        ''' </summary>        Friend Overridable ReadOnly Property tm() As tm            Get                'Helper.Assert(Compiler IsNot Nothing)                'Return Compiler.tm            End Get        End Property        Overridable Function ResolveCode(ByVal Info As ResolveInfo) As Boolean Implements IBaseObject.ResolveCode            'Compiler.Report.WriteLine(vbnc.Report.ReportLevels.Debug, "ResolveInfo ignored for '" & Me.GetType.ToString & "'")            'Helper.NotImplemented()            ''Return ResolveCode()        End Function        Friend Overridable Function GenerateCode(ByVal Info As EmitInfo) As Boolean Implements IBaseObject.GenerateCode            'Compiler.Report.WriteLine(vbnc.Report.ReportLevels.Debug, "The class " & Me.GetType.ToString & " does not implement GenerateCode()")            'Helper.NotImplemented()        End Function        ''' <summary>        ''' Define = create a builder for the object.        ''' </summary>        ''' <returns></returns>        ''' <remarks></remarks>        <Obsolete("Throws NotImplementedException() - The class you are using does not override this method!")> _        Overridable Function Define() As Boolean Implements IBaseObject.Define            'Compiler.Report.WriteLine(vbnc.Report.ReportLevels.Debug, "The class " & Me.GetType.ToString & " does not implement Define()")            'Helper.NotImplemented()        End Function#If DEBUG Then    Overridable Sub Dump(ByVal Dumper As IndentedTextWriter) Implements IBaseObject.Dump        'Dumper.WriteLine("Dump of " & Me.GetType.ToString & "!")    End Sub    Private m_ObjectID As Integer = NewID()    Public Shared ObjectIDStop As Integer    Public Shared NextID As Integer    ReadOnly Property ObjectID() As Integer Implements IBaseObject.ObjectID        Get           ' Return m_ObjectID        End Get    End Property    Shared Function NewID() As Integer        'NextID += 1        'If ObjectIDStop = NextID Then        '    Helper.StopIfDebugging()        'End If        'Return NextID    End Function#End If    End Class    Public Interface ILiteralToken        ReadOnly Property LiteralValue() As Object        ReadOnly Property LiteralType() As TypeCode        Function Equals(ByVal Token As ILiteralToken) As Boolean    End Interface    Public MustInherit Class Token        Inherits BaseObject        Sub New(ByVal Span As Span, ByVal Compiler As Compiler)            MyBase.New(Compiler, Span)        End Sub        Function IdentiferOrKeywordIdentifier() As String            'If IsKeyword() Then            '    Return AsKeyword.Identifier            'ElseIf IsIdentifier() Then            '    Return AsIdentifier.Identifier            'Else            '    Throw New InternalException            'End If        End Function        Function IsSpecial() As Boolean            ' Return IsKeyword() OrElse IsSymbol()        End Function

⌨️ 快捷键说明

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