提交 e51ce40c 编写于 作者: M Manish Vasani

Address review feedback

上级 bdc83b7e
......@@ -1302,13 +1302,14 @@ private ICatchClause CreateBoundCatchBlockOperation(BoundCatchBlock boundCatchBl
var exceptionSourceOpt = (BoundLocal)boundCatchBlock.ExceptionSourceOpt;
Lazy<IOperation> expressionDeclarationOrExpression = new Lazy<IOperation>(() => exceptionSourceOpt != null ? CreateVariableDeclaration(exceptionSourceOpt) : null);
ITypeSymbol exceptionType = boundCatchBlock.ExceptionTypeOpt;
ImmutableArray<ILocalSymbol> locals = boundCatchBlock.Locals.As<ILocalSymbol>();
Lazy<IOperation> filter = new Lazy<IOperation>(() => Create(boundCatchBlock.ExceptionFilterOpt));
Lazy<IBlockStatement> handler = new Lazy<IBlockStatement>(() => (IBlockStatement)Create(boundCatchBlock.Body));
SyntaxNode syntax = boundCatchBlock.Syntax;
ITypeSymbol type = null;
Optional<object> constantValue = default(Optional<object>);
bool isImplicit = boundCatchBlock.WasCompilerGenerated;
return new LazyCatchClause(expressionDeclarationOrExpression, exceptionType, filter, handler, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyCatchClause(expressionDeclarationOrExpression, exceptionType, locals, filter, handler, _semanticModel, syntax, type, constantValue, isImplicit);
}
private IFixedStatement CreateBoundFixedStatementOperation(BoundFixedStatement boundFixedStatement)
......
......@@ -43,6 +43,7 @@ void M(int i)
Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 0) (Syntax: '0')
Catch clauses(1):
ICatchClause (Exception type: System.Exception) (OperationKind.CatchClause) (Syntax: 'catch (Exce ... }')
Locals: Local_1: System.Exception ex
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: '(Exception ex)')
Variables: Local_1: System.Exception ex
Initializer: null
......@@ -100,6 +101,7 @@ void M(int i)
Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 0) (Syntax: '0')
Catch clauses(1):
ICatchClause (Exception type: System.Exception) (OperationKind.CatchClause) (Syntax: 'catch (Exce ... }')
Locals: Local_1: System.Exception ex
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: '(Exception ex)')
Variables: Local_1: System.Exception ex
Initializer: null
......@@ -144,6 +146,7 @@ static void Main()
Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }')
Catch clauses(1):
ICatchClause (Exception type: System.IO.IOException) (OperationKind.CatchClause) (Syntax: 'catch (Syst ... }')
Locals: Local_1: System.IO.IOException e
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: '(System.IO. ... xception e)')
Variables: Local_1: System.IO.IOException e
Initializer: null
......@@ -183,6 +186,7 @@ static void Main()
Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }')
Catch clauses(1):
ICatchClause (Exception type: System.IO.IOException) (OperationKind.CatchClause) (Syntax: 'catch (Syst ... }')
Locals: Local_1: System.IO.IOException e
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: '(System.IO. ... xception e)')
Variables: Local_1: System.IO.IOException e
Initializer: null
......@@ -226,12 +230,14 @@ static void Main()
Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }')
Catch clauses(2):
ICatchClause (Exception type: System.IO.IOException) (OperationKind.CatchClause) (Syntax: 'catch (Syst ... }')
Locals: Local_1: System.IO.IOException e
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: '(System.IO. ... xception e)')
Variables: Local_1: System.IO.IOException e
Initializer: null
Filter: null
Handler: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }')
ICatchClause (Exception type: System.Exception) (OperationKind.CatchClause) (Syntax: 'catch (Syst ... }')
Locals: Local_1: System.Exception e
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: '(System.Exception e)')
Variables: Local_1: System.Exception e
Initializer: null
......@@ -279,12 +285,14 @@ static void Main()
Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }')
Catch clauses(2):
ICatchClause (Exception type: System.IO.IOException) (OperationKind.CatchClause) (Syntax: 'catch (Syst ... }')
Locals: Local_1: System.IO.IOException e
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: '(System.IO. ... xception e)')
Variables: Local_1: System.IO.IOException e
Initializer: null
Filter: null
Handler: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }')
ICatchClause (Exception type: System.IO.IOException) (OperationKind.CatchClause, IsInvalid) (Syntax: 'catch (Syst ... }')
Locals: Local_1: System.IO.IOException e
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration, IsInvalid) (Syntax: '(System.IO. ... xception e)')
Variables: Local_1: System.IO.IOException e
Initializer: null
......@@ -532,6 +540,7 @@ static void M(object o)
Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }')
Catch clauses(1):
ICatchClause (Exception type: System.Exception) (OperationKind.CatchClause) (Syntax: 'catch (Exce ... }')
Locals: Local_1: System.String s
ExceptionDeclarationOrExpression: null
Filter: IIsPatternExpression (OperationKind.IsPatternExpression, Type: System.Boolean) (Syntax: 'o is string s')
Expression: IParameterReferenceExpression: o (OperationKind.ParameterReferenceExpression, Type: System.Object) (Syntax: 'o')
......@@ -544,6 +553,51 @@ static void M(object o)
VerifyOperationTreeAndDiagnosticsForTest<TryStatementSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void TryCatch_CatchFilterAndSourceWithLocalDeclaration()
{
string source = @"
using System;
class C
{
static void M(object o)
{
/*<bind>*/try
{
}
catch (Exception e) when (o is string s)
{
}/*</bind>*/
}
}
";
string expectedOperationTree = @"
ITryStatement (OperationKind.TryStatement) (Syntax: 'try ... }')
Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }')
Catch clauses(1):
ICatchClause (Exception type: System.Exception) (OperationKind.CatchClause) (Syntax: 'catch (Exce ... }')
Locals: Local_1: System.Exception e
Local_2: System.String s
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: '(Exception e)')
Variables: Local_1: System.Exception e
Initializer: null
Filter: IIsPatternExpression (OperationKind.IsPatternExpression, Type: System.Boolean) (Syntax: 'o is string s')
Expression: IParameterReferenceExpression: o (OperationKind.ParameterReferenceExpression, Type: System.Object) (Syntax: 'o')
Pattern: IDeclarationPattern (Declared Symbol: System.String s) (OperationKind.DeclarationPattern) (Syntax: 'string s')
Handler: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }')
Finally: null
";
var expectedDiagnostics = new DiagnosticDescription[] {
// file.cs(11,26): warning CS0168: The variable 'e' is declared but never used
// catch (Exception e) when (o is string s)
Diagnostic(ErrorCode.WRN_UnreferencedVar, "e").WithArguments("e").WithLocation(11, 26)
};
VerifyOperationTreeAndDiagnosticsForTest<TryStatementSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void TryCatch_FinallyWithLocalDeclaration()
......@@ -603,6 +657,7 @@ static void Main()
";
string expectedOperationTree = @"
ICatchClause (Exception type: System.Int32) (OperationKind.CatchClause, IsInvalid) (Syntax: 'catch (int ... }')
Locals: Local_1: System.Int32 e
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration, IsInvalid) (Syntax: '(int e)')
Variables: Local_1: System.Int32 e
Initializer: null
......@@ -641,6 +696,7 @@ static void Main()
";
string expectedOperationTree = @"
ICatchClause (Exception type: System.IO.IOException) (OperationKind.CatchClause) (Syntax: 'catch (Syst ... }')
Locals: Local_1: System.IO.IOException e
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: '(System.IO. ... xception e)')
Variables: Local_1: System.IO.IOException e
Initializer: null
......
......@@ -821,15 +821,20 @@ internal abstract partial class CaseClause : Operation, ICaseClause
/// </summary>
internal abstract partial class BaseCatchClause : Operation, ICatchClause
{
protected BaseCatchClause(ITypeSymbol exceptionType, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
protected BaseCatchClause(ITypeSymbol exceptionType, ImmutableArray<ILocalSymbol> locals, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(OperationKind.CatchClause, semanticModel, syntax, type, constantValue, isImplicit)
{
ExceptionType = exceptionType;
Locals = locals;
}
/// <summary>
/// Type of the exception handled by the catch clause.
/// </summary>
public ITypeSymbol ExceptionType { get; }
/// <summary>
/// Locals declared by the <see cref="ExceptionDeclarationOrExpression"/> and/or <see cref="Filter"/> clause.
/// </summary>
public ImmutableArray<ILocalSymbol> Locals { get; }
protected abstract IOperation ExceptionDeclarationOrExpressionImpl { get; }
protected abstract IOperation FilterImpl { get; }
protected abstract IBlockStatement HandlerImpl { get; }
......@@ -874,8 +879,8 @@ public override void Accept(OperationVisitor visitor)
/// </summary>
internal sealed partial class CatchClause : BaseCatchClause, ICatchClause
{
public CatchClause(IOperation exceptionDeclarationOrExpression, ITypeSymbol exceptionType, IOperation filter, IBlockStatement handler, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(exceptionType, semanticModel, syntax, type, constantValue, isImplicit)
public CatchClause(IOperation exceptionDeclarationOrExpression, ITypeSymbol exceptionType, ImmutableArray<ILocalSymbol> locals, IOperation filter, IBlockStatement handler, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(exceptionType, locals, semanticModel, syntax, type, constantValue, isImplicit)
{
ExceptionDeclarationOrExpressionImpl = exceptionDeclarationOrExpression;
FilterImpl = filter;
......@@ -896,8 +901,8 @@ internal sealed partial class LazyCatchClause : BaseCatchClause, ICatchClause
private readonly Lazy<IOperation> _lazyFilter;
private readonly Lazy<IBlockStatement> _lazyHandler;
public LazyCatchClause(Lazy<IOperation> exceptionDeclarationOrExpression, ITypeSymbol exceptionType, Lazy<IOperation> filter, Lazy<IBlockStatement> handler, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit)
: base(exceptionType, semanticModel, syntax, type, constantValue, isImplicit)
public LazyCatchClause(Lazy<IOperation> exceptionDeclarationOrExpression, ITypeSymbol exceptionType, ImmutableArray<ILocalSymbol> locals, Lazy<IOperation> filter, Lazy<IBlockStatement> handler, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit)
: base(exceptionType, locals, semanticModel, syntax, type, constantValue, isImplicit)
{
_lazyExceptionDeclarationOrExpression = exceptionDeclarationOrExpression ?? throw new System.ArgumentNullException(nameof(exceptionDeclarationOrExpression));
_lazyFilter = filter ?? throw new System.ArgumentNullException(nameof(filter));
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Immutable;
namespace Microsoft.CodeAnalysis.Semantics
{
/// <summary>
......@@ -16,6 +18,11 @@ public interface ICatchClause : IOperation
/// </summary>
IBlockStatement Handler { get; }
/// <summary>
/// Locals declared by the <see cref="ExceptionDeclarationOrExpression"/> and/or <see cref="Filter"/> clause.
/// </summary>
ImmutableArray<ILocalSymbol> Locals { get; }
/// <summary>
/// Type of the exception handled by the catch clause.
/// </summary>
......
......@@ -146,7 +146,7 @@ public override IOperation VisitTryStatement(ITryStatement operation, object arg
public override IOperation VisitCatchClause(ICatchClause operation, object argument)
{
return new CatchClause(Visit(operation.ExceptionDeclarationOrExpression), operation.ExceptionType, Visit(operation.Filter), Visit(operation.Handler), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
return new CatchClause(Visit(operation.ExceptionDeclarationOrExpression), operation.ExceptionType, operation.Locals, Visit(operation.Filter), Visit(operation.Handler), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
}
public override IOperation VisitUsingStatement(IUsingStatement operation, object argument)
......
......@@ -234,6 +234,7 @@ Microsoft.CodeAnalysis.Semantics.ICatchClause.ExceptionDeclarationOrExpression.g
Microsoft.CodeAnalysis.Semantics.ICatchClause.ExceptionType.get -> Microsoft.CodeAnalysis.ITypeSymbol
Microsoft.CodeAnalysis.Semantics.ICatchClause.Filter.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.ICatchClause.Handler.get -> Microsoft.CodeAnalysis.Semantics.IBlockStatement
Microsoft.CodeAnalysis.Semantics.ICatchClause.Locals.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ILocalSymbol>
Microsoft.CodeAnalysis.Semantics.ICoalesceExpression
Microsoft.CodeAnalysis.Semantics.ICoalesceExpression.Expression.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.ICoalesceExpression.WhenNull.get -> Microsoft.CodeAnalysis.IOperation
......
......@@ -1098,22 +1098,25 @@ Namespace Microsoft.CodeAnalysis.Semantics
Private Function CreateBoundCatchBlockOperation(boundCatchBlock As BoundCatchBlock) As ICatchClause
Dim exceptionDeclarationOrExpression As Lazy(Of IOperation) = New Lazy(Of IOperation)(
Function()
If boundCatchBlock.LocalOpt IsNot Nothing Then
Dim exceptionSourceOpt = DirectCast(boundCatchBlock.ExceptionSourceOpt, BoundLocal)
Debug.Assert(boundCatchBlock.LocalOpt Is exceptionSourceOpt.LocalSymbol)
Return OperationFactory.CreateVariableDeclaration(exceptionSourceOpt.LocalSymbol, initialValue:=Nothing, semanticModel:=_semanticModel, syntax:=exceptionSourceOpt.Syntax)
If boundCatchBlock.LocalOpt IsNot Nothing AndAlso
boundCatchBlock.ExceptionSourceOpt?.Kind = BoundKind.Local AndAlso
boundCatchBlock.LocalOpt Is DirectCast(boundCatchBlock.ExceptionSourceOpt, BoundLocal).LocalSymbol Then
Return OperationFactory.CreateVariableDeclaration(boundCatchBlock.LocalOpt, initialValue:=Nothing, semanticModel:=_semanticModel, syntax:=boundCatchBlock.ExceptionSourceOpt.Syntax)
Else
Return Create(boundCatchBlock.ExceptionSourceOpt)
End If
End Function)
Dim exceptionType As ITypeSymbol = If(boundCatchBlock.ExceptionSourceOpt?.Type, DirectCast(_semanticModel.Compilation, VisualBasicCompilation).GetWellKnownType(WellKnownType.System_Exception))
Dim locals As ImmutableArray(Of ILocalSymbol) = If(boundCatchBlock.LocalOpt IsNot Nothing,
ImmutableArray.Create(Of ILocalSymbol)(boundCatchBlock.LocalOpt),
ImmutableArray(Of ILocalSymbol).Empty)
Dim filter As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundCatchBlock.ExceptionFilterOpt))
Dim handler As Lazy(Of IBlockStatement) = New Lazy(Of IBlockStatement)(Function() DirectCast(Create(boundCatchBlock.Body), IBlockStatement))
Dim syntax As SyntaxNode = boundCatchBlock.Syntax
Dim type As ITypeSymbol = Nothing
Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)()
Dim isImplicit As Boolean = boundCatchBlock.WasCompilerGenerated
Return New LazyCatchClause(exceptionDeclarationOrExpression, exceptionType, filter, handler, _semanticModel, syntax, type, constantValue, isImplicit)
Return New LazyCatchClause(exceptionDeclarationOrExpression, exceptionType, locals, filter, handler, _semanticModel, syntax, type, constantValue, isImplicit)
End Function
Private Function CreateBoundBlockOperation(boundBlock As BoundBlock) As IBlockStatement
......
......@@ -626,6 +626,7 @@ End Module]]>.Value
Dim expectedOperationTree = <![CDATA[
ICatchClause (Exception type: System.Exception) (OperationKind.CatchClause) (Syntax: 'Catch ex As ... Is Nothing')
Locals: Local_1: ex As System.Exception
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'ex')
Variables: Local_1: ex As System.Exception
Initializer: null
......
......@@ -35,6 +35,7 @@ ITryStatement (OperationKind.TryStatement) (Syntax: 'Try'BIND:"T ... End Try')
Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 0) (Syntax: '0')
Catch clauses(1):
ICatchClause (Exception type: System.Exception) (OperationKind.CatchClause) (Syntax: 'Catch ex As ... Throw ex')
Locals: Local_1: ex As System.Exception
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'ex')
Variables: Local_1: ex As System.Exception
Initializer: null
......@@ -85,6 +86,7 @@ IBlockStatement (3 statements) (OperationKind.BlockStatement) (Syntax: 'Private
Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 0) (Syntax: '0')
Catch clauses(1):
ICatchClause (Exception type: System.Exception) (OperationKind.CatchClause) (Syntax: 'Catch ex As ... Throw ex')
Locals: Local_1: ex As System.Exception
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'ex')
Variables: Local_1: ex As System.Exception
Initializer: null
......@@ -129,6 +131,7 @@ ITryStatement (OperationKind.TryStatement) (Syntax: 'Try'BIND:"T ... End Try')
Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: 'Try'BIND:"T ... End Try')
Catch clauses(1):
ICatchClause (Exception type: System.IO.IOException) (OperationKind.CatchClause) (Syntax: 'Catch e As ... IOException')
Locals: Local_1: e As System.IO.IOException
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'e')
Variables: Local_1: e As System.IO.IOException
Initializer: null
......@@ -160,6 +163,7 @@ ITryStatement (OperationKind.TryStatement) (Syntax: 'Try'BIND:"T ... End Try')
Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: 'Try'BIND:"T ... End Try')
Catch clauses(1):
ICatchClause (Exception type: System.IO.IOException) (OperationKind.CatchClause) (Syntax: 'Catch e As ... Not Nothing')
Locals: Local_1: e As System.IO.IOException
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'e')
Variables: Local_1: e As System.IO.IOException
Initializer: null
......@@ -199,12 +203,14 @@ ITryStatement (OperationKind.TryStatement) (Syntax: 'Try'BIND:"T ... End Try')
Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: 'Try'BIND:"T ... End Try')
Catch clauses(2):
ICatchClause (Exception type: System.IO.IOException) (OperationKind.CatchClause) (Syntax: 'Catch e As ... IOException')
Locals: Local_1: e As System.IO.IOException
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'e')
Variables: Local_1: e As System.IO.IOException
Initializer: null
Filter: null
Handler: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: 'Catch e As ... IOException')
ICatchClause (Exception type: System.Exception) (OperationKind.CatchClause) (Syntax: 'Catch e As ... Not Nothing')
Locals: Local_1: e As System.Exception
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'e')
Variables: Local_1: e As System.Exception
Initializer: null
......@@ -244,12 +250,14 @@ ITryStatement (OperationKind.TryStatement) (Syntax: 'Try'BIND:"T ... End Try')
Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: 'Try'BIND:"T ... End Try')
Catch clauses(2):
ICatchClause (Exception type: System.IO.IOException) (OperationKind.CatchClause) (Syntax: 'Catch e As ... IOException')
Locals: Local_1: e As System.IO.IOException
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'e')
Variables: Local_1: e As System.IO.IOException
Initializer: null
Filter: null
Handler: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: 'Catch e As ... IOException')
ICatchClause (Exception type: System.IO.IOException) (OperationKind.CatchClause) (Syntax: 'Catch e As ... Not Nothing')
Locals: Local_1: e As System.IO.IOException
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'e')
Variables: Local_1: e As System.IO.IOException
Initializer: null
......@@ -598,6 +606,7 @@ ITryStatement (OperationKind.TryStatement) (Syntax: 'Try'BIND:"T ... End Try')
Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: 'Try'BIND:"T ... End Try')
Catch clauses(1):
ICatchClause (Exception type: System.Exception) (OperationKind.CatchClause) (Syntax: 'Catch ex As ... Integer = 0')
Locals: Local_1: ex As System.Exception
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'ex')
Variables: Local_1: ex As System.Exception
Initializer: null
......@@ -665,6 +674,7 @@ ITryStatement (OperationKind.TryStatement, IsInvalid) (Syntax: 'Try'BIND:"T ...
Body: IBlockStatement (0 statements) (OperationKind.BlockStatement, IsInvalid) (Syntax: 'Try'BIND:"T ... End Try')
Catch clauses(1):
ICatchClause (Exception type: System.Int32) (OperationKind.CatchClause, IsInvalid) (Syntax: 'Catch i As Integer')
Locals: Local_1: i As System.Int32
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'i')
Variables: Local_1: i As System.Int32
Initializer: null
......@@ -697,6 +707,7 @@ End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
ICatchClause (Exception type: System.IO.IOException) (OperationKind.CatchClause) (Syntax: 'Catch e As ... Not Nothing')
Locals: Local_1: e As System.IO.IOException
ExceptionDeclarationOrExpression: IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'e')
Variables: Local_1: e As System.IO.IOException
Initializer: null
......
......@@ -574,6 +574,7 @@ public override void VisitCatchClause(ICatchClause operation)
LogString($" (Exception type: {exceptionTypeStr})");
LogCommonPropertiesAndNewLine(operation);
LogLocals(operation.Locals);
Visit(operation.ExceptionDeclarationOrExpression, "ExceptionDeclarationOrExpression");
Visit(operation.Filter, "Filter");
Visit(operation.Handler, "Handler");
......
......@@ -188,6 +188,7 @@ public override void VisitTryStatement(ITryStatement operation)
public override void VisitCatchClause(ICatchClause operation)
{
var exceptionType = operation.ExceptionType;
var locals = operation.Locals;
base.VisitCatchClause(operation);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册