提交 d295c279 编写于 作者: C Charles Stoner

Add hoisted catch exception to the local scope

上级 59b16273
......@@ -1470,6 +1470,7 @@ .maxstack 3
<forward declaringType=""C"" methodName=""F"" />
<hoistedLocalScopes>
<slot startOffset=""0xe"" endOffset=""0xed"" />
<slot startOffset=""0x29"" endOffset=""0x32"" />
</hoistedLocalScopes>
<encLocalSlotMap>
<slot kind=""27"" offset=""0"" />
......
......@@ -344,6 +344,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGen
Case BoundKind.FieldAccess
Dim left = DirectCast(exceptionSource, BoundFieldAccess)
If Not left.FieldSymbol.IsShared Then
Dim stateMachineField = TryCast(left.FieldSymbol, StateMachineFieldSymbol)
If (stateMachineField IsNot Nothing) AndAlso (stateMachineField.SlotIndex >= 0) Then
DefineUserDefinedStateMachineHoistedLocal(stateMachineField)
End If
' When assigning to a field
' we need to push param address below the exception
Dim temp = AllocateTemp(exceptionSource.Type, exceptionSource.Syntax)
......@@ -1414,17 +1420,21 @@ OtherExpressions:
' 817 // we skip loading this lifted field since it is out of scope.
For Each field In scope.Fields
Dim name As String = Nothing
Dim index As Integer = 0
Dim parsedOk As Boolean = GeneratedNames.TryParseStateMachineHoistedUserVariableName(field.Name, name, index)
Debug.Assert(parsedOk)
Debug.Assert(index >= 0)
If parsedOk Then
DefineUserDefinedStateMachineHoistedLocal(DirectCast(field, StateMachineFieldSymbol))
Next
EmitStatement(scope.Statement)
_builder.CloseLocalScope()
End Sub
Private Sub DefineUserDefinedStateMachineHoistedLocal(field As StateMachineFieldSymbol)
Debug.Assert(field.SlotIndex >= 0)
Dim fakePdbOnlyLocal = New LocalDefinition(
symbolOpt:=Nothing,
nameOpt:=field.Name,
type:=Nothing,
slot:=index,
slot:=field.SlotIndex,
synthesizedKind:=SynthesizedLocalKind.EmitterTemp,
id:=Nothing,
pdbAttributes:=Cci.PdbWriter.DefaultLocalAttributesValue,
......@@ -1432,12 +1442,6 @@ OtherExpressions:
isDynamic:=False,
dynamicTransformFlags:=Nothing)
_builder.AddLocalToScope(fakePdbOnlyLocal)
End If
Next
EmitStatement(scope.Statement)
_builder.CloseLocalScope()
End Sub
Private Sub EmitUnstructuredExceptionResumeSwitch(node As BoundUnstructuredExceptionResumeSwitch)
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.Cci
Imports Microsoft.CodeAnalysis.CodeGen
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic
''' <summary>
''' Represents a synthesized state machine helper field.
''' </summary>
Friend Class StateMachineFieldSymbol
Friend NotInheritable Class StateMachineFieldSymbol
Inherits SynthesizedFieldSymbol
Implements ISynthesizedMethodBodyImplementationSymbol
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册