trycatchstatement.cs
来自「全功能c#编译器」· CS 代码 · 共 129 行
CS
129 行
using System;
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
namespace ICSharpCode.CsVbRefactory.Parser.AST
{
public class TryCatchStatement : Statement
{
Statement statementBlock;
List<CatchClause> catchClauses;
Statement finallyBlock;
public Statement StatementBlock {
get {
return statementBlock;
}
set {
statementBlock = value == null ? Statement.Null : value;
}
}
public List<CatchClause> CatchClauses {
get {
return catchClauses;
}
set {
catchClauses = value == null ? new List<CatchClause>(1) : value;
}
}
public Statement FinallyBlock {
get {
return finallyBlock;
}
set {
finallyBlock = value == null ? Statement.Null : value;
}
}
public TryCatchStatement(Statement statementBlock, List<CatchClause> catchClauses, Statement finallyBlock)
{
this.StatementBlock = statementBlock;
this.CatchClauses = catchClauses;
this.FinallyBlock = finallyBlock;
}
public TryCatchStatement(Statement statementBlock, List<CatchClause> catchClauses) : this(statementBlock, catchClauses, null)
{
}
public override object AcceptVisitor(IASTVisitor visitor, object data)
{
return visitor.Visit(this, data);
}
public override string ToString()
{
return String.Format("[TryCatchStatement: StatementBlock={0}, CatchClauses={1}, FinallyBlock={2}]",
statementBlock,
GetCollectionString(catchClauses),
finallyBlock);
}
}
public class CatchClause : AbstractNode
{
string type = "";
string variableName = "";
Statement statementBlock;
public string Type {
get {
return type;
}
set {
Debug.Assert(value != null);
type = value;
}
}
public string VariableName {
get {
return variableName;
}
set {
Debug.Assert(value != null);
variableName = value;
}
}
public Statement StatementBlock {
get {
return statementBlock;
}
set {
statementBlock = value;
}
}
public CatchClause(string type, string variableName, Statement statementBlock)
{
this.type = type;
this.variableName = variableName;
this.statementBlock = statementBlock;
}
public CatchClause(Statement statementBlock)
{
this.type = "";
this.variableName = "";
this.statementBlock = statementBlock;
}
public override object AcceptVisitor(IASTVisitor visitor, object data)
{
return visitor.Visit(this, data);
}
public override string ToString()
{
return String.Format("[CatchClause: Type={0}, VariableName={1}, StatementBlock={2}]",
type,
variableName,
statementBlock);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?