vbcodecompiler.cs

来自「没的 没的 没的 没的 没的 没的 没的 没的 没的 没的 没的 没的 没的 没」· CS 代码 · 共 1,281 行 · 第 1/3 页

CS
1,281
字号
			{				Output.Write("Goto ");				Output.Write(e.Label);				Output.WriteLine();			}	protected override void GenerateIterationStatement				(CodeIterationStatement e)			{				if(e.InitStatement != null)				{					GenerateStatement(e.InitStatement);				}				Output.Write("While ");				if(e.TestExpression != null)				{					GenerateExpression(e.TestExpression);				}				else				{					Output.Write("True");				}				Output.WriteLine();				++Indent;				GenerateStatements(e.Statements);				if(e.IncrementStatement != null)				{					GenerateStatement(e.IncrementStatement);				}				--Indent;				Output.WriteLine("End While");			}	protected override void GenerateLabeledStatement				(CodeLabeledStatement e)			{				Indent -= 1;				Output.Write(e.Label);				Output.WriteLine(":");				Indent += 1;				GenerateStatement(e.Statement);			}	protected override void GenerateMethodReturnStatement				(CodeMethodReturnStatement e)			{				CodeExpression expr = e.Expression;				if(expr == null)				{					Output.WriteLine("Return");				}				else				{					Output.Write("Return ");					GenerateExpression(expr);					Output.WriteLine();				}			}	protected override void GenerateRemoveEventStatement				(CodeRemoveEventStatement e)			{				Output.Write("RemoveHandler ");				GenerateExpression(e.Event);				Output.Write(", ");				GenerateExpression(e.Listener);				Output.WriteLine();			}	protected override void GenerateThrowExceptionStatement				(CodeThrowExceptionStatement e)			{				CodeExpression expr = e.ToThrow;				if(expr == null)				{					Output.WriteLine("Throw");				}				else				{					Output.Write("Throw ");					GenerateExpression(expr);					Output.WriteLine();				}			}	protected override void GenerateTryCatchFinallyStatement				(CodeTryCatchFinallyStatement e)			{				Output.WriteLine("Try");				++Indent;				GenerateStatements(e.TryStatements);				--Indent;				CodeCatchClauseCollection clauses = e.CatchClauses;				if(clauses.Count > 0)				{					foreach(CodeCatchClause clause in clauses)					{						if(clause.CatchExceptionType != null)						{							Output.Write("Catch ");							OutputIdentifier(clause.LocalName);							Output.Write(" As ");							OutputType(clause.CatchExceptionType);							Output.WriteLine();						}						else						{							Output.WriteLine("Catch");						}						++Indent;						GenerateStatements(clause.Statements);						--Indent;					}				}				CodeStatementCollection fin = e.FinallyStatements;				if(fin.Count > 0)				{					Output.WriteLine("Finally");					++Indent;					GenerateStatements(fin);					--Indent;				}				Output.WriteLine("End Try");			}	protected override void GenerateVariableDeclarationStatement				(CodeVariableDeclarationStatement e)			{				Output.Write("Dim ");				OutputTypeNamePair(e.Type, e.Name);				if(e.InitExpression != null)				{					Output.Write(" = ");					GenerateExpression(e.InitExpression);				}				Output.WriteLine();			}	// Generate various declaration categories.	protected override void GenerateAttributeDeclarationsStart				(CodeAttributeDeclarationCollection attributes)			{				Output.Write("<");			}	protected override void GenerateAttributeDeclarationsEnd				(CodeAttributeDeclarationCollection attributes)			{				Output.Write(">");			}	protected override void GenerateConstructor				(CodeConstructor e, CodeTypeDeclaration c)			{				// Bail out if not a class or struct.				if(!IsCurrentClass && !IsCurrentStruct)				{					return;				}				// Output the attributes and constructor signature.				OutputAttributeDeclarations(e.CustomAttributes);				OutputMemberAccessModifier(e.Attributes);				Output.Write("Sub New ");				Output.Write("(");				OutputParameters(e.Parameters);				Output.WriteLine(")");				// Output the body of the constructor.				++Indent;				GenerateStatements(e.Statements);				--Indent;				Output.WriteLine("End Sub");			}	protected override void GenerateEntryPointMethod				(CodeEntryPointMethod e, CodeTypeDeclaration c)			{				Output.WriteLine("Public Shared Sub Main()");				++Indent;				GenerateStatements(e.Statements);				--Indent;				Output.WriteLine("End Sub");			}	protected override void GenerateEvent				(CodeMemberEvent e, CodeTypeDeclaration c)			{				// Bail out if not a class, struct, or interface.				if(!IsCurrentClass && !IsCurrentStruct && !IsCurrentInterface)				{					return;				}				// Output the event definition.				OutputAttributeDeclarations(e.CustomAttributes);				if(e.PrivateImplementationType == null)				{					OutputMemberAccessModifier(e.Attributes);					OutputMemberScopeModifier(e.Attributes);					Output.Write("Event ");					OutputTypeNamePair(e.Type, e.Name);				}				else				{					Output.Write("Event ");					OutputTypeNamePair(e.Type, e.Name);					Output.Write(" Implements ");					OutputType(e.PrivateImplementationType);				}				Output.WriteLine();			}	protected override void GenerateField(CodeMemberField e)			{				// Bail out if not a class, struct, or enum.				if(!IsCurrentClass && !IsCurrentStruct && !IsCurrentEnum)				{					return;				}				// Generate information about the field.				if(!IsCurrentEnum)				{					OutputAttributeDeclarations(e.CustomAttributes);					OutputMemberAccessModifier(e.Attributes);					OutputFieldScopeModifier(e.Attributes);					OutputTypeNamePair(e.Type, e.Name);					if(e.InitExpression != null)					{						Output.Write(" = ");						GenerateExpression(e.InitExpression);					}					Output.WriteLine();				}				else				{					OutputAttributeDeclarations(e.CustomAttributes);					OutputIdentifier(e.Name);					if(e.InitExpression != null)					{						Output.Write(" = ");						GenerateExpression(e.InitExpression);					}					Output.WriteLine();				}			}	protected override void GenerateMethod				(CodeMemberMethod e, CodeTypeDeclaration c)			{				// Bail out if not a class, struct, or interface.				if(!IsCurrentClass && !IsCurrentStruct && !IsCurrentInterface)				{					return;				}				// Output the attributes and method signature.				OutputAttributeDeclarations(e.CustomAttributes);				if(!IsCurrentInterface)				{					if(e.PrivateImplementationType == null)					{						OutputMemberAccessModifier(e.Attributes);						OutputMemberScopeModifier(e.Attributes);					}				}				else if((e.Attributes & MemberAttributes.VTableMask)							== MemberAttributes.New)				{					Output.Write("Shadows ");				}				if(e.ReturnType != null)				{					Output.Write("Function ");				}				else				{					Output.Write("Sub ");				}				Output.Write(" ");				OutputIdentifier(e.Name);				Output.Write("(");				OutputParameters(e.Parameters);				Output.Write(")");				if(e.ReturnType != null)				{					Output.Write(" As ");					OutputType(e.ReturnType);				}				Output.WriteLine();				if(e.PrivateImplementationType != null && !IsCurrentInterface)				{					Output.Write("Implements ");					Output.Write(e.PrivateImplementationType.BaseType);					Output.WriteLine();				}				// Output the body of the method.				if(IsCurrentInterface ||				   (e.Attributes & MemberAttributes.ScopeMask) ==				   		MemberAttributes.Abstract)				{					// Nothing to do here.				}				else				{					++Indent;					GenerateStatements(e.Statements);					--Indent;					if(e.ReturnType != null)					{						Output.WriteLine("End Function");					}					else					{						Output.WriteLine("End Sub");					}				}			}	protected override void GenerateProperty				(CodeMemberProperty e, CodeTypeDeclaration c)			{				// Bail out if not a class, struct, or interface.				if(!IsCurrentClass && !IsCurrentStruct && !IsCurrentInterface)				{					return;				}				// Output the attributes and property signature.				OutputAttributeDeclarations(e.CustomAttributes);				if(!IsCurrentInterface)				{					if(e.PrivateImplementationType == null)					{						OutputMemberAccessModifier(e.Attributes);						OutputMemberScopeModifier(e.Attributes);					}				}				else if((e.Attributes & MemberAttributes.VTableMask)							== MemberAttributes.New)				{					Output.Write("Shadows ");				}				Output.Write("Property ");				OutputIdentifier(e.Name);				if(e.Parameters.Count != 0)				{					Output.Write("(");					OutputParameters(e.Parameters);					Output.Write(")");				}				Output.Write(" As ");				OutputType(e.Type);				if(e.PrivateImplementationType != null && !IsCurrentInterface)				{					Output.Write(" Implements ");					Output.Write(e.PrivateImplementationType.BaseType);				}				Output.WriteLine();				// Output the body of the property.				++Indent;				if(e.HasGet)				{					if(IsCurrentInterface ||					   (e.Attributes & MemberAttributes.ScopeMask)							== MemberAttributes.Abstract)					{						Output.WriteLine("Get");					}					else					{						Output.WriteLine("Get");						++Indent;						GenerateStatements(e.GetStatements);						--Indent;						Output.WriteLine("End Get");					}				}				if(e.HasSet)				{					if(IsCurrentInterface ||					   (e.Attributes & MemberAttributes.ScopeMask)							== MemberAttributes.Abstract)					{						Output.WriteLine("Set");					}					else					{						Output.WriteLine("Set");						++Indent;						GenerateStatements(e.SetStatements);						--Indent;						Output.WriteLine("End Set");					}				}				++Indent;				Output.WriteLine("End Property");			}	protected override void GenerateNamespaceStart(CodeNamespace e)			{				Output.Write("Namespace ");				OutputIdentifier(e.Name);				Output.WriteLine();			}	protected override void GenerateNamespaceEnd(CodeNamespace e)			{				Output.WriteLine("End Namespace");			}	protected override void GenerateNamespaceImport(CodeNamespaceImport e)			{				Output.Write("Imports ");				OutputIdentifier(e.Namespace);				Output.WriteLine();			}	protected override void GenerateSnippetMember				(CodeSnippetTypeMember e)			{				Output.Write(e.Text);			}	protected override void GenerateTypeConstructor				(CodeTypeConstructor e)			{				Output.WriteLine("Shared Sub New ");				++Indent;				GenerateStatements(e.Statements);				--Indent;				Output.WriteLine("End Sub");			}	protected override void GenerateTypeStart(CodeTypeDeclaration e)			{				OutputAttributeDeclarations(e.CustomAttributes);				if(!IsCurrentDelegate)				{					OutputTypeAttributes						(e.TypeAttributes, IsCurrentStruct, IsCurrentEnum);					OutputIdentifier(e.Name);					Output.WriteLine();					Indent += 2;

⌨️ 快捷键说明

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