dumper.vb
来自「大名鼎鼎的mono是.NET平台的跨平台(支持linux」· VB 代码 · 共 1,255 行 · 第 1/3 页
VB
1,255 行
' ' 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' Public Class Dumper Private m_Dumper As IndentedTextWriter Property Dumper() As IndentedTextWriter Get Return m_Dumper End Get Set(ByVal value As IndentedTextWriter) m_Dumper = value End Set End Property#If EXTENDEDDEBUG Then Public Sub Dump(ByVal Element As ConstructorDeclaration) If Element.CustomAttributes IsNot Nothing Then Dump(Element.CustomAttributes) Dump(Element.Modifiers) Dumper.Write("Sub New") Dump(Element.Signature) Dumper.WriteLine("") Dumper.Indent() Dump(Element.Code) Dumper.Unindent() Dumper.WriteLine("End Sub") End Sub Public Sub Dump(ByVal Element As CustomEventHandlerDeclaration) If Element.CustomAttributes IsNot Nothing Then Dump(Element.CustomAttributes) Dumper.Write(Element.HandlerType.ToString) Dumper.Write("(") If Element.Signature.Parameters IsNot Nothing Then Dump(Element.Signature.Parameters) Dumper.WriteLine(")") If Element.Code IsNot Nothing Then Dump(Element.Code) Dumper.WriteLine("End " & Element.HandlerType.ToString) End Sub Public Sub Dump(ByVal Element As ExternalSubDeclaration) If Element.CustomAttributes IsNot Nothing Then Dump(Element.CustomAttributes) Dump(Element.Modifiers) Dumper.Write("Declare ") If Element.CharsetModifier <> KS.None Then Dumper.Write(Element.CharsetModifier.ToString & " ") Dumper.Write("Sub ") Element.Identifier.Dump(Dumper) If Element.LibraryClause IsNot Nothing Then Dump(Element.LibraryClause) If Element.AliasClause IsNot Nothing Then Dump(Element.AliasClause) If Element.Signature.Parameters IsNot Nothing Then Dumper.Write("(") Dump(Element.Signature.Parameters) Dumper.Write(")") End If Dumper.WriteLine("") End Sub Public Sub Dump(ByVal Element As ExternalFunctionDeclaration) If Element.CustomAttributes IsNot Nothing Then Dump(Element.CustomAttributes) Dump(Element.Modifiers) Dumper.Write("Declare ") If Element.CharsetModifier <> KS.None Then Dumper.Write(Element.CharsetModifier.ToString & " ") Dumper.Write("Function ") Element.Identifier.Dump(Dumper) If Element.LibraryClause IsNot Nothing Then Dump(Element.LibraryClause) If Element.AliasClause IsNot Nothing Then Dump(Element.AliasClause) If Element.Signature.Parameters IsNot Nothing Then Dumper.Write("(") Dump(Element.Signature.Parameters) Dumper.Write(")") End If If Element.Signature.TypeName IsNot Nothing Then Dumper.Write("As ") If Element.Signature.ReturnTypeAttributes IsNot Nothing Then Dump(Element.Signature.ReturnTypeAttributes) Dump(Element.Signature.TypeName) End If Dumper.WriteLine("") End Sub Public Sub Dump(ByVal Element As CaseClause) If Element.Comparison <> KS.None Then Dumper.Write("Is " & Enums.GetKSStringAttribute(Element.Comparison).Value & " ") Element.Expression1.Dump(Dumper) Else Element.Expression1.Dump(Dumper) If Element.Expression2 IsNot Nothing Then Dumper.Write(" To ") Element.Expression2.Dump(Dumper) End If End If End Sub Public Sub Dump(ByVal Element As Constraint) If Element.TypeName IsNot Nothing Then Dump(Element.TypeName) Else Dumper.Write("New") End If End Sub Public Sub Dump(ByVal Element As VariableInitializer) Dump(Element.Initializer) End Sub Public Sub Dump(ByVal Element As UsingStatement) Dumper.Write("Using ") Dump(Element.UsingResources) Dumper.WriteLine("") Dump(Element.CodeBlock) Dumper.WriteLine("End Using") End Sub Sub Dump(ByVal Element As identifier) Dumper.Write("[" & Element.Name & "] ") End Sub Public Sub Dump(ByVal Element As TypeImplementsClauses) For Each clause As NonArrayTypeName In Element.Clauses Dumper.Write("Implements ") Dump(clause) Dumper.WriteLine("") Next End Sub Sub Dump(ByVal Element As ParameterList) Dim sep As String = "" For Each pa As Parameter In Element.List Dumper.Write(sep) Dump(pa) sep = ", " Next End Sub Sub Dump(ByVal Element As ConstraintList) Dim sep As String = "" For Each pa As Constraint In Element.List Dumper.Write(sep) Dump(pa) sep = ", " Next End Sub Sub Dump(ByVal Element As MemberImplementsList) Dim sep As String = "" For Each pa As InterfaceMemberSpecifier In Element.List Dumper.Write(sep) Dump(pa) sep = ", " Next End Sub Public Sub Dump(ByVal Element As SyncLockStatement) Dumper.Write("SyncLock ") Element.Lock.Dump(Dumper) Dumper.WriteLine("") Dump(Element.CodeBlock) Dumper.WriteLine("End SyncLock") End Sub Public Sub Dump(ByVal Element As ReDimStatement) Dumper.Write("Redim ") If Element.IsPreserve Then Dumper.Write("Preserve ") Dump(Element.Clauses) Dumper.WriteLine("") End Sub Sub Dump(ByVal Elements As BaseObjects(Of CatchStatement)) For Each e As CatchStatement In Elements Dump(e) Next End Sub Public Sub Dump(ByVal Element As ImportsStatement) Dumper.Write("Imports ") Dump(Element.Clauses) Dumper.WriteLine("") End Sub Public Sub Dump(ByVal Element As HandlesOrImplements) Dump(Element.Clause) End Sub Sub Dump(ByVal Element As BaseObject) If Element Is Nothing Then Return If TypeOf Element Is Expression Then Dump(DirectCast(Element, Expression)) : Return If TypeOf Element Is Token Then Dump(DirectCast(Element, Token)) : Return Dim m As MethodInfo m = GetType(Dumper).GetMethod("Dump", BindingFlags.Instance Or BindingFlags.DeclaredOnly Or BindingFlags.Public Or BindingFlags.NonPublic Or BindingFlags.ExactBinding, Nothing, CallingConventions.Any, New Type() {Element.GetType}, Nothing) If m IsNot Nothing Then m.Invoke(Me, New Object() {Element}) Return End If Diagnostics.Debug.WriteLine("Dump(" & Element.GetType.Name & ") not implemented yet.") Console.WriteLine("Dump(" & Element.GetType.Name & ") not implemented yet.") End Sub Public Sub Dump(ByVal Element As EraseStatement) Dumper.Write("Erase ") Dump(Element.Targets) Dumper.WriteLine("") End Sub Sub Dump(ByVal Element As ExpressionList) Dim sep As String = "" For Each e As Expression In Element Dumper.Write(sep) Dump(e) sep = ", " Next End Sub Sub Dump(ByVal Element As TypeParameterList) Dim sep As String = "" For Each e As TypeParameter In Element.List Dumper.Write(sep) Dump(e) sep = ", " Next End Sub Sub Dump(ByVal Element As VariableInitializerList) Dim sep As String = "" For Each e As VariableInitializer In Element.List Dumper.Write(sep) Dump(e) sep = ", " Next End Sub Sub Dump(ByVal Element As GetTypeTypeName) Dump(Element.Name) End Sub Public Sub Dump(ByVal Element As AttributeList) Dim sep As String = "" For Each a As Attribute In Element.List Dumper.Write(sep) Dump(a) sep = ", " Next End Sub Public Sub Dump(ByVal Element As BaseObjects(Of CaseStatement)) Dim sep As String = "" For Each a As CaseStatement In Element Dumper.Write(sep) Dump(a) sep = ", " Next End Sub Public Sub Dump(ByVal Element As ForEachStatement) Dumper.Write("For Each ") Dump(Element.LoopControlVariable) Dumper.Write(" In ") Element.InExpression.Dump(Dumper) Dumper.WriteLine("") Dump(Element.CodeBlock) Dumper.Write("Next ") If Element.NextExpression IsNot Nothing Then Element.NextExpression.Dump(Dumper) End If Dumper.WriteLine("") End Sub Public Sub Dump(ByVal Element As EventAccessorDeclarations) For Each e As CustomEventHandlerDeclaration In Element.Handlers Dump(e) Next End Sub Public Sub Dump(ByVal Element As EventMemberSpecifier) Dump(Element.First) Dumper.Write(".") Dump(Element.Second) End Sub Public Sub Dump(ByVal Element As ForStatement) Dumper.Write("For ") Dump(Element.LoopControlVariable) Dumper.Write(" = ") Element.LoopStartExpression.Dump(Dumper) Dumper.Write(" To ") Element.LoopEndExpression.Dump(Dumper) If Element.LoopStepExpression IsNot Nothing Then Dumper.Write(" Step ") Element.LoopStepExpression.Dump(Dumper) End If Dumper.WriteLine("") Dump(Element.CodeBlock) Dumper.Write("Next") If Element.NextExpressionList IsNot Nothing Then Dumper.Write(" ") Dump(Element.NextExpressionList) End If Dumper.WriteLine("") End Sub Sub Dump(ByVal Element As EventHandlesList) For Each e As EventMemberSpecifier In Element Dump(e) Next End Sub Public Sub Dump(ByVal Element As HandlesClause) Dumper.Write("Handles ") Dump(Element.List) End Sub Public Sub Dump(ByVal Element As ElseIfStatement) Dumper.Write("ElseIf ") Element.Condition.Dump(Dumper) Dumper.WriteLine(" Then") Dump(Element.CodeBlock) End Sub Public Sub Dump(ByVal Element As SelectStatement) Dumper.Write("Select Case ") Element.Test.Dump(Dumper) Dumper.WriteLine("") Dumper.Indent() Dump(Element.Cases) Dumper.Unindent() Dumper.WriteLine("End Select") End Sub Public Sub Dump(ByVal Element As IfStatement) Dumper.Write("If ") Element.Condition.Dump(Dumper) Dumper.WriteLine(" Then") Dump(Element.CodeBlock) If Element.ElseIfs IsNot Nothing Then For Each elseexp As ElseIfStatement In Element.ElseIfs Dump(elseexp) Next End If If Element.FalseCode IsNot Nothing Then Dumper.WriteLine("Else ") Dump(Element.FalseCode) End If Dumper.WriteLine("End If") End Sub Public Sub Dump(ByVal Element As LoopControlVariable) If Element.Expression IsNot Nothing Then Element.Expression.Dump(Dumper) Else Element.Identifier.Dump(Dumper) If Element.ArrayNameModifier IsNot Nothing Then Dump(Element.ArrayNameModifier) End If Dumper.Write(" As ") Dump(Element.TypeName) End If End Sub Public Sub Dump(ByVal Element As QualifiedIdentifier) If Element.IsFirstQualifiedIdentifier Then Dump(Element.FirstAsQualifiedIdentifier) ElseIf Element.IsFirstIdentifier Then Dump(Element.FirstAsIdentifier) ElseIf Element.IsFirstGlobal Then Dumper.Write("Global") Else Throw New InternalException(Me) End If If Element.Second IsNot Nothing Then Dumper.Write(".") Element.Second.Dump(Dumper) End If End Sub Public Sub Dump(ByVal Element As TryStatement) Dumper.WriteLine("Try") Dump(Element.CodeBlock) Dump(Element.Catches) If Element.FinallyBlock IsNot Nothing Then Dumper.WriteLine("Finally") Dump(Element.FinallyBlock) End If Dumper.WriteLine("End Try") End Sub Public Sub Dump(ByVal Element As ConstructedTypeName) Dump(Element.QualifiedIdentifier) Dumper.Write("(Of ") Dump(Element.TypeArgumentList) Dumper.Write(")") End Sub Public Sub Dump(ByVal Element As WithStatement) Dumper.Write("With ") Element.WithExpression.Dump(Dumper) Dumper.WriteLine("") Dump(Element.CodeBlock) Dumper.WriteLine("End With") End Sub Public Sub Dump(ByVal Element As WhileStatement) Dumper.Write("While ") Element.Condition.Dump(Dumper) Dumper.WriteLine("") Dump(Element.CodeBlock) Dumper.WriteLine("End While") End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?