提交 2316dd75 编写于 作者: A AlekseyTs

VB Unstructured Exception Handling: Finish work to comply with requirement...

VB Unstructured Exception Handling: Finish work to comply with requirement that IL shall only differ between Release and Debug. Enable/fix all Unstructured Exception Handling unit-tests.
***NO_CI***
 (changeset 1386638)
上级 f5b41926
......@@ -135,6 +135,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Me.Flags = flags
End Sub
Public ReadOnly Property OptimizationLevelIsDebug As Boolean
Get
Return Me.Compilation.Options.OptimizationLevel = OptimizationLevel.Debug
End Get
End Property
Private Shared Function RewriteNode(node As BoundNode,
topMethod As MethodSymbol,
currentMethod As MethodSymbol,
......
......@@ -44,7 +44,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Dim asMultiline = DirectCast(syntax, MultiLineIfBlockSyntax)
conditionSyntax = asMultiline.IfStatement
newConsequence = InsertBlockEpilogue(newConsequence,
If(generateUnstructuredExceptionHandlingResumeCode,
If(generateUnstructuredExceptionHandlingResumeCode AndAlso (OptimizationLevelIsDebug OrElse finishConsequenceWithResumeTarget),
RegisterUnstructuredExceptionHandlingNonThrowingResumeTarget(newConsequence.Syntax),
Nothing),
asMultiline.EndIfStatement)
......@@ -54,7 +54,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Dim asElseIfBlock = DirectCast(syntax, ElseIfBlockSyntax)
conditionSyntax = asElseIfBlock.ElseIfStatement
newConsequence = InsertBlockEpilogue(newConsequence,
If(generateUnstructuredExceptionHandlingResumeCode,
If(generateUnstructuredExceptionHandlingResumeCode AndAlso (OptimizationLevelIsDebug OrElse finishConsequenceWithResumeTarget),
RegisterUnstructuredExceptionHandlingNonThrowingResumeTarget(newConsequence.Syntax),
Nothing),
DirectCast(syntax.Parent, MultiLineIfBlockSyntax).EndIfStatement)
......@@ -80,7 +80,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
If asElse IsNot Nothing Then
' Update the resume table to make sure that we are in the right scope when we Resume Next on [End If].
newAlternative = InsertBlockEpilogue(newAlternative,
If(generateUnstructuredExceptionHandlingResumeCode,
If(generateUnstructuredExceptionHandlingResumeCode AndAlso OptimizationLevelIsDebug,
RegisterUnstructuredExceptionHandlingNonThrowingResumeTarget(newAlternative.Syntax),
Nothing),
DirectCast(asElse.Parent, MultiLineIfBlockSyntax).EndIfStatement)
......
......@@ -227,7 +227,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
' Determine if the handler index is less than or equal to -2 (ActiveHandler_FirstOnErrorResumeNextIndex):
' If so, replace it with ActiveHandler_ResumeNext and jump to the switch.
statements.Add(New BoundUnstructuredExceptionOnErrorSwitch(node.Syntax,
If(node.ResumeWithoutLabelOpt IsNot Nothing AndAlso Me.Compilation.Options.OptimizationLevel = OptimizationLevel.Debug,
If(node.ResumeWithoutLabelOpt IsNot Nothing AndAlso OptimizationLevelIsDebug,
nodeFactory.Conditional(nodeFactory.Binary(BinaryOperatorKind.GreaterThan,
bool,
nodeFactory.Local(unstructuredExceptionHandling.ActiveHandlerTemporary, isLValue:=False),
......@@ -347,7 +347,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
unstructuredExceptionHandling.ExceptionHandlers.Add(nodeFactory.Goto(node.LabelOpt, setWasCompilerGenerated:=False))
Case OnErrorStatementKind.ResumeNext
If Compilation.Options.OptimizationLevel = OptimizationLevel.Debug Then
If OptimizationLevelIsDebug Then
newErrorHandlerIndex = ActiveHandler_FirstOnErrorResumeNextIndex - unstructuredExceptionHandling.OnErrorResumeNextCount
Else
newErrorHandlerIndex = ActiveHandler_ResumeNext
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册