提交 2898c124 编写于 作者: H Heejae Chang

regenerated xml.generated file

上级 23bba453
......@@ -180,8 +180,8 @@ internal BoundExpression ConvertPatternExpression(TypeSymbol inputType, CSharpSy
{
case ConversionKind.ExplicitDynamic:
case ConversionKind.ImplicitDynamic:
// Since the input was `dynamic`, which is equivalent to `object`, there must also
// exist some unboxing, identity, or reference conversion as well, making the conversion legal.
// Since the input was `dynamic`, which is equivalent to `object`, there must also
// exist some unboxing, identity, or reference conversion as well, making the conversion legal.
case ConversionKind.Boxing:
case ConversionKind.ExplicitNullable:
case ConversionKind.ExplicitReference:
......@@ -245,7 +245,7 @@ internal BoundExpression ConvertPatternExpression(TypeSymbol inputType, CSharpSy
case SyntaxKind.SingleVariableDesignation:
break;
case SyntaxKind.DiscardDesignation:
return new BoundDeclarationPattern(node, null, boundDeclType, isVar, hasErrors);
return new BoundDeclarationPattern(node, null, new BoundDiscardExpression(node, boundDeclType.Type), boundDeclType, isVar, hasErrors);
default:
throw ExceptionUtilities.UnexpectedValue(node.Designation.Kind());
}
......@@ -271,7 +271,8 @@ internal BoundExpression ConvertPatternExpression(TypeSymbol inputType, CSharpSy
hasErrors = CheckRestrictedTypeInAsync(this.ContainingMemberOrLambda, declType, diagnostics, typeSyntax);
}
return new BoundDeclarationPattern(node, localSymbol, boundDeclType, isVar, hasErrors);
var expression = localSymbol == null ? new BoundDiscardExpression(node, boundDeclType.Type) : (BoundExpression)new BoundLocal(node, localSymbol, null, boundDeclType.Type);
return new BoundDeclarationPattern(node, localSymbol, expression, boundDeclType, isVar, hasErrors);
}
else
{
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if false
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.Semantics;
using System.Collections.Immutable;
......@@ -262,8 +263,8 @@ public override void Accept(OperationVisitor visitor)
internal partial class BoundForEachStatement : IForEachLoopStatement
{
ILocalSymbol IForEachLoopStatement.IterationVariable => this.IterationVariables.Length == 1?
this.IterationVariables.FirstOrDefault():
ILocalSymbol IForEachLoopStatement.IterationVariable => this.IterationVariables.Length == 1 ?
this.IterationVariables.FirstOrDefault() :
null;
IOperation IForEachLoopStatement.Collection => this.Expression;
......@@ -612,7 +613,7 @@ ImmutableArray<IVariableDeclaration> IVariableDeclarationStatement.Variables
get
{
return (ImmutableArray<IVariableDeclaration>)s_variablesMappings.GetValue(this,
declaration => ImmutableArray.Create<IVariableDeclaration>(new VariableDeclaration(declaration.LocalSymbol, declaration.InitializerOpt, declaration.Syntax)));
declaration => ImmutableArray.Create<IVariableDeclaration>(OperationFactory.CreateVariableDeclaration(declaration.LocalSymbol, declaration.InitializerOpt, declaration.Syntax)));
}
}
......@@ -641,7 +642,7 @@ ImmutableArray<IVariableDeclaration> IVariableDeclarationStatement.Variables
return (ImmutableArray<IVariableDeclaration>)s_variablesMappings.GetValue(this,
multipleDeclarations =>
multipleDeclarations.LocalDeclarations.SelectAsArray(declaration =>
(IVariableDeclaration)new VariableDeclaration(declaration.LocalSymbol, declaration.InitializerOpt, declaration.Syntax)));
(IVariableDeclaration)OperationFactory.CreateVariableDeclaration(declaration.LocalSymbol, declaration.InitializerOpt, declaration.Syntax)));
}
}
......@@ -837,3 +838,4 @@ public override void Accept(OperationVisitor visitor)
}
}
}
#endif
\ No newline at end of file
......@@ -103,7 +103,7 @@ public override CSharpSemanticModel ParentModel
internal override MemberSemanticModel GetMemberModel(SyntaxNode node)
{
// We do have to override this method, but should never call it because it might not do the right thing.
Debug.Assert(false);
Debug.Assert(false);
return IsInTree(node) ? this : null;
}
......@@ -591,7 +591,7 @@ private LocalFunctionSymbol GetDeclaredLocalFunction(LocalFunctionStatementSynta
private static LocalFunctionSymbol GetDeclaredLocalFunction(Binder enclosingBinder, SyntaxToken declaredIdentifier)
{
for (var binder = enclosingBinder ; binder != null; binder = binder.Next)
for (var binder = enclosingBinder; binder != null; binder = binder.Next)
{
foreach (var localFunction in binder.LocalFunctions)
{
......@@ -929,7 +929,7 @@ public override ISymbol GetDeclaredSymbol(ArgumentSyntax declaratorSyntax, Cance
{
var elements = tupleLiteralType.TupleElements;
if(!elements.IsDefault)
if (!elements.IsDefault)
{
var idx = tupleLiteral.Arguments.IndexOf(declaratorSyntax);
return elements[idx];
......@@ -978,7 +978,7 @@ internal override IOperation GetOperationWorker(CSharpSyntaxNode node, GetOperat
break;
}
return result as IOperation;
return CSharpOperationFactory.Create(result);
}
internal override SymbolInfo GetSymbolInfoWorker(CSharpSyntaxNode node, SymbolInfoOptions options, CancellationToken cancellationToken = default(CancellationToken))
......@@ -1520,7 +1520,7 @@ private static Binder GetQueryEnclosingBinder(int position, CSharpSyntaxNode sta
}
while (node != null);
done:
done:
return GetEnclosingBinderInternalWithinRoot(AdjustStartingNodeAccordingToNewRoot(startingNode, queryClause.Syntax),
position, queryClause.Binder, queryClause.Syntax);
}
......@@ -1805,7 +1805,7 @@ protected CSharpSyntaxNode GetBindableParentNode(CSharpSyntaxNode node)
{
return null;
}
throw new ArgumentException($"The parent of {nameof(node)} must not be null unless this is a speculative semantic model.", nameof(node));
}
......
......@@ -56,18 +56,6 @@ public bool HasLocals
}
}
protected override OperationKind ExpressionKind => OperationKind.None;
public override void Accept(OperationVisitor visitor)
{
throw ExceptionUtilities.Unreachable;
}
public override TResult Accept<TArgument, TResult>(OperationVisitor<TArgument, TResult> visitor, TArgument argument)
{
throw ExceptionUtilities.Unreachable;
}
public ImmutableArray<LocalSymbol> GetLocals()
{
return (_locals == null) ? ImmutableArray<LocalSymbol>.Empty : _locals.ToImmutable();
......@@ -772,8 +760,8 @@ public override BoundNode VisitCall(BoundCall node)
private static RefKind ReceiverSpillRefKind(BoundExpression receiver)
{
return LocalRewriter.WouldBeAssignableIfUsedAsMethodReceiver(receiver) ?
RefKind.Ref :
return LocalRewriter.WouldBeAssignableIfUsedAsMethodReceiver(receiver) ?
RefKind.Ref :
RefKind.None;
}
......
......@@ -29,23 +29,5 @@ internal class PartiallyLoweredLocalFunctionReference : BoundExpression
public override BoundNode Accept(BoundTreeVisitor visitor) =>
visitor.Visit(this);
protected override OperationKind ExpressionKind
{
get
{
throw new InvalidOperationException();
}
}
public override void Accept(OperationVisitor visitor)
{
throw new InvalidOperationException();
}
public override TResult Accept<TArgument, TResult>(OperationVisitor<TArgument, TResult> visitor, TArgument argument)
{
throw new InvalidOperationException();
}
}
}
......@@ -3,6 +3,7 @@
using System;
using System.Collections.Immutable;
using System.Linq;
using System.Runtime.CompilerServices;
using Microsoft.CodeAnalysis.CSharp;
namespace Microsoft.CodeAnalysis.Semantics
......@@ -168,12 +169,12 @@ private static IPlaceholderExpression CreateBoundDeconstructValuePlaceholderOper
private static IInvocationExpression CreateBoundCallOperation(BoundCall boundCall)
{
IMethodSymbol targetMethod = boundCall.Method;
Lazy<IOperation> instance = new Lazy<IOperation>(() => ((object)boundCall.Method == null || boundCall.Method.IsStatic) ? null : boundCall.ReceiverOpt);
Lazy<IOperation> instance = new Lazy<IOperation>(() => (IOperation)Create(((object)boundCall.Method == null || boundCall.Method.IsStatic) ? null : boundCall.ReceiverOpt));
bool isVirtual = (object)boundCall.Method != null &&
boundCall.ReceiverOpt != null &&
(boundCall.Method.IsVirtual || boundCall.Method.IsAbstract || boundCall.Method.IsOverride) &&
!boundCall.ReceiverOpt.SuppressVirtualCalls;
Lazy<ImmutableArray<IArgument>> argumentsInSourceOrder = new Lazy<ImmutableArray<IArgument>>(() => ((IInvocationExpression)boundCall).ArgumentsInSourceOrder /* MANUAL */);
Lazy<ImmutableArray<IArgument>> argumentsInSourceOrder = new Lazy<ImmutableArray<IArgument>>(() => GetArgumentsInSourceOrder(boundCall));
bool isInvalid = boundCall.HasErrors;
SyntaxNode syntax = boundCall.Syntax;
ITypeSymbol type = boundCall.Type;
......@@ -192,7 +193,7 @@ private static ILocalReferenceExpression CreateBoundLocalOperation(BoundLocal bo
private static IFieldReferenceExpression CreateBoundFieldAccessOperation(BoundFieldAccess boundFieldAccess)
{
IFieldSymbol field = boundFieldAccess.FieldSymbol;
Lazy<IOperation> instance = new Lazy<IOperation>(() => boundFieldAccess.FieldSymbol.IsStatic ? null : boundFieldAccess.ReceiverOpt);
Lazy<IOperation> instance = new Lazy<IOperation>(() => (IOperation)Create(boundFieldAccess.FieldSymbol.IsStatic ? null : boundFieldAccess.ReceiverOpt));
ISymbol member = boundFieldAccess.FieldSymbol;
bool isInvalid = boundFieldAccess.HasErrors;
SyntaxNode syntax = boundFieldAccess.Syntax;
......@@ -203,7 +204,7 @@ private static IFieldReferenceExpression CreateBoundFieldAccessOperation(BoundFi
private static IPropertyReferenceExpression CreateBoundPropertyAccessOperation(BoundPropertyAccess boundPropertyAccess)
{
IPropertySymbol property = boundPropertyAccess.PropertySymbol;
Lazy<IOperation> instance = new Lazy<IOperation>(() => boundPropertyAccess.PropertySymbol.IsStatic ? null : boundPropertyAccess.ReceiverOpt);
Lazy<IOperation> instance = new Lazy<IOperation>(() => (IOperation)Create(boundPropertyAccess.PropertySymbol.IsStatic ? null : boundPropertyAccess.ReceiverOpt));
ISymbol member = boundPropertyAccess.PropertySymbol;
bool isInvalid = boundPropertyAccess.HasErrors;
SyntaxNode syntax = boundPropertyAccess.Syntax;
......@@ -214,7 +215,7 @@ private static IPropertyReferenceExpression CreateBoundPropertyAccessOperation(B
private static IIndexedPropertyReferenceExpression CreateBoundIndexerAccessOperation(BoundIndexerAccess boundIndexerAccess)
{
IPropertySymbol property = boundIndexerAccess.Indexer;
Lazy<IOperation> instance = new Lazy<IOperation>(() => boundIndexerAccess.Indexer.IsStatic ? null : boundIndexerAccess.ReceiverOpt);
Lazy<IOperation> instance = new Lazy<IOperation>(() => (IOperation)Create(boundIndexerAccess.Indexer.IsStatic ? null : boundIndexerAccess.ReceiverOpt));
ISymbol member = boundIndexerAccess.Indexer;
bool isInvalid = boundIndexerAccess.HasErrors;
SyntaxNode syntax = boundIndexerAccess.Syntax;
......@@ -225,7 +226,7 @@ private static IIndexedPropertyReferenceExpression CreateBoundIndexerAccessOpera
private static IEventReferenceExpression CreateBoundEventAccessOperation(BoundEventAccess boundEventAccess)
{
IEventSymbol @event = boundEventAccess.EventSymbol;
Lazy<IOperation> instance = new Lazy<IOperation>(() => boundEventAccess.EventSymbol.IsStatic ? null : boundEventAccess.ReceiverOpt);
Lazy<IOperation> instance = new Lazy<IOperation>(() => (IOperation)Create(boundEventAccess.EventSymbol.IsStatic ? null : boundEventAccess.ReceiverOpt));
ISymbol member = boundEventAccess.EventSymbol;
bool isInvalid = boundEventAccess.HasErrors;
SyntaxNode syntax = boundEventAccess.Syntax;
......@@ -236,8 +237,8 @@ private static IEventReferenceExpression CreateBoundEventAccessOperation(BoundEv
private static IEventAssignmentExpression CreateBoundEventAssignmentOperatorOperation(BoundEventAssignmentOperator boundEventAssignmentOperator)
{
IEventSymbol @event = boundEventAssignmentOperator.Event;
Lazy<IOperation> eventInstance = new Lazy<IOperation>(() => boundEventAssignmentOperator.Event.IsStatic ? null : boundEventAssignmentOperator.ReceiverOpt);
Lazy<IOperation> handlerValue = new Lazy<IOperation>(() => boundEventAssignmentOperator.Argument);
Lazy<IOperation> eventInstance = new Lazy<IOperation>(() => (IOperation)Create(boundEventAssignmentOperator.Event.IsStatic ? null : boundEventAssignmentOperator.ReceiverOpt));
Lazy<IOperation> handlerValue = new Lazy<IOperation>(() => (IOperation)Create(boundEventAssignmentOperator.Argument));
bool adds = boundEventAssignmentOperator.IsAddition;
bool isInvalid = boundEventAssignmentOperator.HasErrors;
SyntaxNode syntax = boundEventAssignmentOperator.Syntax;
......@@ -251,7 +252,7 @@ private static IMethodBindingExpression CreateBoundDelegateCreationExpressionOpe
bool isVirtual = (object)boundDelegateCreationExpression.MethodOpt != null &&
(boundDelegateCreationExpression.MethodOpt.IsVirtual || boundDelegateCreationExpression.MethodOpt.IsAbstract || boundDelegateCreationExpression.MethodOpt.IsOverride) &&
!boundDelegateCreationExpression.SuppressVirtualCalls;
Lazy<IOperation> instance = new Lazy<IOperation>(() => ((IMemberReferenceExpression)boundDelegateCreationExpression).Instance /* MANUAL */);
Lazy<IOperation> instance = new Lazy<IOperation>(() => GetDelegateCreationInstance(boundDelegateCreationExpression));
ISymbol member = boundDelegateCreationExpression.MethodOpt;
bool isInvalid = boundDelegateCreationExpression.HasErrors;
SyntaxNode syntax = boundDelegateCreationExpression.Argument.Syntax;
......@@ -280,7 +281,7 @@ private static ILiteralExpression CreateBoundLiteralOperation(BoundLiteral bound
private static IObjectCreationExpression CreateBoundObjectCreationExpressionOperation(BoundObjectCreationExpression boundObjectCreationExpression)
{
IMethodSymbol constructor = boundObjectCreationExpression.Constructor;
Lazy<ImmutableArray<ISymbolInitializer>> memberInitializers = new Lazy<ImmutableArray<ISymbolInitializer>>(() => ((IObjectCreationExpression)boundObjectCreationExpression).MemberInitializers /* MANUAL */);
Lazy<ImmutableArray<ISymbolInitializer>> memberInitializers = new Lazy<ImmutableArray<ISymbolInitializer>>(() => GetObjectCreationMemberInitializers(boundObjectCreationExpression));
bool isInvalid = boundObjectCreationExpression.HasErrors;
SyntaxNode syntax = boundObjectCreationExpression.Syntax;
ITypeSymbol type = boundObjectCreationExpression.Type;
......@@ -298,7 +299,7 @@ private static IUnboundLambdaExpression CreateUnboundLambdaOperation(UnboundLamb
private static ILambdaExpression CreateBoundLambdaOperation(BoundLambda boundLambda)
{
IMethodSymbol signature = boundLambda.Symbol;
Lazy<IBlockStatement> body = new Lazy<IBlockStatement>(() => boundLambda.Body);
Lazy<IBlockStatement> body = new Lazy<IBlockStatement>(() => (IBlockStatement)Create(boundLambda.Body));
bool isInvalid = boundLambda.HasErrors;
SyntaxNode syntax = boundLambda.Syntax;
ITypeSymbol type = boundLambda.Type;
......@@ -307,8 +308,8 @@ private static ILambdaExpression CreateBoundLambdaOperation(BoundLambda boundLam
}
private static IConversionExpression CreateBoundConversionOperation(BoundConversion boundConversion)
{
Lazy<IOperation> operand = new Lazy<IOperation>(() => boundConversion.Operand);
ConversionKind conversionKind = ((IConversionExpression)boundConversion).ConversionKind /* MANUAL */;
Lazy<IOperation> operand = new Lazy<IOperation>(() => (IOperation)Create(boundConversion.Operand));
ConversionKind conversionKind = GetConversionKind(boundConversion.ConversionKind);
bool isExplicit = boundConversion.ExplicitCastInCode;
bool usesOperatorMethod = boundConversion.ConversionKind == CSharp.ConversionKind.ExplicitUserDefined || boundConversion.ConversionKind == CSharp.ConversionKind.ImplicitUserDefined;
IMethodSymbol operatorMethod = boundConversion.SymbolOpt;
......@@ -320,7 +321,7 @@ private static IConversionExpression CreateBoundConversionOperation(BoundConvers
}
private static IConversionExpression CreateBoundAsOperatorOperation(BoundAsOperator boundAsOperator)
{
Lazy<IOperation> operand = new Lazy<IOperation>(() => boundAsOperator.Operand);
Lazy<IOperation> operand = new Lazy<IOperation>(() => (IOperation)Create(boundAsOperator.Operand));
ConversionKind conversionKind = Semantics.ConversionKind.TryCast;
bool isExplicit = true;
bool usesOperatorMethod = false;
......@@ -333,7 +334,7 @@ private static IConversionExpression CreateBoundAsOperatorOperation(BoundAsOpera
}
private static IIsTypeExpression CreateBoundIsOperatorOperation(BoundIsOperator boundIsOperator)
{
Lazy<IOperation> operand = new Lazy<IOperation>(() => boundIsOperator.Operand);
Lazy<IOperation> operand = new Lazy<IOperation>(() => (IOperation)Create(boundIsOperator.Operand));
ITypeSymbol isType = boundIsOperator.TargetType.Type;
bool isInvalid = boundIsOperator.HasErrors;
SyntaxNode syntax = boundIsOperator.Syntax;
......@@ -361,9 +362,9 @@ private static ITypeOfExpression CreateBoundTypeOfOperatorOperation(BoundTypeOfO
}
private static IArrayCreationExpression CreateBoundArrayCreationOperation(BoundArrayCreation boundArrayCreation)
{
ITypeSymbol elementType = ((IArrayCreationExpression)boundArrayCreation).ElementType /* MANUAL */;
Lazy<ImmutableArray<IOperation>> dimensionSizes = new Lazy<ImmutableArray<IOperation>>(() => boundArrayCreation.Bounds.As<IOperation>());
Lazy<IArrayInitializer> initializer = new Lazy<IArrayInitializer>(() => boundArrayCreation.InitializerOpt);
ITypeSymbol elementType = GetArrayCreationElementType(boundArrayCreation);
Lazy<ImmutableArray<IOperation>> dimensionSizes = new Lazy<ImmutableArray<IOperation>>(() => boundArrayCreation.Bounds.SelectAsArray(n => (IOperation)Create(n)));
Lazy<IArrayInitializer> initializer = new Lazy<IArrayInitializer>(() => (IArrayInitializer)Create(boundArrayCreation.InitializerOpt));
bool isInvalid = boundArrayCreation.HasErrors;
SyntaxNode syntax = boundArrayCreation.Syntax;
ITypeSymbol type = boundArrayCreation.Type;
......@@ -372,7 +373,7 @@ private static IArrayCreationExpression CreateBoundArrayCreationOperation(BoundA
}
private static IArrayInitializer CreateBoundArrayInitializationOperation(BoundArrayInitialization boundArrayInitialization)
{
Lazy<ImmutableArray<IOperation>> elementValues = new Lazy<ImmutableArray<IOperation>>(() => boundArrayInitialization.Initializers.As<IOperation>());
Lazy<ImmutableArray<IOperation>> elementValues = new Lazy<ImmutableArray<IOperation>>(() => boundArrayInitialization.Initializers.SelectAsArray(n => (IOperation)Create(n)));
bool isInvalid = boundArrayInitialization.HasErrors;
SyntaxNode syntax = boundArrayInitialization.Syntax;
ITypeSymbol type = boundArrayInitialization.Type;
......@@ -407,8 +408,8 @@ private static IInstanceReferenceExpression CreateBoundThisReferenceOperation(Bo
}
private static IAssignmentExpression CreateBoundAssignmentOperatorOperation(BoundAssignmentOperator boundAssignmentOperator)
{
Lazy<IOperation> target = new Lazy<IOperation>(() => boundAssignmentOperator.Left);
Lazy<IOperation> value = new Lazy<IOperation>(() => boundAssignmentOperator.Right);
Lazy<IOperation> target = new Lazy<IOperation>(() => (IOperation)Create(boundAssignmentOperator.Left));
Lazy<IOperation> value = new Lazy<IOperation>(() => (IOperation)Create(boundAssignmentOperator.Right));
bool isInvalid = boundAssignmentOperator.HasErrors;
SyntaxNode syntax = boundAssignmentOperator.Syntax;
ITypeSymbol type = boundAssignmentOperator.Type;
......@@ -418,8 +419,8 @@ private static IAssignmentExpression CreateBoundAssignmentOperatorOperation(Boun
private static ICompoundAssignmentExpression CreateBoundCompoundAssignmentOperatorOperation(BoundCompoundAssignmentOperator boundCompoundAssignmentOperator)
{
BinaryOperationKind binaryOperationKind = CSharp.Expression.DeriveBinaryOperationKind(boundCompoundAssignmentOperator.Operator.Kind);
Lazy<IOperation> target = new Lazy<IOperation>(() => boundCompoundAssignmentOperator.Left);
Lazy<IOperation> value = new Lazy<IOperation>(() => boundCompoundAssignmentOperator.Right);
Lazy<IOperation> target = new Lazy<IOperation>(() => (IOperation)Create(boundCompoundAssignmentOperator.Left));
Lazy<IOperation> value = new Lazy<IOperation>(() => (IOperation)Create(boundCompoundAssignmentOperator.Right));
bool usesOperatorMethod = (boundCompoundAssignmentOperator.Operator.Kind & BinaryOperatorKind.TypeMask) == BinaryOperatorKind.UserDefined;
IMethodSymbol operatorMethod = boundCompoundAssignmentOperator.Operator.Method;
bool isInvalid = boundCompoundAssignmentOperator.HasErrors;
......@@ -432,7 +433,7 @@ private static IIncrementExpression CreateBoundIncrementOperatorOperation(BoundI
{
UnaryOperationKind incrementOperationKind = CSharp.Expression.DeriveUnaryOperationKind(boundIncrementOperator.OperatorKind);
BinaryOperationKind binaryOperationKind = CSharp.Expression.DeriveBinaryOperationKind(incrementOperationKind);
Lazy<IOperation> target = new Lazy<IOperation>(() => boundIncrementOperator.Operand);
Lazy<IOperation> target = new Lazy<IOperation>(() => (IOperation)Create(boundIncrementOperator.Operand));
Lazy<IOperation> value = new Lazy<IOperation>(() => CreateIncrementOneLiteralExpression(boundIncrementOperator));
bool usesOperatorMethod = (boundIncrementOperator.OperatorKind & UnaryOperatorKind.TypeMask) == UnaryOperatorKind.UserDefined;
IMethodSymbol operatorMethod = boundIncrementOperator.MethodOpt;
......@@ -461,7 +462,7 @@ private static ITypeParameterObjectCreationExpression CreateBoundNewTOperation(B
private static IUnaryOperatorExpression CreateBoundUnaryOperatorOperation(BoundUnaryOperator boundUnaryOperator)
{
UnaryOperationKind unaryOperationKind = CSharp.Expression.DeriveUnaryOperationKind(boundUnaryOperator.OperatorKind);
Lazy<IOperation> operand = new Lazy<IOperation>(() => boundUnaryOperator.Operand);
Lazy<IOperation> operand = new Lazy<IOperation>(() => (IOperation)Create(boundUnaryOperator.Operand));
bool usesOperatorMethod = (boundUnaryOperator.OperatorKind & UnaryOperatorKind.TypeMask) == UnaryOperatorKind.UserDefined;
IMethodSymbol operatorMethod = boundUnaryOperator.MethodOpt;
bool isInvalid = boundUnaryOperator.HasErrors;
......@@ -473,8 +474,8 @@ private static IUnaryOperatorExpression CreateBoundUnaryOperatorOperation(BoundU
private static IBinaryOperatorExpression CreateBoundBinaryOperatorOperation(BoundBinaryOperator boundBinaryOperator)
{
BinaryOperationKind binaryOperationKind = CSharp.Expression.DeriveBinaryOperationKind(boundBinaryOperator.OperatorKind);
Lazy<IOperation> leftOperand = new Lazy<IOperation>(() => boundBinaryOperator.Left);
Lazy<IOperation> rightOperand = new Lazy<IOperation>(() => boundBinaryOperator.Right);
Lazy<IOperation> leftOperand = new Lazy<IOperation>(() => (IOperation)Create(boundBinaryOperator.Left));
Lazy<IOperation> rightOperand = new Lazy<IOperation>(() => (IOperation)Create(boundBinaryOperator.Right));
bool usesOperatorMethod = (boundBinaryOperator.OperatorKind & BinaryOperatorKind.TypeMask) == BinaryOperatorKind.UserDefined;
IMethodSymbol operatorMethod = boundBinaryOperator.MethodOpt;
bool isInvalid = boundBinaryOperator.HasErrors;
......@@ -485,9 +486,9 @@ private static IBinaryOperatorExpression CreateBoundBinaryOperatorOperation(Boun
}
private static IConditionalChoiceExpression CreateBoundConditionalOperatorOperation(BoundConditionalOperator boundConditionalOperator)
{
Lazy<IOperation> condition = new Lazy<IOperation>(() => boundConditionalOperator.Condition);
Lazy<IOperation> ifTrueValue = new Lazy<IOperation>(() => boundConditionalOperator.Consequence);
Lazy<IOperation> ifFalseValue = new Lazy<IOperation>(() => boundConditionalOperator.Alternative);
Lazy<IOperation> condition = new Lazy<IOperation>(() => (IOperation)Create(boundConditionalOperator.Condition));
Lazy<IOperation> ifTrueValue = new Lazy<IOperation>(() => (IOperation)Create(boundConditionalOperator.Consequence));
Lazy<IOperation> ifFalseValue = new Lazy<IOperation>(() => (IOperation)Create(boundConditionalOperator.Alternative));
bool isInvalid = boundConditionalOperator.HasErrors;
SyntaxNode syntax = boundConditionalOperator.Syntax;
ITypeSymbol type = boundConditionalOperator.Type;
......@@ -496,8 +497,8 @@ private static IConditionalChoiceExpression CreateBoundConditionalOperatorOperat
}
private static INullCoalescingExpression CreateBoundNullCoalescingOperatorOperation(BoundNullCoalescingOperator boundNullCoalescingOperator)
{
Lazy<IOperation> primaryOperand = new Lazy<IOperation>(() => boundNullCoalescingOperator.LeftOperand);
Lazy<IOperation> secondaryOperand = new Lazy<IOperation>(() => boundNullCoalescingOperator.RightOperand);
Lazy<IOperation> primaryOperand = new Lazy<IOperation>(() => (IOperation)Create(boundNullCoalescingOperator.LeftOperand));
Lazy<IOperation> secondaryOperand = new Lazy<IOperation>(() => (IOperation)Create(boundNullCoalescingOperator.RightOperand));
bool isInvalid = boundNullCoalescingOperator.HasErrors;
SyntaxNode syntax = boundNullCoalescingOperator.Syntax;
ITypeSymbol type = boundNullCoalescingOperator.Type;
......@@ -506,7 +507,7 @@ private static INullCoalescingExpression CreateBoundNullCoalescingOperatorOperat
}
private static IAwaitExpression CreateBoundAwaitExpressionOperation(BoundAwaitExpression boundAwaitExpression)
{
Lazy<IOperation> awaitedValue = new Lazy<IOperation>(() => boundAwaitExpression.Expression);
Lazy<IOperation> awaitedValue = new Lazy<IOperation>(() => (IOperation)Create(boundAwaitExpression.Expression));
bool isInvalid = boundAwaitExpression.HasErrors;
SyntaxNode syntax = boundAwaitExpression.Syntax;
ITypeSymbol type = boundAwaitExpression.Type;
......@@ -515,8 +516,8 @@ private static IAwaitExpression CreateBoundAwaitExpressionOperation(BoundAwaitEx
}
private static IArrayElementReferenceExpression CreateBoundArrayAccessOperation(BoundArrayAccess boundArrayAccess)
{
Lazy<IOperation> arrayReference = new Lazy<IOperation>(() => boundArrayAccess.Expression);
Lazy<ImmutableArray<IOperation>> indices = new Lazy<ImmutableArray<IOperation>>(() => boundArrayAccess.Indices.As<IOperation>());
Lazy<IOperation> arrayReference = new Lazy<IOperation>(() => (IOperation)Create(boundArrayAccess.Expression));
Lazy<ImmutableArray<IOperation>> indices = new Lazy<ImmutableArray<IOperation>>(() => boundArrayAccess.Indices.SelectAsArray(n => (IOperation)Create(n)));
bool isInvalid = boundArrayAccess.HasErrors;
SyntaxNode syntax = boundArrayAccess.Syntax;
ITypeSymbol type = boundArrayAccess.Type;
......@@ -525,7 +526,7 @@ private static IArrayElementReferenceExpression CreateBoundArrayAccessOperation(
}
private static IPointerIndirectionReferenceExpression CreateBoundPointerIndirectionOperatorOperation(BoundPointerIndirectionOperator boundPointerIndirectionOperator)
{
Lazy<IOperation> pointer = new Lazy<IOperation>(() => boundPointerIndirectionOperator.Operand);
Lazy<IOperation> pointer = new Lazy<IOperation>(() => (IOperation)Create(boundPointerIndirectionOperator.Operand));
bool isInvalid = boundPointerIndirectionOperator.HasErrors;
SyntaxNode syntax = boundPointerIndirectionOperator.Syntax;
ITypeSymbol type = boundPointerIndirectionOperator.Type;
......@@ -534,7 +535,7 @@ private static IPointerIndirectionReferenceExpression CreateBoundPointerIndirect
}
private static IAddressOfExpression CreateBoundAddressOfOperatorOperation(BoundAddressOfOperator boundAddressOfOperator)
{
Lazy<IOperation> reference = new Lazy<IOperation>(() => boundAddressOfOperator.Operand);
Lazy<IOperation> reference = new Lazy<IOperation>(() => (IOperation)Create(boundAddressOfOperator.Operand));
bool isInvalid = boundAddressOfOperator.HasErrors;
SyntaxNode syntax = boundAddressOfOperator.Syntax;
ITypeSymbol type = boundAddressOfOperator.Type;
......@@ -552,8 +553,8 @@ private static IInstanceReferenceExpression CreateBoundImplicitReceiverOperation
}
private static IConditionalAccessExpression CreateBoundConditionalAccessOperation(BoundConditionalAccess boundConditionalAccess)
{
Lazy<IOperation> conditionalValue = new Lazy<IOperation>(() => boundConditionalAccess.AccessExpression);
Lazy<IOperation> conditionalInstance = new Lazy<IOperation>(() => boundConditionalAccess.Receiver);
Lazy<IOperation> conditionalValue = new Lazy<IOperation>(() => (IOperation)Create(boundConditionalAccess.AccessExpression));
Lazy<IOperation> conditionalInstance = new Lazy<IOperation>(() => (IOperation)Create(boundConditionalAccess.Receiver));
bool isInvalid = boundConditionalAccess.HasErrors;
SyntaxNode syntax = boundConditionalAccess.Syntax;
ITypeSymbol type = boundConditionalAccess.Type;
......@@ -571,7 +572,7 @@ private static IConditionalAccessInstanceExpression CreateBoundConditionalReceiv
private static IFieldInitializer CreateBoundFieldEqualsValueOperation(BoundFieldEqualsValue boundFieldEqualsValue)
{
ImmutableArray<IFieldSymbol> initializedFields = ImmutableArray.Create<IFieldSymbol>(boundFieldEqualsValue.Field);
Lazy<IOperation> value = new Lazy<IOperation>(() => boundFieldEqualsValue.Value);
Lazy<IOperation> value = new Lazy<IOperation>(() => (IOperation)Create(boundFieldEqualsValue.Value));
OperationKind kind = OperationKind.FieldInitializerAtDeclaration;
bool isInvalid = ((IOperation)boundFieldEqualsValue.Value).IsInvalid;
SyntaxNode syntax = boundFieldEqualsValue.Syntax;
......@@ -582,7 +583,7 @@ private static IFieldInitializer CreateBoundFieldEqualsValueOperation(BoundField
private static IPropertyInitializer CreateBoundPropertyEqualsValueOperation(BoundPropertyEqualsValue boundPropertyEqualsValue)
{
IPropertySymbol initializedProperty = boundPropertyEqualsValue.Property;
Lazy<IOperation> value = new Lazy<IOperation>(() => boundPropertyEqualsValue.Value);
Lazy<IOperation> value = new Lazy<IOperation>(() => (IOperation)Create(boundPropertyEqualsValue.Value));
OperationKind kind = OperationKind.PropertyInitializerAtDeclaration;
bool isInvalid = ((IOperation)boundPropertyEqualsValue.Value).IsInvalid;
SyntaxNode syntax = boundPropertyEqualsValue.Syntax;
......@@ -593,7 +594,7 @@ private static IPropertyInitializer CreateBoundPropertyEqualsValueOperation(Boun
private static IParameterInitializer CreateBoundParameterEqualsValueOperation(BoundParameterEqualsValue boundParameterEqualsValue)
{
IParameterSymbol parameter = boundParameterEqualsValue.Parameter;
Lazy<IOperation> value = new Lazy<IOperation>(() => boundParameterEqualsValue.Value);
Lazy<IOperation> value = new Lazy<IOperation>(() => (IOperation)Create(boundParameterEqualsValue.Value));
OperationKind kind = OperationKind.ParameterInitializerAtDeclaration;
bool isInvalid = ((IOperation)boundParameterEqualsValue.Value).IsInvalid;
SyntaxNode syntax = boundParameterEqualsValue.Syntax;
......@@ -603,7 +604,7 @@ private static IParameterInitializer CreateBoundParameterEqualsValueOperation(Bo
}
private static IBlockStatement CreateBoundBlockOperation(BoundBlock boundBlock)
{
Lazy<ImmutableArray<IOperation>> statements = new Lazy<ImmutableArray<IOperation>>(() => ((IBlockStatement)boundBlock).Statements /* MANUAL */);
Lazy<ImmutableArray<IOperation>> statements = new Lazy<ImmutableArray<IOperation>>(() => GetBlockStatement(boundBlock));
ImmutableArray<ILocalSymbol> locals = boundBlock.Locals.As<ILocalSymbol>();
bool isInvalid = boundBlock.HasErrors;
SyntaxNode syntax = boundBlock.Syntax;
......@@ -633,7 +634,7 @@ private static IBranchStatement CreateBoundBreakStatementOperation(BoundBreakSta
}
private static IReturnStatement CreateBoundYieldBreakStatementOperation(BoundYieldBreakStatement boundYieldBreakStatement)
{
Lazy<IOperation> returnedValue = new Lazy<IOperation>(() => null);
Lazy<IOperation> returnedValue = new Lazy<IOperation>(() => (IOperation)Create(null));
bool isInvalid = boundYieldBreakStatement.HasErrors;
SyntaxNode syntax = boundYieldBreakStatement.Syntax;
ITypeSymbol type = null;
......@@ -660,9 +661,9 @@ private static IEmptyStatement CreateBoundNoOpStatementOperation(BoundNoOpStatem
}
private static IIfStatement CreateBoundIfStatementOperation(BoundIfStatement boundIfStatement)
{
Lazy<IOperation> condition = new Lazy<IOperation>(() => boundIfStatement.Condition);
Lazy<IOperation> ifTrueStatement = new Lazy<IOperation>(() => boundIfStatement.Consequence);
Lazy<IOperation> ifFalseStatement = new Lazy<IOperation>(() => boundIfStatement.AlternativeOpt);
Lazy<IOperation> condition = new Lazy<IOperation>(() => (IOperation)Create(boundIfStatement.Condition));
Lazy<IOperation> ifTrueStatement = new Lazy<IOperation>(() => (IOperation)Create(boundIfStatement.Consequence));
Lazy<IOperation> ifFalseStatement = new Lazy<IOperation>(() => (IOperation)Create(boundIfStatement.AlternativeOpt));
bool isInvalid = boundIfStatement.HasErrors;
SyntaxNode syntax = boundIfStatement.Syntax;
ITypeSymbol type = null;
......@@ -673,9 +674,9 @@ private static IWhileUntilLoopStatement CreateBoundWhileStatementOperation(Bound
{
bool isTopTest = true;
bool isWhile = true;
Lazy<IOperation> condition = new Lazy<IOperation>(() => boundWhileStatement.Condition);
Lazy<IOperation> condition = new Lazy<IOperation>(() => (IOperation)Create(boundWhileStatement.Condition));
LoopKind loopKind = LoopKind.WhileUntil;
Lazy<IOperation> body = new Lazy<IOperation>(() => boundWhileStatement.Body);
Lazy<IOperation> body = new Lazy<IOperation>(() => (IOperation)Create(boundWhileStatement.Body));
bool isInvalid = boundWhileStatement.HasErrors;
SyntaxNode syntax = boundWhileStatement.Syntax;
ITypeSymbol type = null;
......@@ -686,9 +687,9 @@ private static IWhileUntilLoopStatement CreateBoundDoStatementOperation(BoundDoS
{
bool isTopTest = false;
bool isWhile = true;
Lazy<IOperation> condition = new Lazy<IOperation>(() => boundDoStatement.Condition);
Lazy<IOperation> condition = new Lazy<IOperation>(() => (IOperation)Create(boundDoStatement.Condition));
LoopKind loopKind = LoopKind.WhileUntil;
Lazy<IOperation> body = new Lazy<IOperation>(() => boundDoStatement.Body);
Lazy<IOperation> body = new Lazy<IOperation>(() => (IOperation)Create(boundDoStatement.Body));
bool isInvalid = boundDoStatement.HasErrors;
SyntaxNode syntax = boundDoStatement.Syntax;
ITypeSymbol type = null;
......@@ -700,9 +701,9 @@ private static IForLoopStatement CreateBoundForStatementOperation(BoundForStatem
Lazy<ImmutableArray<IOperation>> before = new Lazy<ImmutableArray<IOperation>>(() => ToStatements(boundForStatement.Initializer));
Lazy<ImmutableArray<IOperation>> atLoopBottom = new Lazy<ImmutableArray<IOperation>>(() => ToStatements(boundForStatement.Increment));
ImmutableArray<ILocalSymbol> locals = boundForStatement.OuterLocals.As<ILocalSymbol>();
Lazy<IOperation> condition = new Lazy<IOperation>(() => boundForStatement.Condition);
Lazy<IOperation> condition = new Lazy<IOperation>(() => (IOperation)Create(boundForStatement.Condition));
LoopKind loopKind = LoopKind.For;
Lazy<IOperation> body = new Lazy<IOperation>(() => boundForStatement.Body);
Lazy<IOperation> body = new Lazy<IOperation>(() => (IOperation)Create(boundForStatement.Body));
bool isInvalid = boundForStatement.HasErrors;
SyntaxNode syntax = boundForStatement.Syntax;
ITypeSymbol type = null;
......@@ -714,9 +715,9 @@ private static IForEachLoopStatement CreateBoundForEachStatementOperation(BoundF
ILocalSymbol iterationVariable = boundForEachStatement.IterationVariables.Length == 1 ?
boundForEachStatement.IterationVariables.FirstOrDefault() :
null;
Lazy<IOperation> collection = new Lazy<IOperation>(() => boundForEachStatement.Expression);
Lazy<IOperation> collection = new Lazy<IOperation>(() => (IOperation)Create(boundForEachStatement.Expression));
LoopKind loopKind = LoopKind.ForEach;
Lazy<IOperation> body = new Lazy<IOperation>(() => boundForEachStatement.Body);
Lazy<IOperation> body = new Lazy<IOperation>(() => (IOperation)Create(boundForEachStatement.Body));
bool isInvalid = boundForEachStatement.HasErrors;
SyntaxNode syntax = boundForEachStatement.Syntax;
ITypeSymbol type = null;
......@@ -725,8 +726,8 @@ private static IForEachLoopStatement CreateBoundForEachStatementOperation(BoundF
}
private static ISwitchStatement CreateBoundSwitchStatementOperation(BoundSwitchStatement boundSwitchStatement)
{
Lazy<IOperation> value = new Lazy<IOperation>(() => boundSwitchStatement.Expression);
Lazy<ImmutableArray<ISwitchCase>> cases = new Lazy<ImmutableArray<ISwitchCase>>(() => ((ISwitchStatement)boundSwitchStatement).Cases /* MANUAL */);
Lazy<IOperation> value = new Lazy<IOperation>(() => (IOperation)Create(boundSwitchStatement.Expression));
Lazy<ImmutableArray<ISwitchCase>> cases = new Lazy<ImmutableArray<ISwitchCase>>(() => GetSwitchStatementCases(boundSwitchStatement));
bool isInvalid = boundSwitchStatement.HasErrors;
SyntaxNode syntax = boundSwitchStatement.Syntax;
ITypeSymbol type = null;
......@@ -735,8 +736,8 @@ private static ISwitchStatement CreateBoundSwitchStatementOperation(BoundSwitchS
}
private static ISingleValueCaseClause CreateBoundSwitchLabelOperation(BoundSwitchLabel boundSwitchLabel)
{
Lazy<IOperation> value = new Lazy<IOperation>(() => boundSwitchLabel.ExpressionOpt);
BinaryOperationKind equality = ((ISingleValueCaseClause)boundSwitchLabel).Equality /* MANUAL */;
Lazy<IOperation> value = new Lazy<IOperation>(() => (IOperation)Create(boundSwitchLabel.ExpressionOpt));
BinaryOperationKind equality = GetLabelEqualityKind(boundSwitchLabel);
CaseKind caseKind = boundSwitchLabel.ExpressionOpt != null ? CaseKind.SingleValue : CaseKind.Default;
bool isInvalid = boundSwitchLabel.HasErrors;
SyntaxNode syntax = boundSwitchLabel.Syntax;
......@@ -746,9 +747,9 @@ private static ISingleValueCaseClause CreateBoundSwitchLabelOperation(BoundSwitc
}
private static ITryStatement CreateBoundTryStatementOperation(BoundTryStatement boundTryStatement)
{
Lazy<IBlockStatement> body = new Lazy<IBlockStatement>(() => boundTryStatement.TryBlock);
Lazy<ImmutableArray<ICatchClause>> catches = new Lazy<ImmutableArray<ICatchClause>>(() => boundTryStatement.CatchBlocks.As<ICatchClause>());
Lazy<IBlockStatement> finallyHandler = new Lazy<IBlockStatement>(() => boundTryStatement.FinallyBlockOpt);
Lazy<IBlockStatement> body = new Lazy<IBlockStatement>(() => (IBlockStatement)Create(boundTryStatement.TryBlock));
Lazy<ImmutableArray<ICatchClause>> catches = new Lazy<ImmutableArray<ICatchClause>>(() => boundTryStatement.CatchBlocks.SelectAsArray(n => (ICatchClause)Create(n)));
Lazy<IBlockStatement> finallyHandler = new Lazy<IBlockStatement>(() => (IBlockStatement)Create(boundTryStatement.FinallyBlockOpt));
bool isInvalid = boundTryStatement.HasErrors;
SyntaxNode syntax = boundTryStatement.Syntax;
ITypeSymbol type = null;
......@@ -757,10 +758,10 @@ private static ITryStatement CreateBoundTryStatementOperation(BoundTryStatement
}
private static ICatchClause CreateBoundCatchBlockOperation(BoundCatchBlock boundCatchBlock)
{
Lazy<IBlockStatement> handler = new Lazy<IBlockStatement>(() => boundCatchBlock.Body);
Lazy<IBlockStatement> handler = new Lazy<IBlockStatement>(() => (IBlockStatement)Create(boundCatchBlock.Body));
ITypeSymbol caughtType = boundCatchBlock.ExceptionTypeOpt;
Lazy<IOperation> filter = new Lazy<IOperation>(() => boundCatchBlock.ExceptionFilterOpt);
ILocalSymbol exceptionLocal = ((ICatchClause)boundCatchBlock).ExceptionLocal /* MANUAL */;
Lazy<IOperation> filter = new Lazy<IOperation>(() => (IOperation)Create(boundCatchBlock.ExceptionFilterOpt));
ILocalSymbol exceptionLocal = (boundCatchBlock.Locals.FirstOrDefault()?.DeclarationKind == CSharp.Symbols.LocalDeclarationKind.CatchVariable) ? boundCatchBlock.Locals.FirstOrDefault() : null;
bool isInvalid = boundCatchBlock.Body.HasErrors || (boundCatchBlock.ExceptionFilterOpt != null && boundCatchBlock.ExceptionFilterOpt.HasErrors);
SyntaxNode syntax = boundCatchBlock.Syntax;
ITypeSymbol type = null;
......@@ -769,8 +770,8 @@ private static ICatchClause CreateBoundCatchBlockOperation(BoundCatchBlock bound
}
private static IFixedStatement CreateBoundFixedStatementOperation(BoundFixedStatement boundFixedStatement)
{
Lazy<IVariableDeclarationStatement> variables = new Lazy<IVariableDeclarationStatement>(() => boundFixedStatement.Declarations);
Lazy<IOperation> body = new Lazy<IOperation>(() => boundFixedStatement.Body);
Lazy<IVariableDeclarationStatement> variables = new Lazy<IVariableDeclarationStatement>(() => (IVariableDeclarationStatement)Create(boundFixedStatement.Declarations));
Lazy<IOperation> body = new Lazy<IOperation>(() => (IOperation)Create(boundFixedStatement.Body));
bool isInvalid = boundFixedStatement.HasErrors;
SyntaxNode syntax = boundFixedStatement.Syntax;
ITypeSymbol type = null;
......@@ -779,9 +780,9 @@ private static IFixedStatement CreateBoundFixedStatementOperation(BoundFixedStat
}
private static IUsingStatement CreateBoundUsingStatementOperation(BoundUsingStatement boundUsingStatement)
{
Lazy<IOperation> body = new Lazy<IOperation>(() => boundUsingStatement.Body);
Lazy<IVariableDeclarationStatement> declaration = new Lazy<IVariableDeclarationStatement>(() => boundUsingStatement.DeclarationsOpt);
Lazy<IOperation> value = new Lazy<IOperation>(() => boundUsingStatement.ExpressionOpt);
Lazy<IOperation> body = new Lazy<IOperation>(() => (IOperation)Create(boundUsingStatement.Body));
Lazy<IVariableDeclarationStatement> declaration = new Lazy<IVariableDeclarationStatement>(() => (IVariableDeclarationStatement)Create(boundUsingStatement.DeclarationsOpt));
Lazy<IOperation> value = new Lazy<IOperation>(() => (IOperation)Create(boundUsingStatement.ExpressionOpt));
bool isInvalid = boundUsingStatement.HasErrors;
SyntaxNode syntax = boundUsingStatement.Syntax;
ITypeSymbol type = null;
......@@ -790,7 +791,7 @@ private static IUsingStatement CreateBoundUsingStatementOperation(BoundUsingStat
}
private static IThrowStatement CreateBoundThrowStatementOperation(BoundThrowStatement boundThrowStatement)
{
Lazy<IOperation> thrownObject = new Lazy<IOperation>(() => boundThrowStatement.ExpressionOpt);
Lazy<IOperation> thrownObject = new Lazy<IOperation>(() => (IOperation)Create(boundThrowStatement.ExpressionOpt));
bool isInvalid = boundThrowStatement.HasErrors;
SyntaxNode syntax = boundThrowStatement.Syntax;
ITypeSymbol type = null;
......@@ -799,7 +800,7 @@ private static IThrowStatement CreateBoundThrowStatementOperation(BoundThrowStat
}
private static IReturnStatement CreateBoundReturnStatementOperation(BoundReturnStatement boundReturnStatement)
{
Lazy<IOperation> returnedValue = new Lazy<IOperation>(() => boundReturnStatement.ExpressionOpt);
Lazy<IOperation> returnedValue = new Lazy<IOperation>(() => (IOperation)Create(boundReturnStatement.ExpressionOpt));
bool isInvalid = boundReturnStatement.HasErrors;
SyntaxNode syntax = boundReturnStatement.Syntax;
ITypeSymbol type = null;
......@@ -808,7 +809,7 @@ private static IReturnStatement CreateBoundReturnStatementOperation(BoundReturnS
}
private static IReturnStatement CreateBoundYieldReturnStatementOperation(BoundYieldReturnStatement boundYieldReturnStatement)
{
Lazy<IOperation> returnedValue = new Lazy<IOperation>(() => boundYieldReturnStatement.Expression);
Lazy<IOperation> returnedValue = new Lazy<IOperation>(() => (IOperation)Create(boundYieldReturnStatement.Expression));
bool isInvalid = boundYieldReturnStatement.HasErrors;
SyntaxNode syntax = boundYieldReturnStatement.Syntax;
ITypeSymbol type = null;
......@@ -817,8 +818,8 @@ private static IReturnStatement CreateBoundYieldReturnStatementOperation(BoundYi
}
private static ILockStatement CreateBoundLockStatementOperation(BoundLockStatement boundLockStatement)
{
Lazy<IOperation> lockedObject = new Lazy<IOperation>(() => boundLockStatement.Argument);
Lazy<IOperation> body = new Lazy<IOperation>(() => boundLockStatement.Body);
Lazy<IOperation> lockedObject = new Lazy<IOperation>(() => (IOperation)Create(boundLockStatement.Argument));
Lazy<IOperation> body = new Lazy<IOperation>(() => (IOperation)Create(boundLockStatement.Body));
bool isInvalid = boundLockStatement.HasErrors;
SyntaxNode syntax = boundLockStatement.Syntax;
ITypeSymbol type = null;
......@@ -835,7 +836,7 @@ private static IInvalidStatement CreateBoundBadStatementOperation(BoundBadStatem
}
private static IVariableDeclarationStatement CreateBoundLocalDeclarationOperation(BoundLocalDeclaration boundLocalDeclaration)
{
Lazy<ImmutableArray<IVariableDeclaration>> variables = new Lazy<ImmutableArray<IVariableDeclaration>>(() => ((IVariableDeclarationStatement)boundLocalDeclaration).Variables /* MANUAL */);
Lazy<ImmutableArray<IVariableDeclaration>> variables = new Lazy<ImmutableArray<IVariableDeclaration>>(() => GetVariableDeclarationStatementVariables(boundLocalDeclaration));
bool isInvalid = boundLocalDeclaration.HasErrors;
SyntaxNode syntax = boundLocalDeclaration.Syntax;
ITypeSymbol type = null;
......@@ -844,7 +845,7 @@ private static IVariableDeclarationStatement CreateBoundLocalDeclarationOperatio
}
private static IVariableDeclarationStatement CreateBoundMultipleLocalDeclarationsOperation(BoundMultipleLocalDeclarations boundMultipleLocalDeclarations)
{
Lazy<ImmutableArray<IVariableDeclaration>> variables = new Lazy<ImmutableArray<IVariableDeclaration>>(() => ((IVariableDeclarationStatement)boundMultipleLocalDeclarations).Variables /* MANUAL */);
Lazy<ImmutableArray<IVariableDeclaration>> variables = new Lazy<ImmutableArray<IVariableDeclaration>>(() => GetVariableDeclarationStatementVariables(boundMultipleLocalDeclarations));
bool isInvalid = boundMultipleLocalDeclarations.HasErrors;
SyntaxNode syntax = boundMultipleLocalDeclarations.Syntax;
ITypeSymbol type = null;
......@@ -854,7 +855,7 @@ private static IVariableDeclarationStatement CreateBoundMultipleLocalDeclaration
private static ILabelStatement CreateBoundLabelStatementOperation(BoundLabelStatement boundLabelStatement)
{
ILabelSymbol label = boundLabelStatement.Label;
Lazy<IOperation> labeledStatement = new Lazy<IOperation>(() => null);
Lazy<IOperation> labeledStatement = new Lazy<IOperation>(() => (IOperation)Create(null));
bool isInvalid = boundLabelStatement.HasErrors;
SyntaxNode syntax = boundLabelStatement.Syntax;
ITypeSymbol type = null;
......@@ -864,7 +865,7 @@ private static ILabelStatement CreateBoundLabelStatementOperation(BoundLabelStat
private static ILabelStatement CreateBoundLabeledStatementOperation(BoundLabeledStatement boundLabeledStatement)
{
ILabelSymbol label = boundLabeledStatement.Label;
Lazy<IOperation> labeledStatement = new Lazy<IOperation>(() => boundLabeledStatement.Body);
Lazy<IOperation> labeledStatement = new Lazy<IOperation>(() => (IOperation)Create(boundLabeledStatement.Body));
bool isInvalid = boundLabeledStatement.HasErrors;
SyntaxNode syntax = boundLabeledStatement.Syntax;
ITypeSymbol type = null;
......@@ -873,7 +874,7 @@ private static ILabelStatement CreateBoundLabeledStatementOperation(BoundLabeled
}
private static IExpressionStatement CreateBoundExpressionStatementOperation(BoundExpressionStatement boundExpressionStatement)
{
Lazy<IOperation> expression = new Lazy<IOperation>(() => boundExpressionStatement.Expression);
Lazy<IOperation> expression = new Lazy<IOperation>(() => (IOperation)Create(boundExpressionStatement.Expression));
bool isInvalid = boundExpressionStatement.HasErrors;
SyntaxNode syntax = boundExpressionStatement.Syntax;
ITypeSymbol type = null;
......@@ -892,24 +893,415 @@ private static ImmutableArray<IOperation> ToStatements(BoundStatement statement)
BoundStatementList statementList = statement as BoundStatementList;
if (statementList != null)
{
return statementList.Statements.As<IOperation>();
return statementList.Statements.Select(n => Create(n)).ToImmutableArray();
}
else if (statement == null)
{
return ImmutableArray<IOperation>.Empty;
}
return ImmutableArray.Create<IOperation>(statement);
return ImmutableArray.Create<IOperation>(Create(statement));
}
private static readonly ConditionalWeakTable<BoundIncrementOperator, ILiteralExpression> s_incrementValueMappings = new ConditionalWeakTable<BoundIncrementOperator, ILiteralExpression>();
private static ILiteralExpression CreateIncrementOneLiteralExpression(BoundIncrementOperator boundIncrementOperator)
{
string text = boundIncrementOperator.Syntax.ToString();
bool isInvalid = false;
SyntaxNode syntax = boundIncrementOperator.Syntax;
ITypeSymbol type = boundIncrementOperator.Type;
Optional<object> constantValue = ConvertToOptional(Semantics.Expression.SynthesizeNumeric(boundIncrementOperator.Type, 1));
return new LiteralExpression(text, isInvalid, syntax, type, constantValue);
return s_incrementValueMappings.GetValue(boundIncrementOperator, (increment) =>
{
string text = increment.Syntax.ToString();
bool isInvalid = false;
SyntaxNode syntax = increment.Syntax;
ITypeSymbol type = increment.Type;
Optional<object> constantValue = ConvertToOptional(Semantics.Expression.SynthesizeNumeric(increment.Type, 1));
return new LiteralExpression(text, isInvalid, syntax, type, constantValue);
});
}
private static ImmutableArray<IArgument> GetArgumentsInSourceOrder(BoundCall call)
{
ArrayBuilder<IArgument> sourceOrderArguments = ArrayBuilder<IArgument>.GetInstance(call.Arguments.Length);
for (int argumentIndex = 0; argumentIndex < call.Arguments.Length; argumentIndex++)
{
IArgument argument = DeriveArgument(
call.ArgsToParamsOpt.IsDefault ? argumentIndex : call.ArgsToParamsOpt[argumentIndex],
argumentIndex,
call.Arguments,
call.ArgumentNamesOpt,
call.ArgumentRefKindsOpt,
call.Method.Parameters.As<IParameterSymbol>(),
call.Syntax);
sourceOrderArguments.Add(argument);
if (argument.ArgumentKind == ArgumentKind.ParamArray)
{
break;
}
}
return sourceOrderArguments.ToImmutableAndFree();
}
private static readonly ConditionalWeakTable<BoundExpression, IArgument> s_argumentMappings = new ConditionalWeakTable<BoundExpression, IArgument>();
private static IArgument DeriveArgument(
int parameterIndex,
int argumentIndex,
ImmutableArray<BoundExpression> boundArguments,
ImmutableArray<string> argumentNamesOpt,
ImmutableArray<RefKind> argumentRefKindsOpt,
ImmutableArray<IParameterSymbol> parameters,
SyntaxNode invocationSyntax)
{
if ((uint)argumentIndex >= (uint)boundArguments.Length)
{
// Check for an omitted argument that becomes an empty params array.
if (parameters.Length > 0)
{
IParameterSymbol lastParameter = parameters[parameters.Length - 1];
if (lastParameter.IsParams)
{
var value = CreateParamArray(lastParameter, boundArguments, argumentIndex, invocationSyntax);
return new Argument(
argumentKind: ArgumentKind.ParamArray,
parameter: lastParameter,
value: value,
inConversion: null,
outConversion: null,
isInvalid: lastParameter == null || value.IsInvalid,
syntax: value.Syntax,
type: null,
constantValue: default(Optional<object>));
}
}
// There is no supplied argument and there is no params parameter. Any action is suspect at this point.
var invalid = OperationFactory.CreateInvalidExpression(invocationSyntax);
return new Argument(
argumentKind: ArgumentKind.Positional,
parameter: null,
value: invalid,
inConversion: null,
outConversion: null,
isInvalid: true,
syntax: null,
type: null,
constantValue: default(Optional<object>));
}
return s_argumentMappings.GetValue(
boundArguments[argumentIndex],
(argument) =>
{
string nameOpt = !argumentNamesOpt.IsDefaultOrEmpty ? argumentNamesOpt[argumentIndex] : null;
IParameterSymbol parameterOpt = (uint)parameterIndex < (uint)parameters.Length ? parameters[parameterIndex] : null;
if ((object)nameOpt == null)
{
RefKind refMode = argumentRefKindsOpt.IsDefaultOrEmpty ? RefKind.None : argumentRefKindsOpt[argumentIndex];
if (refMode != RefKind.None)
{
var value = Create(argument);
return new Argument(
argumentKind: ArgumentKind.Positional,
parameter: parameterOpt,
value: value,
inConversion: null,
outConversion: null,
isInvalid: parameterOpt == null || value.IsInvalid,
syntax: argument.Syntax,
type: null,
constantValue: default(Optional<object>));
}
if (argumentIndex >= parameters.Length - 1 &&
parameters.Length > 0 &&
parameters[parameters.Length - 1].IsParams &&
// An argument that is an array of the appropriate type is not a params argument.
(boundArguments.Length > argumentIndex + 1 ||
((object)argument.Type != null && // If argument type is null, we are in an error scenario and cannot tell if it is a param array, or not.
(argument.Type.TypeKind != TypeKind.Array ||
!argument.Type.Equals((CSharp.Symbols.TypeSymbol)parameters[parameters.Length - 1].Type, TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds)))))
{
var parameter = parameters[parameters.Length - 1];
var value = CreateParamArray(parameter, boundArguments, argumentIndex, invocationSyntax);
return new Argument(
argumentKind: ArgumentKind.ParamArray,
parameter: parameter,
value: value,
inConversion: null,
outConversion: null,
isInvalid: parameter == null || value.IsInvalid,
syntax: value.Syntax,
type: null,
constantValue: default(Optional<object>));
}
else
{
var value = Create(argument);
return new Argument(
argumentKind: ArgumentKind.Positional,
parameter: parameterOpt,
value: value,
inConversion: null,
outConversion: null,
isInvalid: parameterOpt == null || value.IsInvalid,
syntax: value.Syntax,
type: null,
constantValue: default(Optional<object>));
}
}
var operation = Create(argument);
return new Argument(
argumentKind: ArgumentKind.Named,
parameter: parameterOpt,
value: operation,
inConversion: null,
outConversion: null,
isInvalid: parameterOpt == null || operation.IsInvalid,
syntax: operation.Syntax,
type: null,
constantValue: default(Optional<object>));
});
}
private static IOperation CreateParamArray(IParameterSymbol parameter, ImmutableArray<BoundExpression> boundArguments, int firstArgumentElementIndex, SyntaxNode invocationSyntax)
{
if (parameter.Type.TypeKind == TypeKind.Array)
{
IArrayTypeSymbol arrayType = (IArrayTypeSymbol)parameter.Type;
ArrayBuilder<IOperation> builder = ArrayBuilder<IOperation>.GetInstance(boundArguments.Length - firstArgumentElementIndex);
for (int index = firstArgumentElementIndex; index < boundArguments.Length; index++)
{
builder.Add(Create(boundArguments[index]));
}
var paramArrayArguments = builder.ToImmutableAndFree();
// Use the invocation syntax node if there is no actual syntax available for the argument (because the paramarray is empty.)
return OperationFactory.CreateArrayCreationExpression(arrayType, paramArrayArguments, paramArrayArguments.Length > 0 ? paramArrayArguments[0].Syntax : invocationSyntax);
}
return OperationFactory.CreateInvalidExpression(invocationSyntax);
}
private static IOperation GetDelegateCreationInstance(BoundDelegateCreationExpression expression)
{
BoundMethodGroup methodGroup = expression.Argument as BoundMethodGroup;
if (methodGroup != null)
{
return Create(methodGroup.InstanceOpt);
}
return null;
}
private static readonly ConditionalWeakTable<BoundObjectCreationExpression, object> s_memberInitializersMappings =
new ConditionalWeakTable<BoundObjectCreationExpression, object>();
private static ImmutableArray<ISymbolInitializer> GetObjectCreationMemberInitializers(BoundObjectCreationExpression expression)
{
return (ImmutableArray<ISymbolInitializer>)s_memberInitializersMappings.GetValue(expression,
objectCreationExpression =>
{
var objectInitializerExpression = expression.InitializerExpressionOpt as BoundObjectInitializerExpression;
if (objectInitializerExpression != null)
{
var builder = ArrayBuilder<ISymbolInitializer>.GetInstance(objectInitializerExpression.Initializers.Length);
foreach (var memberAssignment in objectInitializerExpression.Initializers)
{
var assignment = memberAssignment as BoundAssignmentOperator;
var leftSymbol = (assignment?.Left as BoundObjectInitializerMember)?.MemberSymbol;
if ((object)leftSymbol == null)
{
continue;
}
switch (leftSymbol.Kind)
{
case SymbolKind.Field:
{
var value = Create(assignment.Right);
builder.Add(new FieldInitializer(
ImmutableArray.Create((IFieldSymbol)leftSymbol),
value,
OperationKind.FieldInitializerInCreation,
value.IsInvalid || leftSymbol == null,
assignment.Syntax,
type: null,
constantValue: default(Optional<object>)));
break;
}
case SymbolKind.Property:
{
var value = Create(assignment.Right);
builder.Add(new PropertyInitializer(
(IPropertySymbol)leftSymbol,
value,
OperationKind.PropertyInitializerInCreation,
value.IsInvalid || leftSymbol == null,
assignment.Syntax,
type: null,
constantValue: default(Optional<object>)));
break;
}
}
}
return builder.ToImmutableAndFree();
}
return ImmutableArray<ISymbolInitializer>.Empty;
});
}
private static ConversionKind GetConversionKind(CSharp.ConversionKind kind)
{
switch (kind)
{
case CSharp.ConversionKind.ExplicitUserDefined:
case CSharp.ConversionKind.ImplicitUserDefined:
return Semantics.ConversionKind.OperatorMethod;
case CSharp.ConversionKind.ExplicitReference:
case CSharp.ConversionKind.ImplicitReference:
case CSharp.ConversionKind.Boxing:
case CSharp.ConversionKind.Unboxing:
case CSharp.ConversionKind.Identity:
return Semantics.ConversionKind.Cast;
case CSharp.ConversionKind.AnonymousFunction:
case CSharp.ConversionKind.ExplicitDynamic:
case CSharp.ConversionKind.ImplicitDynamic:
case CSharp.ConversionKind.ExplicitEnumeration:
case CSharp.ConversionKind.ImplicitEnumeration:
case CSharp.ConversionKind.ImplicitThrow:
case CSharp.ConversionKind.ImplicitTupleLiteral:
case CSharp.ConversionKind.ImplicitTuple:
case CSharp.ConversionKind.ExplicitTupleLiteral:
case CSharp.ConversionKind.ExplicitTuple:
case CSharp.ConversionKind.ExplicitNullable:
case CSharp.ConversionKind.ImplicitNullable:
case CSharp.ConversionKind.ExplicitNumeric:
case CSharp.ConversionKind.ImplicitNumeric:
case CSharp.ConversionKind.ImplicitConstant:
case CSharp.ConversionKind.IntegerToPointer:
case CSharp.ConversionKind.IntPtr:
case CSharp.ConversionKind.NullLiteral:
case CSharp.ConversionKind.NullToPointer:
case CSharp.ConversionKind.PointerToInteger:
case CSharp.ConversionKind.PointerToPointer:
case CSharp.ConversionKind.PointerToVoid:
return Semantics.ConversionKind.CSharp;
default:
return Semantics.ConversionKind.Invalid;
}
}
private static ITypeSymbol GetArrayCreationElementType(BoundArrayCreation creation)
{
IArrayTypeSymbol arrayType = creation.Type as IArrayTypeSymbol;
if ((object)arrayType != null)
{
return arrayType.ElementType;
}
return null;
}
private static readonly ConditionalWeakTable<BoundBlock, object> s_blockStatementsMappings =
new ConditionalWeakTable<BoundBlock, object>();
private static ImmutableArray<IOperation> GetBlockStatement(BoundBlock block)
{
// This is to filter out operations of kind None.
return (ImmutableArray<IOperation>)s_blockStatementsMappings.GetValue(block,
blockStatement =>
{
return blockStatement.Statements.Select(s => Create(s)).Where(s => s.Kind != OperationKind.None).ToImmutableArray();
});
}
private static readonly ConditionalWeakTable<BoundSwitchStatement, object> s_switchSectionsMappings =
new ConditionalWeakTable<BoundSwitchStatement, object>();
private static ImmutableArray<ISwitchCase> GetSwitchStatementCases(BoundSwitchStatement statement)
{
return (ImmutableArray<ISwitchCase>)s_switchSectionsMappings.GetValue(statement,
switchStatement =>
{
return switchStatement.SwitchSections.SelectAsArray(switchSection =>
{
var clauses = switchSection.SwitchLabels.Select(s => (ICaseClause)Create(s)).ToImmutableArray();
var body = switchSection.Statements.Select(s => Create(s)).ToImmutableArray();
return new SwitchCase(clauses, body, switchSection.HasErrors, switchSection.Syntax, type: null, constantValue: default(Optional<object>));
});
});
}
private static BinaryOperationKind GetLabelEqualityKind(BoundSwitchLabel label)
{
BoundExpression caseValue = label.ExpressionOpt;
if (caseValue != null)
{
switch (caseValue.Type.SpecialType)
{
case SpecialType.System_Int32:
case SpecialType.System_Int64:
case SpecialType.System_UInt32:
case SpecialType.System_UInt64:
case SpecialType.System_UInt16:
case SpecialType.System_Int16:
case SpecialType.System_SByte:
case SpecialType.System_Byte:
case SpecialType.System_Char:
return BinaryOperationKind.IntegerEquals;
case SpecialType.System_Boolean:
return BinaryOperationKind.BooleanEquals;
case SpecialType.System_String:
return BinaryOperationKind.StringEquals;
}
if (caseValue.Type.TypeKind == TypeKind.Enum)
{
return BinaryOperationKind.EnumEquals;
}
return BinaryOperationKind.Invalid;
}
// Return None for `default` case.
return BinaryOperationKind.None;
}
private static readonly ConditionalWeakTable<BoundLocalDeclaration, object> s_variablesMappings =
new ConditionalWeakTable<BoundLocalDeclaration, object>();
private static ImmutableArray<IVariableDeclaration> GetVariableDeclarationStatementVariables(BoundLocalDeclaration decl)
{
return (ImmutableArray<IVariableDeclaration>)s_variablesMappings.GetValue(decl,
declaration => ImmutableArray.Create<IVariableDeclaration>(
OperationFactory.CreateVariableDeclaration(declaration.LocalSymbol, Create(declaration.InitializerOpt), declaration.Syntax)));
}
private static readonly ConditionalWeakTable<BoundMultipleLocalDeclarations, object> s_multiVariablesMappings =
new ConditionalWeakTable<BoundMultipleLocalDeclarations, object>();
private static ImmutableArray<IVariableDeclaration> GetVariableDeclarationStatementVariables(BoundMultipleLocalDeclarations decl)
{
return (ImmutableArray<IVariableDeclaration>)s_multiVariablesMappings.GetValue(decl,
multipleDeclarations =>
multipleDeclarations.LocalDeclarations.SelectAsArray(declaration =>
OperationFactory.CreateVariableDeclaration(declaration.LocalSymbol, Create(declaration.InitializerOpt), declaration.Syntax)));
}
}
}
......@@ -43,7 +43,6 @@
<Compile Include="Operations\BranchKind.cs" />
<Compile Include="Operations\CaseKind.cs" />
<Compile Include="Operations\ConversionKind.cs" />
<Compile Include="Operations\Expressions.cs" />
<Compile Include="Operations\IAddressOfExpression.cs" />
<Compile Include="Operations\IArgument.cs" />
<Compile Include="Operations\IArrayCreationExpression.cs" />
......@@ -131,6 +130,7 @@
<Compile Include="Operations\IWhileUntilLoopStatement.cs" />
<Compile Include="Operations\IWithStatement.cs" />
<Compile Include="Operations\LoopKind.cs" />
<Compile Include="Operations\OperationFactory.cs" />
<Compile Include="Operations\SimpleBinaryOperationKind.cs" />
<Compile Include="Operations\SimpleUnaryOperationKind.cs" />
<Compile Include="Operations\SyntheticLocalKind.cs" />
......@@ -403,7 +403,6 @@
<Compile Include="Compilation\SemanticModel.cs" />
<Compile Include="Compilation\SourceReferenceResolver.cs" />
<Compile Include="Compilation\SpeculativeBindingOption.cs" />
<Compile Include="Operations\Statement.cs" />
<Compile Include="Compilation\SubsystemVersion.cs" />
<Compile Include="Compilation\SymbolInfo.cs" />
<Compile Include="Compilation\TypeInfo.cs" />
......
......@@ -1913,12 +1913,19 @@ public override void Accept(OperationVisitor visitor)
/// </summary>
internal sealed partial class IndexedPropertyReferenceExpression : PropertyReferenceExpressionBase, IHasArgumentsExpression, IIndexedPropertyReferenceExpression
{
public IndexedPropertyReferenceExpression(IPropertySymbol property, IOperation instance, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) :
public IndexedPropertyReferenceExpression(IPropertySymbol property, IOperation instance, ISymbol member, ImmutableArray<IArgument> argumentsInParameterOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) :
base(property, member, OperationKind.IndexedPropertyReferenceExpression, isInvalid, syntax, type, constantValue)
{
ArgumentsInParameterOrder = argumentsInParameterOrder;
Instance = instance ?? throw new System.ArgumentNullException("instance");
}
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public ImmutableArray<IArgument> ArgumentsInParameterOrder { get; }
/// <summary>
/// Instance of the type. Null if the reference is to a static/shared member.
/// </summary>
public override IOperation Instance { get; }
......@@ -1938,11 +1945,20 @@ public override void Accept(OperationVisitor visitor)
internal sealed partial class LazyIndexedPropertyReferenceExpression : PropertyReferenceExpressionBase, IHasArgumentsExpression, IIndexedPropertyReferenceExpression
{
private readonly Lazy<IOperation> _lazyInstance;
private readonly Lazy<ImmutableArray<IArgument>> _lazyArgumentsInParameterOrder;
public LazyIndexedPropertyReferenceExpression(IPropertySymbol property, Lazy<IOperation> instance, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) : base(property, member, OperationKind.IndexedPropertyReferenceExpression, isInvalid, syntax, type, constantValue)
public LazyIndexedPropertyReferenceExpression(IPropertySymbol property, Lazy<IOperation> instance, ISymbol member, Lazy<ImmutableArray<IArgument>> argumentsInParameterOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) : base(property, member, OperationKind.IndexedPropertyReferenceExpression, isInvalid, syntax, type, constantValue)
{
_lazyArgumentsInParameterOrder = argumentsInParameterOrder;
_lazyInstance = instance ?? throw new System.ArgumentNullException("instance");
}
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public ImmutableArray<IArgument> ArgumentsInParameterOrder => _lazyArgumentsInParameterOrder.Value;
/// <summary>
/// Instance of the type. Null if the reference is to a static/shared member.
/// </summary>
......@@ -2051,6 +2067,12 @@ internal abstract partial class InvocationExpressionBase : Operation, IHasArgume
/// unless supplied in source.
/// </summary>
public abstract ImmutableArray<IArgument> ArgumentsInSourceOrder { get; }
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public abstract ImmutableArray<IArgument> ArgumentsInParameterOrder { get; }
public override void Accept(OperationVisitor visitor)
{
visitor.VisitInvocationExpression(this);
......@@ -2066,11 +2088,12 @@ public override void Accept(OperationVisitor visitor)
/// </summary>
internal sealed partial class InvocationExpression : InvocationExpressionBase, IHasArgumentsExpression, IInvocationExpression
{
public InvocationExpression(IMethodSymbol targetMethod, IOperation instance, bool isVirtual, ImmutableArray<IArgument> argumentsInSourceOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) :
public InvocationExpression(IMethodSymbol targetMethod, IOperation instance, bool isVirtual, ImmutableArray<IArgument> argumentsInSourceOrder, ImmutableArray<IArgument> argumentsInParameterOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) :
base(targetMethod, isVirtual, isInvalid, syntax, type, constantValue)
{
Instance = instance ?? throw new System.ArgumentNullException("instance");
ArgumentsInSourceOrder = argumentsInSourceOrder;
ArgumentsInParameterOrder = argumentsInParameterOrder;
}
/// <summary>
/// 'This' or 'Me' instance to be supplied to the method, or null if the method is static.
......@@ -2082,6 +2105,12 @@ internal sealed partial class InvocationExpression : InvocationExpressionBase, I
/// unless supplied in source.
/// </summary>
public override ImmutableArray<IArgument> ArgumentsInSourceOrder { get; }
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public override ImmutableArray<IArgument> ArgumentsInParameterOrder { get; }
}
/// <summary>
......@@ -2091,11 +2120,13 @@ internal sealed partial class LazyInvocationExpression : InvocationExpressionBas
{
private readonly Lazy<IOperation> _lazyInstance;
private readonly Lazy<ImmutableArray<IArgument>> _lazyArgumentsInSourceOrder;
private readonly Lazy<ImmutableArray<IArgument>> _lazyArgumentsInParameterOrder;
public LazyInvocationExpression(IMethodSymbol targetMethod, Lazy<IOperation> instance, bool isVirtual, Lazy<ImmutableArray<IArgument>> argumentsInSourceOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) : base(targetMethod, isVirtual, isInvalid, syntax, type, constantValue)
public LazyInvocationExpression(IMethodSymbol targetMethod, Lazy<IOperation> instance, bool isVirtual, Lazy<ImmutableArray<IArgument>> argumentsInSourceOrder, Lazy<ImmutableArray<IArgument>> argumentsInParameterOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) : base(targetMethod, isVirtual, isInvalid, syntax, type, constantValue)
{
_lazyInstance = instance ?? throw new System.ArgumentNullException("instance");
_lazyArgumentsInSourceOrder = argumentsInSourceOrder;
_lazyArgumentsInParameterOrder = argumentsInParameterOrder;
}
/// <summary>
/// 'This' or 'Me' instance to be supplied to the method, or null if the method is static.
......@@ -2108,6 +2139,13 @@ public LazyInvocationExpression(IMethodSymbol targetMethod, Lazy<IOperation> ins
/// unless supplied in source.
/// </summary>
public override ImmutableArray<IArgument> ArgumentsInSourceOrder => _lazyArgumentsInSourceOrder.Value;
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public override ImmutableArray<IArgument> ArgumentsInParameterOrder => _lazyArgumentsInParameterOrder.Value;
}
/// <summary>
......@@ -2677,6 +2715,12 @@ internal abstract partial class ObjectCreationExpressionBase : Operation, IHasAr
/// Explicitly-specified member initializers.
/// </summary>
public abstract ImmutableArray<ISymbolInitializer> MemberInitializers { get; }
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public abstract ImmutableArray<IArgument> ArgumentsInParameterOrder { get; }
public override void Accept(OperationVisitor visitor)
{
visitor.VisitObjectCreationExpression(this);
......@@ -2692,15 +2736,22 @@ public override void Accept(OperationVisitor visitor)
/// </summary>
internal sealed partial class ObjectCreationExpression : ObjectCreationExpressionBase, IHasArgumentsExpression, IObjectCreationExpression
{
public ObjectCreationExpression(IMethodSymbol constructor, ImmutableArray<ISymbolInitializer> memberInitializers, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) :
public ObjectCreationExpression(IMethodSymbol constructor, ImmutableArray<ISymbolInitializer> memberInitializers, ImmutableArray<IArgument> argumentsInParameterOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) :
base(constructor, isInvalid, syntax, type, constantValue)
{
MemberInitializers = memberInitializers;
ArgumentsInParameterOrder = argumentsInParameterOrder;
}
/// <summary>
/// Explicitly-specified member initializers.
/// </summary>
public override ImmutableArray<ISymbolInitializer> MemberInitializers { get; }
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public override ImmutableArray<IArgument> ArgumentsInParameterOrder { get; }
}
/// <summary>
......@@ -2709,15 +2760,24 @@ internal sealed partial class ObjectCreationExpression : ObjectCreationExpressio
internal sealed partial class LazyObjectCreationExpression : ObjectCreationExpressionBase, IHasArgumentsExpression, IObjectCreationExpression
{
private readonly Lazy<ImmutableArray<ISymbolInitializer>> _lazyMemberInitializers;
private readonly Lazy<ImmutableArray<IArgument>> _lazyArgumentsInParameterOrder;
public LazyObjectCreationExpression(IMethodSymbol constructor, Lazy<ImmutableArray<ISymbolInitializer>> memberInitializers, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) : base(constructor, isInvalid, syntax, type, constantValue)
public LazyObjectCreationExpression(IMethodSymbol constructor, Lazy<ImmutableArray<ISymbolInitializer>> memberInitializers, Lazy<ImmutableArray<IArgument>> argumentsInParameterOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) : base(constructor, isInvalid, syntax, type, constantValue)
{
_lazyMemberInitializers = memberInitializers;
_lazyArgumentsInParameterOrder = argumentsInParameterOrder;
}
/// <summary>
/// Explicitly-specified member initializers.
/// </summary>
public override ImmutableArray<ISymbolInitializer> MemberInitializers => _lazyMemberInitializers.Value;
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public override ImmutableArray<IArgument> ArgumentsInParameterOrder => _lazyArgumentsInParameterOrder.Value;
}
/// <summary>
......
// 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;
using System.Linq;
namespace Microsoft.CodeAnalysis.Semantics
{
internal sealed partial class ConditionalChoiceExpression : IConditionalChoiceExpression
{
public ConditionalChoiceExpression(IOperation condition, IOperation ifTrue, IOperation ifFalse, ITypeSymbol resultType, SyntaxNode syntax) :
this(condition,
ifTrue,
ifFalse,
IsInvalidOperation(condition, ifTrue, ifFalse, resultType),
syntax,
resultType,
default(Optional<object>))
{
}
private static bool IsInvalidOperation(IOperation condition, IOperation ifTrue, IOperation ifFalse, ITypeSymbol resultType)
{
return (condition == null || condition.IsInvalid || ifTrue == null || ifTrue.IsInvalid || ifFalse == null || ifFalse.IsInvalid || resultType == null);
}
}
internal sealed partial class ExpressionStatement : IExpressionStatement
{
public ExpressionStatement(IOperation target, IOperation value, SyntaxNode syntax) :
this(new AssignmentExpression(target, value, IsInvalidOperation(target, value), syntax, target.Type, default(Optional<object>)),
syntax)
{
}
public ExpressionStatement(IOperation target, IOperation value, BinaryOperationKind binaryOperationKind, IMethodSymbol operatorMethod, SyntaxNode syntax) :
this(new CompoundAssignmentExpression(
binaryOperationKind,
target,
value,
operatorMethod != null,
operatorMethod,
IsInvalidOperation(target, value),
syntax,
target.Type,
default(Optional<object>)),
syntax)
{
}
private ExpressionStatement(IOperation expression, SyntaxNode syntax) :
this(expression, expression.IsInvalid, syntax, type: null, constantValue: default(Optional<object>))
{
}
private static bool IsInvalidOperation(IOperation target, IOperation value)
{
return target == null || target.IsInvalid || value == null || value.IsInvalid;
}
}
internal sealed partial class LiteralExpression : ILiteralExpression
{
public LiteralExpression(long value, ITypeSymbol resultType, SyntaxNode syntax) :
this(value.ToString(), isInvalid: false, syntax: syntax, type: resultType, constantValue: new Optional<object>(value))
{
}
public LiteralExpression(ConstantValue value, ITypeSymbol resultType, SyntaxNode syntax) :
this(value.GetValueToDisplay(), value.IsBad, syntax, resultType, new Optional<object>(value.Value))
{
}
}
internal sealed partial class BinaryOperatorExpression : IBinaryOperatorExpression
{
public BinaryOperatorExpression(BinaryOperationKind binaryOperationKind, IOperation left, IOperation right, ITypeSymbol resultType, SyntaxNode syntax) :
this(binaryOperationKind, left, right,
usesOperatorMethod: false, operatorMethod: null,
isInvalid: IsInvalidOperation(binaryOperationKind, left, right, resultType),
syntax: syntax, type: resultType, constantValue: default(Optional<object>))
{
}
private static bool IsInvalidOperation(BinaryOperationKind binaryOperationKind, IOperation left, IOperation right, ITypeSymbol type)
{
return left == null || left.IsInvalid || right == null
|| right.IsInvalid || binaryOperationKind == BinaryOperationKind.Invalid || type == null;
}
}
internal sealed partial class ArrayCreationExpression : IArrayCreationExpression
{
public ArrayCreationExpression(IArrayTypeSymbol arrayType, ImmutableArray<IOperation> elementValues, SyntaxNode syntax) :
this(arrayType.ElementType,
ImmutableArray.Create<IOperation>(new LiteralExpression(elementValues.Count(), resultType: null, syntax: syntax)),
new ArrayInitializer(elementValues, elementValues.Any(v => v.IsInvalid), syntax, arrayType, default(Optional<object>)),
syntax,
arrayType,
default(Optional<object>))
{
}
private ArrayCreationExpression(ITypeSymbol elementType, ImmutableArray<IOperation> dimensionSizes, IArrayInitializer initializer, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) :
this(elementType, dimensionSizes, initializer, initializer.IsInvalid, syntax, type, constantValue)
{
}
}
internal partial class InvalidExpression : IInvalidExpression
{
public InvalidExpression(SyntaxNode syntax) :
this(isInvalid: true, syntax: syntax, type: null, constantValue: default(Optional<object>))
{
}
}
}
......@@ -6,12 +6,6 @@ namespace Microsoft.CodeAnalysis.Semantics
{
internal partial class IndexedPropertyReferenceExpression : IHasArgumentsExpression
{
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public ImmutableArray<IArgument> ArgumentsInParameterOrder { get; }
/// <summary>
/// Find the argument supplied for a given parameter of the target method.
/// </summary>
......@@ -19,18 +13,12 @@ internal partial class IndexedPropertyReferenceExpression : IHasArgumentsExpress
/// <returns>Argument corresponding to the parameter.</returns>
public IArgument GetArgumentMatchingParameter(IParameterSymbol parameter)
{
throw new System.NotImplementedException();
return this.ArgumentsInParameterOrder[parameter.Ordinal];
}
}
internal partial class LazyIndexedPropertyReferenceExpression : IHasArgumentsExpression
{
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public ImmutableArray<IArgument> ArgumentsInParameterOrder { get; }
/// <summary>
/// Find the argument supplied for a given parameter of the target method.
/// </summary>
......@@ -38,7 +26,7 @@ internal partial class LazyIndexedPropertyReferenceExpression : IHasArgumentsExp
/// <returns>Argument corresponding to the parameter.</returns>
public IArgument GetArgumentMatchingParameter(IParameterSymbol parameter)
{
throw new System.NotImplementedException();
return this.ArgumentsInParameterOrder[parameter.Ordinal];
}
}
}
......@@ -6,12 +6,6 @@ namespace Microsoft.CodeAnalysis.Semantics
{
internal partial class InvocationExpressionBase : IHasArgumentsExpression
{
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public ImmutableArray<IArgument> ArgumentsInParameterOrder { get; }
/// <summary>
/// Find the argument supplied for a given parameter of the target method.
/// </summary>
......@@ -19,7 +13,7 @@ internal partial class InvocationExpressionBase : IHasArgumentsExpression
/// <returns>Argument corresponding to the parameter.</returns>
public IArgument GetArgumentMatchingParameter(IParameterSymbol parameter)
{
throw new System.NotImplementedException();
return this.ArgumentsInParameterOrder[parameter.Ordinal];
}
}
}
......@@ -6,12 +6,6 @@ namespace Microsoft.CodeAnalysis.Semantics
{
internal partial class ObjectCreationExpressionBase : IHasArgumentsExpression
{
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public ImmutableArray<IArgument> ArgumentsInParameterOrder { get; }
/// <summary>
/// Find the argument supplied for a given parameter of the target method.
/// </summary>
......@@ -19,7 +13,7 @@ internal partial class ObjectCreationExpressionBase : IHasArgumentsExpression
/// <returns>Argument corresponding to the parameter.</returns>
public IArgument GetArgumentMatchingParameter(IParameterSymbol parameter)
{
throw new System.NotImplementedException();
return this.ArgumentsInParameterOrder[parameter.Ordinal];
}
}
}
// 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;
using System.Linq;
namespace Microsoft.CodeAnalysis.Semantics
{
internal static class OperationFactory
{
public static VariableDeclaration CreateVariableDeclaration(ILocalSymbol variable, IOperation initialValue, SyntaxNode syntax)
{
return new VariableDeclaration(
variable,
initialValue,
variable == null || (initialValue != null && initialValue.IsInvalid),
syntax,
type: null,
constantValue: default(Optional<object>));
}
public static ConditionalChoiceExpression CreateConditionalChoiceExpression(IOperation condition, IOperation ifTrue, IOperation ifFalse, ITypeSymbol resultType, SyntaxNode syntax)
{
var isInvalid = (condition == null || condition.IsInvalid || ifTrue == null || ifTrue.IsInvalid || ifFalse == null || ifFalse.IsInvalid || resultType == null);
return new ConditionalChoiceExpression(
condition,
ifTrue,
ifFalse,
isInvalid,
syntax,
resultType,
default(Optional<object>));
}
public static ExpressionStatement CreateAssignmentExpressionStatement(IOperation target, IOperation value, SyntaxNode syntax)
{
var isInvalid = target == null || target.IsInvalid || value == null || value.IsInvalid;
var expression = new AssignmentExpression(target, value, isInvalid, syntax, target.Type, default(Optional<object>));
return new ExpressionStatement(expression, expression.IsInvalid, syntax, type: null, constantValue: default(Optional<object>));
}
public static ExpressionStatement CreateCompoundAssignmentExpressionStatement(
IOperation target, IOperation value, BinaryOperationKind binaryOperationKind, IMethodSymbol operatorMethod, SyntaxNode syntax)
{
var isInvalid = target == null || target.IsInvalid || value == null || value.IsInvalid;
var expression = new CompoundAssignmentExpression(
binaryOperationKind,
target,
value,
operatorMethod != null,
operatorMethod,
isInvalid,
syntax,
target.Type,
default(Optional<object>));
return new ExpressionStatement(expression, expression.IsInvalid, syntax, type: null, constantValue: default(Optional<object>));
}
public static LiteralExpression CreateLiteralExpression(long value, ITypeSymbol resultType, SyntaxNode syntax)
{
return new LiteralExpression(value.ToString(), isInvalid: false, syntax: syntax, type: resultType, constantValue: new Optional<object>(value));
}
public static LiteralExpression CreateLiteralExpression(ConstantValue value, ITypeSymbol resultType, SyntaxNode syntax)
{
return new LiteralExpression(value.GetValueToDisplay(), value.IsBad, syntax, resultType, new Optional<object>(value.Value));
}
public static BinaryOperatorExpression CreateBinaryOperatorExpression(
BinaryOperationKind binaryOperationKind, IOperation left, IOperation right, ITypeSymbol resultType, SyntaxNode syntax)
{
var isInvalid = left == null || left.IsInvalid || right == null || right.IsInvalid || binaryOperationKind == BinaryOperationKind.Invalid || resultType == null;
return new BinaryOperatorExpression(
binaryOperationKind, left, right,
usesOperatorMethod: false, operatorMethod: null,
isInvalid: isInvalid, syntax: syntax, type: resultType, constantValue: default(Optional<object>));
}
public static ArrayCreationExpression CreateArrayCreationExpression(
IArrayTypeSymbol arrayType, ImmutableArray<IOperation> elementValues, SyntaxNode syntax)
{
var initializer = new ArrayInitializer(elementValues, elementValues.Any(v => v.IsInvalid), syntax, arrayType, default(Optional<object>));
return new ArrayCreationExpression(
arrayType.ElementType,
ImmutableArray.Create<IOperation>(CreateLiteralExpression(elementValues.Count(), resultType: null, syntax: syntax)),
initializer,
initializer.IsInvalid,
syntax,
arrayType,
default(Optional<object>));
}
public static InvalidExpression CreateInvalidExpression(SyntaxNode syntax)
{
return new InvalidExpression(isInvalid: true, syntax: syntax, type: null, constantValue: default(Optional<object>));
}
}
}
\ No newline at end of file
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.CodeAnalysis.Semantics
{
internal partial class VariableDeclaration : IVariableDeclaration
{
public VariableDeclaration(ILocalSymbol variable, IOperation initialValue, SyntaxNode syntax) :
this(variable,
initialValue,
variable == null || (initialValue != null && initialValue.IsInvalid),
syntax,
type: null,
constantValue: default(Optional<object>))
{
}
}
}
\ No newline at end of file
......@@ -58,7 +58,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End If
End If
Return New InvalidExpression(parent.Syntax)
Return OperationFactory.CreateInvalidExpression(parent.Syntax)
End Function
End Class
......
......@@ -569,7 +569,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End If
Dim stepOperand As IOperation = If(stepValue.IsConstant, DirectCast(stepValue, IOperation), New Temporary(SyntheticLocalKind.ForLoopStepValue, BoundFor, stepValue))
statements.Add(New ExpressionStatement(controlReference, stepOperand, Semantics.Expression.DeriveAdditionKind(controlType), Nothing, stepValue.Syntax))
statements.Add(OperationFactory.CreateCompoundAssignmentExpressionStatement(controlReference, stepOperand, Semantics.Expression.DeriveAdditionKind(controlType), Nothing, stepValue.Syntax))
End If
End If
......@@ -592,17 +592,17 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
' ControlVariable = InitialValue
Dim controlReference As IOperation = BoundFor.ControlVariable
If controlReference IsNot Nothing Then
statements.Add(New ExpressionStatement(controlReference, BoundFor.InitialValue, BoundFor.InitialValue.Syntax))
statements.Add(OperationFactory.CreateAssignmentExpressionStatement(controlReference, BoundFor.InitialValue, BoundFor.InitialValue.Syntax))
End If
' T0 = LimitValue
If Not Me.LimitValue.IsConstant Then
statements.Add(New ExpressionStatement(New Temporary(SyntheticLocalKind.ForLoopLimitValue, BoundFor, BoundFor.LimitValue), BoundFor.LimitValue, BoundFor.LimitValue.Syntax))
statements.Add(OperationFactory.CreateAssignmentExpressionStatement(New Temporary(SyntheticLocalKind.ForLoopLimitValue, BoundFor, BoundFor.LimitValue), BoundFor.LimitValue, BoundFor.LimitValue.Syntax))
End If
' T1 = StepValue
If BoundFor.StepValue IsNot Nothing AndAlso Not BoundFor.StepValue.IsConstant Then
statements.Add(New ExpressionStatement(New Temporary(SyntheticLocalKind.ForLoopStepValue, BoundFor, BoundFor.StepValue), BoundFor.StepValue, BoundFor.StepValue.Syntax))
statements.Add(OperationFactory.CreateAssignmentExpressionStatement(New Temporary(SyntheticLocalKind.ForLoopStepValue, BoundFor, BoundFor.StepValue), BoundFor.StepValue, BoundFor.StepValue.Syntax))
End If
Return statements.ToImmutableAndFree()
......@@ -640,25 +640,25 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
' Either ControlVariable <= LimitValue or ControlVariable >= LimitValue, depending on whether the step value is negative.
Dim relationalCode As BinaryOperationKind = DeriveBinaryOperationKind(If(BoundFor.StepValue IsNot Nothing AndAlso BoundFor.StepValue.ConstantValueOpt.IsNegativeNumeric, BinaryOperatorKind.GreaterThanOrEqual, BinaryOperatorKind.LessThanOrEqual), controlVariable)
Return New BinaryOperatorExpression(relationalCode, controlVariable, limitValue, booleanType, limitValue.Syntax)
Return OperationFactory.CreateBinaryOperatorExpression(relationalCode, controlVariable, limitValue, booleanType, limitValue.Syntax)
Else
' If(StepValue >= 0, ControlVariable <= LimitValue, ControlVariable >= LimitValue)
Dim stepValue As IOperation = New Temporary(SyntheticLocalKind.ForLoopStepValue, BoundFor, BoundFor.StepValue)
Dim stepRelationalCode As BinaryOperationKind = DeriveBinaryOperationKind(BinaryOperatorKind.GreaterThanOrEqual, BoundFor.StepValue)
Dim stepCondition As IOperation = New BinaryOperatorExpression(stepRelationalCode,
Dim stepCondition As IOperation = OperationFactory.CreateBinaryOperatorExpression(stepRelationalCode,
stepValue,
New LiteralExpression(Semantics.Expression.SynthesizeNumeric(stepValue.Type, 0), BoundFor.StepValue.Type, BoundFor.StepValue.Syntax),
OperationFactory.CreateLiteralExpression(Semantics.Expression.SynthesizeNumeric(stepValue.Type, 0), BoundFor.StepValue.Type, BoundFor.StepValue.Syntax),
booleanType,
BoundFor.StepValue.Syntax)
Dim positiveStepRelationalCode As BinaryOperationKind = DeriveBinaryOperationKind(BinaryOperatorKind.LessThanOrEqual, controlVariable)
Dim positiveStepCondition As IOperation = New BinaryOperatorExpression(positiveStepRelationalCode, controlVariable, limitValue, booleanType, limitValue.Syntax)
Dim positiveStepCondition As IOperation = OperationFactory.CreateBinaryOperatorExpression(positiveStepRelationalCode, controlVariable, limitValue, booleanType, limitValue.Syntax)
Dim negativeStepRelationalCode As BinaryOperationKind = DeriveBinaryOperationKind(BinaryOperatorKind.GreaterThanOrEqual, controlVariable)
Dim negativeStepCondition As IOperation = New BinaryOperatorExpression(negativeStepRelationalCode, controlVariable, limitValue, booleanType, limitValue.Syntax)
Dim negativeStepCondition As IOperation = OperationFactory.CreateBinaryOperatorExpression(negativeStepRelationalCode, controlVariable, limitValue, booleanType, limitValue.Syntax)
Return New ConditionalChoiceExpression(stepCondition, positiveStepCondition, negativeStepCondition, booleanType, limitValue.Syntax)
Return OperationFactory.CreateConditionalChoiceExpression(stepCondition, positiveStepCondition, negativeStepCondition, booleanType, limitValue.Syntax)
End If
End If
End Function)
......@@ -1058,11 +1058,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
For Each base In dimStatement.LocalDeclarations
If base.Kind = BoundKind.LocalDeclaration Then
Dim declaration = DirectCast(base, BoundLocalDeclaration)
builder.Add(New VariableDeclaration(declaration.LocalSymbol, declaration.InitializerOpt, declaration.Syntax))
builder.Add(OperationFactory.CreateVariableDeclaration(declaration.LocalSymbol, declaration.InitializerOpt, declaration.Syntax))
ElseIf base.Kind = BoundKind.AsNewLocalDeclarations Then
Dim asNewDeclarations = DirectCast(base, BoundAsNewLocalDeclarations)
For Each asNewDeclaration In asNewDeclarations.LocalDeclarations
builder.Add(New VariableDeclaration(asNewDeclaration.LocalSymbol, asNewDeclarations.Initializer, asNewDeclaration.Syntax))
builder.Add(OperationFactory.CreateVariableDeclaration(asNewDeclaration.LocalSymbol, asNewDeclarations.Initializer, asNewDeclaration.Syntax))
Next
End If
Next
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册