Address remaining PROTOTYPE comments.

上级 e39b6beb
......@@ -1418,25 +1418,6 @@ private IAwaitOperation CreateBoundAwaitExpressionOperation(BoundAwaitExpression
private IArrayElementReferenceOperation CreateBoundArrayAccessOperation(BoundArrayAccess boundArrayAccess)
{
// PROTOTYPE(iop): When removing the laziness, this comment will no longer be relevant, because caching won't
// occur here
// The compiler will dedupe the _arrayAccess.Expression between different array references. Some example code:
//
// class C
// {
// int[] a;
// static void Main()
// {
// // Compiler dedupes the array access receiver for [0] and [1]
// var a = new C { a = { [0] = 1, [1] = 2 } };
// }
// }
//
// In order to prevent parent pointer from having an issue with this, we intentionally create a new IOperation node every time
// we encounter an array access. Since we create from the top down, it should be impossible for us to see the node in
// boundArrayAccess.Expression before seeing the boundArrayAccess itself, so this should not create any other parent pointer
// issues.
IOperation arrayReference = Create(boundArrayAccess.Expression);
ImmutableArray<IOperation> indices = CreateFromArray<BoundExpression, IOperation>(boundArrayAccess.Indices);
SyntaxNode syntax = boundArrayAccess.Syntax;
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
namespace Microsoft.CodeAnalysis
{
// PROTOTYPE(iop): Delete this after migration
internal abstract class OperationOld : Operation
{
protected OperationOld(OperationKind kind, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol type, ConstantValue constantValue, bool isImplicit)
: base(semanticModel, syntax, isImplicit)
{
// Constant value cannot be "null" for non-nullable value type operations.
Debug.Assert(type?.IsValueType != true || ITypeSymbolHelpers.IsNullableType(type) || constantValue == null || constantValue == CodeAnalysis.ConstantValue.Unset || !constantValue.IsNull);
Type = type;
Kind = kind;
OperationConstantValue = constantValue;
}
/// <summary>
/// <inheritdoc/>
/// </summary>
public override ITypeSymbol? Type { get; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public override OperationKind Kind { get; }
internal override CodeAnalysis.ConstantValue? OperationConstantValue { get; }
}
}
......@@ -20,12 +20,6 @@ Namespace Microsoft.CodeAnalysis.Operations
_semanticModel = semanticModel
End Sub
Private Function Clone() As VisualBasicOperationFactory
Dim factory As New VisualBasicOperationFactory(_semanticModel)
factory._lazyPlaceholderToParentMap = _lazyPlaceholderToParentMap
Return factory
End Function
''' <summary>
''' Returns <code>Nothing</code> if parent is not known.
''' </summary>
......@@ -1062,17 +1056,7 @@ Namespace Microsoft.CodeAnalysis.Operations
End Function
Friend Function CreateBoundCaseBlockCondition(boundCaseBlock As BoundCaseBlock) As IOperation
' Some bound nodes used by the boundCaseBlock.CaseStatement.CaseClauses are also going to be used in boundCaseBlock.CaseStatement.ConditionOpt.
' If we simply create another tree based on boundCaseBlock.CaseStatement.ConditionOpt, due to the caching we will end up with the same
' IOperation nodes in two trees, and two parents will compete for assigning itself as the parent - trouble. To avoid that, we simply use
' a new factory to create IOperation tree for the condition. Note that the condition tree is internal and regular consumers cannot get to
' the nodes it contains. At the moment, it is used only by CFG builder. The builder, rewrites all nodes anyway, it is producing a "forest"
' of different trees. So, there is really no chance of some external consumer getting confused by multiple explicit nodes tied to the same
' syntax.
'
' PROTOTYPE(iop): this can be removed when `Create` is refactored to not cache here
Return Clone().Create(boundCaseBlock.CaseStatement.ConditionOpt)
Return Create(boundCaseBlock.CaseStatement.ConditionOpt)
End Function
Private Function CreateBoundCaseBlockOperation(boundCaseBlock As BoundCaseBlock) As ISwitchCaseOperation
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册