提交 7593dfa9 编写于 作者: M Manish Vasani

Address review feedback from the IOperation API review meeting

Addresses Preview and Documentation items from #22719
上级 53a2153c
......@@ -302,7 +302,7 @@ private IInvocationExpression CreateBoundCallOperation(BoundCall boundCall)
boundCall.ReceiverOpt != null &&
(boundCall.Method.IsVirtual || boundCall.Method.IsAbstract || boundCall.Method.IsOverride) &&
!boundCall.ReceiverOpt.SuppressVirtualCalls;
Lazy<ImmutableArray<IArgument>> argumentsInEvaluationOrder = new Lazy<ImmutableArray<IArgument>>(() =>
Lazy<ImmutableArray<IArgument>> arguments = new Lazy<ImmutableArray<IArgument>>(() =>
{
return DeriveArguments(
boundCall,
......@@ -322,7 +322,7 @@ private IInvocationExpression CreateBoundCallOperation(BoundCall boundCall)
ITypeSymbol type = boundCall.Type;
Optional<object> constantValue = ConvertToOptional(boundCall.ConstantValue);
bool isImplicit = boundCall.WasCompilerGenerated;
return new LazyInvocationExpression(targetMethod, instance, isVirtual, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyInvocationExpression(targetMethod, instance, isVirtual, arguments, _semanticModel, syntax, type, constantValue, isImplicit);
}
private IOperation CreateBoundLocalOperation(BoundLocal boundLocal)
......@@ -366,19 +366,19 @@ private IPropertyReferenceExpression CreateBoundPropertyAccessOperation(BoundPro
{
IPropertySymbol property = boundPropertyAccess.PropertySymbol;
Lazy<IOperation> instance = new Lazy<IOperation>(() => Create(boundPropertyAccess.PropertySymbol.IsStatic ? null : boundPropertyAccess.ReceiverOpt));
Lazy<ImmutableArray<IArgument>> argumentsInEvaluationOrder = new Lazy<ImmutableArray<IArgument>>(() => ImmutableArray<IArgument>.Empty);
Lazy<ImmutableArray<IArgument>> arguments = new Lazy<ImmutableArray<IArgument>>(() => ImmutableArray<IArgument>.Empty);
SyntaxNode syntax = boundPropertyAccess.Syntax;
ITypeSymbol type = boundPropertyAccess.Type;
Optional<object> constantValue = ConvertToOptional(boundPropertyAccess.ConstantValue);
bool isImplicit = boundPropertyAccess.WasCompilerGenerated;
return new LazyPropertyReferenceExpression(property, instance, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyPropertyReferenceExpression(property, instance, arguments, _semanticModel, syntax, type, constantValue, isImplicit);
}
private IPropertyReferenceExpression CreateBoundIndexerAccessOperation(BoundIndexerAccess boundIndexerAccess)
{
IPropertySymbol property = boundIndexerAccess.Indexer;
Lazy<IOperation> instance = new Lazy<IOperation>(() => Create(boundIndexerAccess.Indexer.IsStatic ? null : boundIndexerAccess.ReceiverOpt));
Lazy<ImmutableArray<IArgument>> argumentsInEvaluationOrder = new Lazy<ImmutableArray<IArgument>>(() =>
Lazy<ImmutableArray<IArgument>> arguments = new Lazy<ImmutableArray<IArgument>>(() =>
{
MethodSymbol accessor = boundIndexerAccess.UseSetterForDefaultArgumentGeneration
? boundIndexerAccess.Indexer.GetOwnOrInheritedSetMethod()
......@@ -401,7 +401,7 @@ private IPropertyReferenceExpression CreateBoundIndexerAccessOperation(BoundInde
ITypeSymbol type = boundIndexerAccess.Type;
Optional<object> constantValue = ConvertToOptional(boundIndexerAccess.ConstantValue);
bool isImplicit = boundIndexerAccess.WasCompilerGenerated;
return new LazyPropertyReferenceExpression(property, instance, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyPropertyReferenceExpression(property, instance, arguments, _semanticModel, syntax, type, constantValue, isImplicit);
}
private IEventReferenceExpression CreateBoundEventAccessOperation(BoundEventAccess boundEventAccess)
......@@ -460,19 +460,19 @@ private IPropertyReferenceExpression CreateBoundAnonymousPropertyDeclarationOper
{
PropertySymbol property = boundAnonymousPropertyDeclaration.Property;
Lazy<IOperation> instance = new Lazy<IOperation>(() => null);
Lazy<ImmutableArray<IArgument>> argumentsInEvaluationOrder = new Lazy<ImmutableArray<IArgument>>(() => ImmutableArray<IArgument>.Empty);
Lazy<ImmutableArray<IArgument>> arguments = new Lazy<ImmutableArray<IArgument>>(() => ImmutableArray<IArgument>.Empty);
SyntaxNode syntax = boundAnonymousPropertyDeclaration.Syntax;
ITypeSymbol type = boundAnonymousPropertyDeclaration.Type;
Optional<object> constantValue = ConvertToOptional(boundAnonymousPropertyDeclaration.ConstantValue);
bool isImplicit = boundAnonymousPropertyDeclaration.WasCompilerGenerated;
return new LazyPropertyReferenceExpression(property, instance, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyPropertyReferenceExpression(property, instance, arguments, _semanticModel, syntax, type, constantValue, isImplicit);
}
private IObjectCreationExpression CreateBoundObjectCreationExpressionOperation(BoundObjectCreationExpression boundObjectCreationExpression)
{
IMethodSymbol constructor = boundObjectCreationExpression.Constructor;
Lazy<IObjectOrCollectionInitializerExpression> initializer = new Lazy<IObjectOrCollectionInitializerExpression>(() => (IObjectOrCollectionInitializerExpression)Create(boundObjectCreationExpression.InitializerExpressionOpt));
Lazy<ImmutableArray<IArgument>> argumentsInEvaluationOrder = new Lazy<ImmutableArray<IArgument>>(() =>
Lazy<ImmutableArray<IArgument>> arguments = new Lazy<ImmutableArray<IArgument>>(() =>
{
return DeriveArguments(
boundObjectCreationExpression,
......@@ -491,7 +491,7 @@ private IObjectCreationExpression CreateBoundObjectCreationExpressionOperation(B
ITypeSymbol type = boundObjectCreationExpression.Type;
Optional<object> constantValue = ConvertToOptional(boundObjectCreationExpression.ConstantValue);
bool isImplicit = boundObjectCreationExpression.WasCompilerGenerated;
return new LazyObjectCreationExpression(constructor, initializer, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyObjectCreationExpression(constructor, initializer, arguments, _semanticModel, syntax, type, constantValue, isImplicit);
}
private IDynamicObjectCreationExpression CreateBoundDynamicObjectCreationExpressionOperation(BoundDynamicObjectCreationExpression boundDynamicObjectCreationExpression)
......@@ -588,16 +588,16 @@ private IMemberReferenceExpression CreateBoundObjectInitializerMemberOperation(B
return new LazyEventReferenceExpression(eventSymbol, instance, _semanticModel, syntax, type, constantValue, isImplicit);
case SymbolKind.Property:
var property = (PropertySymbol)boundObjectInitializerMember.MemberSymbol;
Lazy<ImmutableArray<IArgument>> argumentsInEvaluationOrder;
Lazy<ImmutableArray<IArgument>> arguments;
if (!boundObjectInitializerMember.Arguments.Any())
{
// Simple property reference.
argumentsInEvaluationOrder = new Lazy<ImmutableArray<IArgument>>(() => ImmutableArray<IArgument>.Empty);
arguments = new Lazy<ImmutableArray<IArgument>>(() => ImmutableArray<IArgument>.Empty);
}
else
{
// Indexed property reference.
argumentsInEvaluationOrder = new Lazy<ImmutableArray<IArgument>>(() =>
arguments = new Lazy<ImmutableArray<IArgument>>(() =>
{
return DeriveArguments(
boundObjectInitializerMember,
......@@ -614,7 +614,7 @@ private IMemberReferenceExpression CreateBoundObjectInitializerMemberOperation(B
});
}
return new LazyPropertyReferenceExpression(property, instance, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyPropertyReferenceExpression(property, instance, arguments, _semanticModel, syntax, type, constantValue, isImplicit);
default:
throw ExceptionUtilities.Unreachable;
}
......@@ -629,7 +629,7 @@ private ICollectionElementInitializerExpression CreateBoundCollectionElementInit
ITypeSymbol type = boundCollectionElementInitializer.Type;
Optional<object> constantValue = ConvertToOptional(boundCollectionElementInitializer.ConstantValue);
bool isImplicit = boundCollectionElementInitializer.WasCompilerGenerated;
return new LazyCollectionElementInitializerExpression(addMethod, arguments, isDynamic, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyCollectionElementInitializerExpression(addMethod, isDynamic, arguments, _semanticModel, syntax, type, constantValue, isImplicit);
}
private IDynamicMemberReferenceExpression CreateBoundDynamicMemberAccessOperation(BoundDynamicMemberAccess boundDynamicMemberAccess)
......@@ -667,7 +667,7 @@ private ICollectionElementInitializerExpression CreateBoundDynamicCollectionElem
ITypeSymbol type = boundCollectionElementInitializer.Type;
Optional<object> constantValue = ConvertToOptional(boundCollectionElementInitializer.ConstantValue);
bool isImplicit = boundCollectionElementInitializer.WasCompilerGenerated;
return new LazyCollectionElementInitializerExpression(addMethod, arguments, isDynamic, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyCollectionElementInitializerExpression(addMethod, isDynamic, arguments, _semanticModel, syntax, type, constantValue, isImplicit);
}
private IOperation CreateUnboundLambdaOperation(UnboundLambda unboundLambda)
......@@ -818,14 +818,14 @@ private IMethodReferenceExpression CreateBoundMethodGroupSingleMethodOperation(B
private IIsTypeExpression CreateBoundIsOperatorOperation(BoundIsOperator boundIsOperator)
{
Lazy<IOperation> operand = new Lazy<IOperation>(() => Create(boundIsOperator.Operand));
ITypeSymbol isType = boundIsOperator.TargetType.Type;
Lazy<IOperation> valueOperand = new Lazy<IOperation>(() => Create(boundIsOperator.Operand));
ITypeSymbol typeOperand = boundIsOperator.TargetType.Type;
SyntaxNode syntax = boundIsOperator.Syntax;
ITypeSymbol type = boundIsOperator.Type;
bool isNotTypeExpression = false;
bool isNegated = false;
Optional<object> constantValue = ConvertToOptional(boundIsOperator.ConstantValue);
bool isImplicit = boundIsOperator.WasCompilerGenerated;
return new LazyIsTypeExpression(operand, isType, isNotTypeExpression, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyIsTypeExpression(valueOperand, typeOperand, isNegated, _semanticModel, syntax, type, constantValue, isImplicit);
}
private ISizeOfExpression CreateBoundSizeOfOperatorOperation(BoundSizeOfOperator boundSizeOfOperator)
......@@ -939,13 +939,12 @@ private ICompoundAssignmentExpression CreateBoundCompoundAssignmentOperatorOpera
Lazy<IOperation> value = new Lazy<IOperation>(() => Create(boundCompoundAssignmentOperator.Right));
bool isLifted = boundCompoundAssignmentOperator.Operator.Kind.IsLifted();
bool isChecked = boundCompoundAssignmentOperator.Operator.Kind.IsChecked();
bool usesOperatorMethod = (boundCompoundAssignmentOperator.Operator.Kind & CSharp.BinaryOperatorKind.TypeMask) == CSharp.BinaryOperatorKind.UserDefined;
IMethodSymbol operatorMethod = boundCompoundAssignmentOperator.Operator.Method;
SyntaxNode syntax = boundCompoundAssignmentOperator.Syntax;
ITypeSymbol type = boundCompoundAssignmentOperator.Type;
Optional<object> constantValue = ConvertToOptional(boundCompoundAssignmentOperator.ConstantValue);
bool isImplicit = boundCompoundAssignmentOperator.WasCompilerGenerated;
return new LazyCompoundAssignmentExpression(operatorKind, isLifted, isChecked, target, value, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyCompoundAssignmentExpression(operatorKind, isLifted, isChecked, target, value, operatorMethod, _semanticModel, syntax, type, constantValue, isImplicit);
}
private IIncrementOrDecrementExpression CreateBoundIncrementOperatorOperation(BoundIncrementOperator boundIncrementOperator)
......@@ -955,13 +954,12 @@ private IIncrementOrDecrementExpression CreateBoundIncrementOperatorOperation(Bo
bool isLifted = boundIncrementOperator.OperatorKind.IsLifted();
bool isChecked = boundIncrementOperator.OperatorKind.IsChecked();
Lazy<IOperation> target = new Lazy<IOperation>(() => Create(boundIncrementOperator.Operand));
bool usesOperatorMethod = (boundIncrementOperator.OperatorKind & CSharp.UnaryOperatorKind.TypeMask) == CSharp.UnaryOperatorKind.UserDefined;
IMethodSymbol operatorMethod = boundIncrementOperator.MethodOpt;
SyntaxNode syntax = boundIncrementOperator.Syntax;
ITypeSymbol type = boundIncrementOperator.Type;
Optional<object> constantValue = ConvertToOptional(boundIncrementOperator.ConstantValue);
bool isImplicit = boundIncrementOperator.WasCompilerGenerated;
return new LazyIncrementExpression(isDecrement, isPostfix, isLifted, isChecked, target, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyIncrementExpression(isDecrement, isPostfix, isLifted, isChecked, target, operatorMethod, _semanticModel, syntax, type, constantValue, isImplicit);
}
private IInvalidExpression CreateBoundBadExpressionOperation(BoundBadExpression boundBadExpression)
......@@ -991,7 +989,6 @@ private IUnaryOperatorExpression CreateBoundUnaryOperatorOperation(BoundUnaryOpe
{
UnaryOperatorKind unaryOperatorKind = Helper.DeriveUnaryOperatorKind(boundUnaryOperator.OperatorKind);
Lazy<IOperation> operand = new Lazy<IOperation>(() => Create(boundUnaryOperator.Operand));
bool usesOperatorMethod = (boundUnaryOperator.OperatorKind & CSharp.UnaryOperatorKind.TypeMask) == CSharp.UnaryOperatorKind.UserDefined;
IMethodSymbol operatorMethod = boundUnaryOperator.MethodOpt;
SyntaxNode syntax = boundUnaryOperator.Syntax;
ITypeSymbol type = boundUnaryOperator.Type;
......@@ -999,7 +996,7 @@ private IUnaryOperatorExpression CreateBoundUnaryOperatorOperation(BoundUnaryOpe
bool isLifted = boundUnaryOperator.OperatorKind.IsLifted();
bool isChecked = boundUnaryOperator.OperatorKind.IsChecked();
bool isImplicit = boundUnaryOperator.WasCompilerGenerated;
return new LazyUnaryOperatorExpression(unaryOperatorKind, operand, isLifted, isChecked, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyUnaryOperatorExpression(unaryOperatorKind, operand, isLifted, isChecked, operatorMethod, _semanticModel, syntax, type, constantValue, isImplicit);
}
private IBinaryOperatorExpression CreateBoundBinaryOperatorOperation(BoundBinaryOperator boundBinaryOperator)
......@@ -1007,7 +1004,6 @@ private IBinaryOperatorExpression CreateBoundBinaryOperatorOperation(BoundBinary
BinaryOperatorKind operatorKind = Helper.DeriveBinaryOperatorKind(boundBinaryOperator.OperatorKind);
Lazy<IOperation> leftOperand = new Lazy<IOperation>(() => Create(boundBinaryOperator.Left));
Lazy<IOperation> rightOperand = new Lazy<IOperation>(() => Create(boundBinaryOperator.Right));
bool usesOperatorMethod = (boundBinaryOperator.OperatorKind & CSharp.BinaryOperatorKind.TypeMask) == CSharp.BinaryOperatorKind.UserDefined;
IMethodSymbol operatorMethod = boundBinaryOperator.MethodOpt;
SyntaxNode syntax = boundBinaryOperator.Syntax;
ITypeSymbol type = boundBinaryOperator.Type;
......@@ -1016,7 +1012,7 @@ private IBinaryOperatorExpression CreateBoundBinaryOperatorOperation(BoundBinary
bool isChecked = boundBinaryOperator.OperatorKind.IsChecked();
bool isCompareText = false;
bool isImplicit = boundBinaryOperator.WasCompilerGenerated;
return new LazyBinaryOperatorExpression(operatorKind, leftOperand, rightOperand, isLifted, isChecked, isCompareText, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyBinaryOperatorExpression(operatorKind, leftOperand, rightOperand, isLifted, isChecked, isCompareText, operatorMethod, _semanticModel, syntax, type, constantValue, isImplicit);
}
private IConditionalExpression CreateBoundConditionalOperatorOperation(BoundConditionalOperator boundConditionalOperator)
......
......@@ -261,7 +261,7 @@ internal static UnaryOperatorKind DeriveUnaryOperatorKind(CSharp.UnaryOperatorKi
return UnaryOperatorKind.False;
}
return UnaryOperatorKind.Invalid;
return UnaryOperatorKind.None;
}
internal static BinaryOperatorKind DeriveBinaryOperatorKind(CSharp.BinaryOperatorKind operatorKind)
......@@ -317,7 +317,7 @@ internal static BinaryOperatorKind DeriveBinaryOperatorKind(CSharp.BinaryOperato
return BinaryOperatorKind.GreaterThan;
}
return BinaryOperatorKind.Invalid;
return BinaryOperatorKind.None;
}
}
}
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// 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;
using Microsoft.CodeAnalysis.CSharp.Syntax;
......@@ -2352,7 +2352,7 @@ static void M2(int x)
var (operation, syntaxNode) = GetOperationAndSyntaxForTest<InvocationExpressionSyntax>(compilation);
var invocation = (IInvocationExpression)operation;
var argument = invocation.ArgumentsInEvaluationOrder[0];
var argument = invocation.Arguments[0];
// We are calling VB extension methods on IArgument in C# code, therefore exception is expected here.
Assert.Throws<ArgumentException>(() => argument.GetInConversion());
......@@ -2908,14 +2908,14 @@ public static void Verify(IOperation operation, Compilation compilation, SyntaxN
public override void VisitPropertyReferenceExpression(IPropertyReferenceExpression operation)
{
if (operation.HasErrors(_compilation) || operation.ArgumentsInEvaluationOrder.Length == 0)
if (operation.HasErrors(_compilation) || operation.Arguments.Length == 0)
{
return;
}
// Check if the parameter symbol for argument is corresponding to indexer instead of accessor.
var indexerSymbol = operation.Property;
foreach (var argument in operation.ArgumentsInEvaluationOrder)
foreach (var argument in operation.Arguments)
{
if (!argument.HasErrors(_compilation))
{
......
......@@ -7,21 +7,26 @@ namespace Microsoft.CodeAnalysis.Semantics
/// </summary>
public enum ArgumentKind
{
/// <summary>
/// Represents unknown argument kind.
/// </summary>
None = 0x0,
/// <summary>
/// Argument value is explicitly supplied.
/// </summary>
Explicit = 0x0,
Explicit = 0x1,
/// <summary>
/// Argument is a param array created by compilers for the matching C# params or VB ParamArray parameter.
/// Note, the value is a an array creation expression that encapsulates all the elements, if any.
/// </summary>
ParamArray = 0x1,
ParamArray = 0x2,
/// <summary>
/// Argument is a default value supplied automatically by the compilers.
/// </summary>
DefaultValue = 0x2
DefaultValue = 0x3
}
}
......@@ -7,132 +7,131 @@ namespace Microsoft.CodeAnalysis.Semantics
/// </summary>
public enum BinaryOperatorKind
{
/// <summary>
/// Represents unknown or error operator kind.
/// </summary>
None = 0x0,
/// <summary>
/// Represents the '+' operator.
/// </summary>
Add = 0x0,
Add = 0x1,
/// <summary>
/// Represents the '-' operator.
/// </summary>
Subtract = 0x1,
Subtract = 0x2,
/// <summary>
/// Represents the '*' operator.
/// </summary>
Multiply = 0x2,
Multiply = 0x3,
/// <summary>
/// Represents the '/' operator.
/// </summary>
Divide = 0x3,
Divide = 0x4,
/// <summary>
/// Represents the VB '\' integer divide operator.
/// </summary>
IntegerDivide = 0x4,
IntegerDivide = 0x5,
/// <summary>
/// Represents the C# '%' operator and VB 'Mod' operator.
/// </summary>
Remainder = 0x5,
Remainder = 0x6,
/// <summary>
/// Represents the VB '^' exponentiation operator.
/// </summary>
Power = 0x6,
Power = 0x7,
/// <summary>
/// Represents the <![CDATA['<<']]> operator.
/// </summary>
LeftShift = 0x7,
LeftShift = 0x8,
/// <summary>
/// Represents the <![CDATA['>>']]> operator.
/// </summary>
RightShift = 0x8,
RightShift = 0x9,
/// <summary>
/// Represents the C# <![CDATA['&']]> operator and VB 'And' operator.
/// </summary>
And = 0x9,
And = 0xa,
/// <summary>
/// Represents the C# <![CDATA['|']]> operator and VB 'Or' operator.
/// </summary>
Or = 0xa,
Or = 0xb,
/// <summary>
/// Represents the C# '^' operator and VB 'Xor' operator.
/// </summary>
ExclusiveOr = 0xb,
ExclusiveOr = 0xc,
/// <summary>
/// Represents the C# <![CDATA['&&']]> operator and VB 'AndAlso' operator.
/// </summary>
ConditionalAnd = 0xc,
ConditionalAnd = 0xd,
/// <summary>
/// Represents the C# <![CDATA['||']]> operator and VB 'OrElse' operator.
/// </summary>
ConditionalOr = 0xd,
ConditionalOr = 0xe,
/// <summary>
/// Represents the VB <![CDATA['&']]> operator for string concatenation.
/// </summary>
Concatenate = 0xe,
Concatenate = 0xf,
// Relational operations.
/// <summary>
/// Represents the C# '=' operator and VB 'Is' operator and '=' operator for non-object typed operands.
/// </summary>
Equals = 0x0f,
Equals = 0x10,
/// <summary>
/// Represents the VB '=' operator for object typed operands.
/// </summary>
ObjectValueEquals = 0x10,
ObjectValueEquals = 0x11,
/// <summary>
/// Represents the C# '!=' operator and VB 'IsNot' operator and <![CDATA['<>']]> operator for non-object typed operands.
/// </summary>
NotEquals = 0x11,
NotEquals = 0x12,
/// <summary>
/// Represents the VB <![CDATA['<>']]> operator for object typed operands.
/// </summary>
ObjectValueNotEquals = 0x12,
ObjectValueNotEquals = 0x13,
/// <summary>
/// Represents the <![CDATA['<']]> operator.
/// </summary>
LessThan = 0x13,
LessThan = 0x14,
/// <summary>
/// Represents the <![CDATA['<=']]> operator.
/// </summary>
LessThanOrEqual = 0x14,
LessThanOrEqual = 0x15,
/// <summary>
/// Represents the <![CDATA['>=']]> operator.
/// </summary>
GreaterThanOrEqual = 0x15,
GreaterThanOrEqual = 0x16,
/// <summary>
/// Represents the <![CDATA['>']]> operator.
/// </summary>
GreaterThan = 0x16,
GreaterThan = 0x17,
/// <summary>
/// Represents the VB 'Like' operator.
/// </summary>
Like = 0x17,
/// <summary>
/// Represents an invalid binary operator for error cases.
/// </summary>
Invalid = 0xff
Like = 0x18
}
}
......@@ -7,20 +7,25 @@ namespace Microsoft.CodeAnalysis.Semantics
/// </summary>
public enum BranchKind
{
/// <summary>
/// Represents unknown branch kind.
/// </summary>
None = 0x1,
/// <summary>
/// Represents a continue branch kind.
/// </summary>
Continue = 0x0,
Continue = 0x1,
/// <summary>
/// Represents a break branch kind.
/// </summary>
Break = 0x1,
Break = 0x2,
/// <summary>
/// Represents a goto branch kind.
/// </summary>
GoTo = 0x2
GoTo = 0x3
}
}
......@@ -9,26 +9,35 @@ namespace Microsoft.CodeAnalysis.Semantics
/// </summary>
public enum CaseKind
{
/// <summary>
/// Represents unknown case kind.
/// </summary>
None = 0x0,
/// <summary>
/// Indicates case x in C# or Case x in VB.
/// </summary>
SingleValue = 0x0,
SingleValue = 0x1,
/// <summary>
/// Indicates Case Is op x in VB.
/// </summary>
Relational = 0x1,
Relational = 0x2,
/// <summary>
/// Indicates Case x To Y in VB.
/// </summary>
Range = 0x2,
Range = 0x3,
/// <summary>
/// Indicates default in C# or Case Else in VB.
/// </summary>
Default = 0x3,
Default = 0x4,
/// <summary>
/// Indicates pattern case in C#.
/// </summary>
Pattern = 0x4
Pattern = 0x5
}
}
......@@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Semantics
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface IBinaryOperatorExpression : IHasOperatorMethodExpression
public interface IBinaryOperatorExpression : IOperation
{
/// <summary>
/// Kind of binary operation.
......@@ -26,6 +26,10 @@ public interface IBinaryOperatorExpression : IHasOperatorMethodExpression
/// </summary>
IOperation RightOperand { get; }
/// <summary>
/// Operator method used by the operation, null if the operation does not use an operator method.
/// </summary>
IMethodSymbol OperatorMethod { get; }
/// <summary>
/// <code>true</code> if this is a 'lifted' binary operator. When there is an
/// operator that is defined to work on a value type, 'lifted' operators are
/// created to work on the <see cref="System.Nullable{T}"/> versions of those
......
......@@ -16,7 +16,7 @@ namespace Microsoft.CodeAnalysis.Semantics
public interface ICollectionElementInitializerExpression : IOperation
{
/// <summary>
/// Add method invoked on collection. Null for dynamic invocation.
/// Add method invoked on collection. Null for dynamic invocation and error cases.
/// </summary>
IMethodSymbol AddMethod { get; }
......
......@@ -9,13 +9,18 @@ namespace Microsoft.CodeAnalysis.Semantics
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface ICompoundAssignmentExpression : IAssignmentExpression, IHasOperatorMethodExpression
public interface ICompoundAssignmentExpression : IAssignmentExpression
{
/// <summary>
/// Kind of binary operation.
/// </summary>
BinaryOperatorKind OperatorKind { get; }
/// <summary>
/// Operator method used by the operation, null if the operation does not use an operator method.
/// </summary>
IMethodSymbol OperatorMethod { get; }
/// <summary>
/// <code>true</code> if this assignment contains a 'lifted' binary operation.
/// </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;
namespace Microsoft.CodeAnalysis.Semantics
{
/// <summary>
/// Represents the value of a conditionally-accessed expression within an expression containing a conditional access.
/// For a conditional expression of the form <code>someExpr?.Member</code>, this operation is used as the InstanceReceiver for the right operation <code>Member</code>.
/// See https://github.com/dotnet/roslyn/issues/21279#issuecomment-323153041 for more details.
/// </summary>
/// <remarks>
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
......
......@@ -11,12 +11,16 @@ namespace Microsoft.CodeAnalysis.Semantics
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface IConversionExpression : IHasOperatorMethodExpression
public interface IConversionExpression : IOperation
{
/// <summary>
/// Value to be converted.
/// </summary>
IOperation Operand { get; }
/// <summary>
/// Operator method used by the operation, null if the operation does not use an operator method.
/// </summary>
IMethodSymbol OperatorMethod { get; }
#pragma warning disable RS0010 // Avoid using cref tags with a prefix
/// <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;
namespace Microsoft.CodeAnalysis.Semantics
{
/// <summary>
/// Represents a C# or VB statement that consists solely of an expression.
/// Note that this node is semantically different from the operation representing the underlying expression
/// as it represents the value of the expression being dropped and also has no underlying type.
/// </summary>
/// <remarks>
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Immutable;
namespace Microsoft.CodeAnalysis.Semantics
{
/// <remarks>
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface IHasArguments : IOperation
{
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in evaluation order.
/// </summary>
/// <remarks>
/// If the invocation is in its expanded form, then params/ParamArray arguments would be collected into arrays.
/// Default values are supplied for optional arguments missing in source.
/// </remarks>
ImmutableArray<IArgument> ArgumentsInEvaluationOrder { get; }
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Immutable;
namespace Microsoft.CodeAnalysis.Semantics
{
/// <summary>
/// Represents a unary, binary, relational, or conversion operation that can use an operator method.
/// </summary>
/// <remarks>
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface IHasOperatorMethodExpression : IOperation
{
/// <summary>
/// True if and only if the operation is performed by an operator method.
/// </summary>
bool UsesOperatorMethod { get; }
/// <summary>
/// Operation method used by the operation, null if the operation does not use an operator method.
/// </summary>
IMethodSymbol OperatorMethod { get; }
}
}
......@@ -4,18 +4,25 @@ namespace Microsoft.CodeAnalysis.Semantics
{
/// <summary>
/// Represents an increment (<see cref="OperationKind.IncrementExpression"/>) or decrement (<see cref="OperationKind.DecrementExpression"/>) expression in C#.
/// Note that this operation is different from an <see cref="IUnaryOperatorExpression"/> as it mutates the <see cref="Target"/>,
/// while unary operator expression does not mutate it's operand.
/// </summary>
/// <remarks>
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface IIncrementOrDecrementExpression : IOperation, IHasOperatorMethodExpression
public interface IIncrementOrDecrementExpression : IOperation
{
/// <summary>
/// Target of the assignment.
/// </summary>
IOperation Target { get; }
/// <summary>
/// Operator method used by the operation, null if the operation does not use an operator method.
/// </summary>
IMethodSymbol OperatorMethod { get; }
/// <summary>
/// <code>true</code> if this is a postfix expression.
/// <code>false</code> if this is a prefix expression.
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Immutable;
namespace Microsoft.CodeAnalysis.Semantics
{
/// <summary>
......@@ -9,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Semantics
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface IInvocationExpression : IHasArguments
public interface IInvocationExpression : IOperation
{
/// <summary>
/// Method to be invoked.
......@@ -23,6 +25,14 @@ public interface IInvocationExpression : IHasArguments
/// True if the invocation uses a virtual mechanism, and false otherwise.
/// </summary>
bool IsVirtual { get; }
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in evaluation order.
/// </summary>
/// <remarks>
/// If the invocation is in its expanded form, then params/ParamArray arguments would be collected into arrays.
/// Default values are supplied for optional arguments missing in source.
/// </remarks>
ImmutableArray<IArgument> Arguments { get; }
}
}
......@@ -14,18 +14,18 @@ public interface IIsTypeExpression : IOperation
/// <summary>
/// Value to test.
/// </summary>
IOperation Operand { get; }
IOperation ValueOperand { get; }
/// <summary>
/// Type for which to test.
/// </summary>
ITypeSymbol IsType { get; }
ITypeSymbol TypeOperand { get; }
/// <summary>
/// Flag indicating if this is an "is not" type expression.
/// True for VB "TypeOf ... IsNot ..." expression.
/// False, otherwise.
/// </summary>
bool IsNotTypeExpression { get; }
bool IsNegated { get; }
}
}
......@@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Semantics
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface IObjectCreationExpression : IHasArguments
public interface IObjectCreationExpression : IOperation
{
/// <summary>
/// Constructor to be invoked on the created instance.
......@@ -21,6 +21,14 @@ public interface IObjectCreationExpression : IHasArguments
/// Object or collection initializer, if any.
/// </summary>
IObjectOrCollectionInitializerExpression Initializer { get; }
/// <summary>
/// Arguments of the object creation, excluding the instance argument. Arguments are in evaluation order.
/// </summary>
/// <remarks>
/// If the invocation is in its expanded form, then params/ParamArray arguments would be collected into arrays.
/// Default values are supplied for optional arguments missing in source.
/// </remarks>
ImmutableArray<IArgument> Arguments { get; }
}
}
......@@ -11,12 +11,20 @@ namespace Microsoft.CodeAnalysis.Semantics
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface IPropertyReferenceExpression : IMemberReferenceExpression, IHasArguments
public interface IPropertyReferenceExpression : IMemberReferenceExpression
{
/// <summary>
/// Referenced property.
/// </summary>
IPropertySymbol Property { get; }
/// <summary>
/// Arguments of the indexer property reference expression, excluding the instance argument. Arguments are in evaluation order.
/// </summary>
/// <remarks>
/// If the invocation is in its expanded form, then params/ParamArray arguments would be collected into arrays.
/// Default values are supplied for optional arguments missing in source.
/// </remarks>
ImmutableArray<IArgument> Arguments { get; }
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Immutable;
namespace Microsoft.CodeAnalysis.Semantics
{
/// <summary>
......@@ -9,12 +11,20 @@ namespace Microsoft.CodeAnalysis.Semantics
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface IRaiseEventStatement : IHasArguments
public interface IRaiseEventStatement: IOperation
{
/// <summary>
/// Reference to the event to be raised.
/// </summary>
IEventReferenceExpression EventReference { get; }
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in evaluation order.
/// </summary>
/// <remarks>
/// If the invocation is in its expanded form, then params/ParamArray arguments would be collected into arrays.
/// Default values are supplied for optional arguments missing in source.
/// </remarks>
ImmutableArray<IArgument> Arguments { get; }
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Immutable;
namespace Microsoft.CodeAnalysis.Semantics
{
/// <summary>
......@@ -11,17 +9,23 @@ namespace Microsoft.CodeAnalysis.Semantics
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface IUnaryOperatorExpression : IHasOperatorMethodExpression
public interface IUnaryOperatorExpression : IOperation
{
/// <summary>
/// Kind of unary operation.
/// </summary>
UnaryOperatorKind OperatorKind { get; }
/// <summary>
/// Single operand.
/// </summary>
IOperation Operand { get; }
/// <summary>
/// Operator method used by the operation, null if the operation does not use an operator method.
/// </summary>
IMethodSymbol OperatorMethod { get; }
/// <summary>
/// <code>true</code> if this is a 'lifted' unary operator. When there is an
/// operator that is defined to work on a value type, 'lifted' operators are
......
......@@ -7,34 +7,34 @@ namespace Microsoft.CodeAnalysis.Semantics
/// </summary>
public enum DoLoopKind
{
/// <summary>
/// Represents unknown or error do loop kind.
/// </summary>
None = 0x0,
/// <summary>
/// Indicates a C# 'do while' or a VB 'Do While' loop where the loop condition is executed at the bottom of the loop, i.e. end of the loop iteration.
/// Loop executes while the loop condition evaluates to <code>true</code>.
/// </summary>
DoWhileBottomLoop = 0x0,
DoWhileBottomLoop = 0x1,
/// <summary>
/// Indicates a VB 'Do While' loop with the loop condition executed at the top of the loop, i.e. beginning of the loop iteration.
/// Loop executes while the loop condition evaluates to <code>true</code>.
/// </summary>
DoWhileTopLoop = 0x1,
DoWhileTopLoop = 0x2,
/// <summary>
/// Indicates a VB 'Do Until' loop with the loop condition executed at the bottom of the loop, i.e. end of the loop iteration.
/// Loop executes while the loop condition evaluates to <code>false</code>.
/// </summary>
DoUntilBottomLoop = 0x2,
DoUntilBottomLoop = 0x3,
/// <summary>
/// Indicates a VB 'Do Until' loop with the loop condition executed at the top of the loop, i.e. beginning of the loop iteration.
/// Loop executes while the loop condition evaluates to <code>false</code>.
/// </summary>
DoUntilTopLoop = 0x3,
/// <summary>
/// Indicates an invalid loop. For example, VB 'Do While' or 'Do Until' loop with syntax errors where both the top and bottom conditions are provided.
/// </summary>
Invalid = 0xf,
DoUntilTopLoop = 0x4
}
}
......@@ -7,30 +7,35 @@ namespace Microsoft.CodeAnalysis.Semantics
/// </summary>
public enum LoopKind
{
/// <summary>
/// Represents unknown loop kind.
/// </summary>
None = 0x0,
/// <summary>
/// Represents a <see cref="IDoLoopStatement"/> in C# or VB.
/// </summary>
Do = 0x0,
Do = 0x1,
/// <summary>
/// Represents a <see cref="IWhileLoopStatement"/> in C# or VB.
/// </summary>
While = 0x1,
While = 0x2,
/// <summary>
/// Indicates a <see cref="IForLoopStatement"/> in C#.
/// </summary>
For = 0x2,
For = 0x3,
/// <summary>
/// Indicates a <see cref="IForToLoopStatement"/> in VB.
/// </summary>
ForTo = 0x3,
ForTo = 0x4,
/// <summary>
/// Indicates a <see cref="IForEachLoopStatement"/> in C# or VB.
/// </summary>
ForEach = 0x4
ForEach = 0x5
}
}
......@@ -182,7 +182,7 @@ public override IOperation VisitEndStatement(IEndStatement operation, object arg
public override IOperation VisitInvocationExpression(IInvocationExpression operation, object argument)
{
return new InvocationExpression(operation.TargetMethod, Visit(operation.Instance), operation.IsVirtual, VisitArray(operation.ArgumentsInEvaluationOrder), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
return new InvocationExpression(operation.TargetMethod, Visit(operation.Instance), operation.IsVirtual, VisitArray(operation.Arguments), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
}
public override IOperation VisitOmittedArgumentExpression(IOmittedArgumentExpression operation, object argument)
......@@ -227,7 +227,7 @@ public override IOperation VisitMethodReferenceExpression(IMethodReferenceExpres
public override IOperation VisitPropertyReferenceExpression(IPropertyReferenceExpression operation, object argument)
{
return new PropertyReferenceExpression(operation.Property, Visit(operation.Instance), VisitArray(operation.ArgumentsInEvaluationOrder), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
return new PropertyReferenceExpression(operation.Property, Visit(operation.Instance), VisitArray(operation.Arguments), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
}
public override IOperation VisitEventReferenceExpression(IEventReferenceExpression operation, object argument)
......@@ -257,12 +257,12 @@ internal override IOperation VisitPlaceholderExpression(IPlaceholderExpression o
public override IOperation VisitUnaryOperatorExpression(IUnaryOperatorExpression operation, object argument)
{
return new UnaryOperatorExpression(operation.OperatorKind, Visit(operation.Operand), operation.IsLifted, operation.IsChecked, operation.UsesOperatorMethod, operation.OperatorMethod, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
return new UnaryOperatorExpression(operation.OperatorKind, Visit(operation.Operand), operation.IsLifted, operation.IsChecked, operation.OperatorMethod, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
}
public override IOperation VisitBinaryOperatorExpression(IBinaryOperatorExpression operation, object argument)
{
return new BinaryOperatorExpression(operation.OperatorKind, Visit(operation.LeftOperand), Visit(operation.RightOperand), operation.IsLifted, operation.IsChecked, operation.IsCompareText, operation.UsesOperatorMethod, operation.OperatorMethod, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
return new BinaryOperatorExpression(operation.OperatorKind, Visit(operation.LeftOperand), Visit(operation.RightOperand), operation.IsLifted, operation.IsChecked, operation.IsCompareText, operation.OperatorMethod, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
}
public override IOperation VisitConditionalExpression(IConditionalExpression operation, object argument)
......@@ -277,7 +277,7 @@ public override IOperation VisitCoalesceExpression(ICoalesceExpression operation
public override IOperation VisitIsTypeExpression(IIsTypeExpression operation, object argument)
{
return new IsTypeExpression(Visit(operation.Operand), operation.IsType, operation.IsNotTypeExpression, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
return new IsTypeExpression(Visit(operation.ValueOperand), operation.TypeOperand, operation.IsNegated, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
}
public override IOperation VisitSizeOfExpression(ISizeOfExpression operation, object argument)
......@@ -327,7 +327,7 @@ public override IOperation VisitAddressOfExpression(IAddressOfExpression operati
public override IOperation VisitObjectCreationExpression(IObjectCreationExpression operation, object argument)
{
return new ObjectCreationExpression(operation.Constructor, Visit(operation.Initializer), VisitArray(operation.ArgumentsInEvaluationOrder), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
return new ObjectCreationExpression(operation.Constructor, Visit(operation.Initializer), VisitArray(operation.Arguments), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
}
public override IOperation VisitAnonymousObjectCreationExpression(IAnonymousObjectCreationExpression operation, object argument)
......@@ -347,7 +347,7 @@ public override IOperation VisitMemberInitializerExpression(IMemberInitializerEx
public override IOperation VisitCollectionElementInitializerExpression(ICollectionElementInitializerExpression operation, object argument)
{
return new CollectionElementInitializerExpression(operation.AddMethod, VisitArray(operation.Arguments), operation.IsDynamic, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
return new CollectionElementInitializerExpression(operation.AddMethod, operation.IsDynamic, VisitArray(operation.Arguments), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
}
public override IOperation VisitFieldInitializer(IFieldInitializer operation, object argument)
......@@ -397,13 +397,13 @@ public override IOperation VisitDeclarationExpression(IDeclarationExpression ope
public override IOperation VisitCompoundAssignmentExpression(ICompoundAssignmentExpression operation, object argument)
{
return new CompoundAssignmentExpression(operation.OperatorKind, operation.IsLifted, operation.IsChecked, Visit(operation.Target), Visit(operation.Value), operation.UsesOperatorMethod, operation.OperatorMethod, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
return new CompoundAssignmentExpression(operation.OperatorKind, operation.IsLifted, operation.IsChecked, Visit(operation.Target), Visit(operation.Value), operation.OperatorMethod, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
}
public override IOperation VisitIncrementOrDecrementExpression(IIncrementOrDecrementExpression operation, object argument)
{
bool isDecrement = operation.Kind == OperationKind.DecrementExpression;
return new IncrementExpression(isDecrement, operation.IsPostfix, operation.IsLifted, operation.IsChecked, Visit(operation.Target), operation.UsesOperatorMethod, operation.OperatorMethod, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
return new IncrementExpression(isDecrement, operation.IsPostfix, operation.IsLifted, operation.IsChecked, Visit(operation.Target), operation.OperatorMethod, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
}
public override IOperation VisitParenthesizedExpression(IParenthesizedExpression operation, object argument)
......@@ -503,7 +503,7 @@ public override IOperation VisitTranslatedQueryExpression(ITranslatedQueryExpres
public override IOperation VisitRaiseEventStatement(IRaiseEventStatement operation, object argument)
{
return new RaiseEventStatement(Visit(operation.EventReference), VisitArray(operation.ArgumentsInEvaluationOrder), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
return new RaiseEventStatement(Visit(operation.EventReference), VisitArray(operation.Arguments), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
}
}
}
......@@ -56,7 +56,6 @@ public static IExpressionStatement CreateSimpleAssignmentExpressionStatement(IOp
isChecked,
target,
value,
operatorMethod != null,
operatorMethod,
semanticModel,
syntax,
......@@ -83,7 +82,7 @@ public static ILiteralExpression CreateLiteralExpression(ConstantValue value, IT
return new BinaryOperatorExpression(
operatorKind, left, right,
isLifted: isLifted, isChecked: isChecked,
isCompareText: isCompareText, usesOperatorMethod: false, operatorMethod: null,
isCompareText: isCompareText, operatorMethod: null,
semanticModel: semanticModel, syntax: syntax, type: resultType, constantValue: default, isImplicit: isImplicit);
}
......
......@@ -7,40 +7,40 @@ namespace Microsoft.CodeAnalysis.Semantics
/// </summary>
public enum UnaryOperatorKind
{
/// <summary>
/// Represents unknown or error operator kind.
/// </summary>
None = 0x0,
/// <summary>
/// Represents the C# '~' operator.
/// </summary>
BitwiseNegation = 0x0,
BitwiseNegation = 0x1,
/// <summary>
/// Represents the C# '!' operator and VB 'Not' operator.
/// </summary>
Not = 0x1,
Not = 0x2,
/// <summary>
/// Represents the unary '+' operator.
/// </summary>
Plus = 0x2,
Plus = 0x3,
/// <summary>
/// Represents the unary '-' operator.
/// </summary>
Minus = 0x3,
Minus = 0x4,
/// <summary>
/// Represents the C# 'true' operator and VB 'IsTrue' operator.
/// </summary>
True = 0x4,
True = 0x5,
/// <summary>
/// Represents the C# 'false' operator and VB 'IsFalse' operator.
/// </summary>
False = 0x5,
/// <summary>
/// Represents an invalid unary operator for error cases.
/// </summary>
Invalid = 0xff,
False = 0x6
}
}
......@@ -362,7 +362,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
Case VisualBasic.UnaryOperatorKind.IsFalse
Return UnaryOperatorKind.False
Case Else
Return UnaryOperatorKind.Invalid
Return UnaryOperatorKind.None
End Select
End Function
......@@ -417,7 +417,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
Case VisualBasic.BinaryOperatorKind.Concatenate
Return BinaryOperatorKind.Concatenate
Case Else
Return BinaryOperatorKind.Invalid
Return BinaryOperatorKind.None
End Select
End Function
End Class
......
......@@ -63,7 +63,6 @@ End Module
Assert.Equal(assignment1.Value.Kind, OperationKind.BinaryOperatorExpression)
Dim add1 As IBinaryOperatorExpression = DirectCast(assignment1.Value, IBinaryOperatorExpression)
Assert.Equal(add1.OperatorKind, CodeAnalysis.Semantics.BinaryOperatorKind.Add)
Assert.False(add1.UsesOperatorMethod)
Assert.Null(add1.OperatorMethod)
Dim left1 As IOperation = add1.LeftOperand
Assert.Equal(left1.Kind, OperationKind.LocalReferenceExpression)
......@@ -97,7 +96,6 @@ IExpressionStatement (OperationKind.ExpressionStatement, IsInvalid) (Syntax: 'x
Assert.Equal(assignment2.Value.Kind, OperationKind.BinaryOperatorExpression)
Dim add2 As IBinaryOperatorExpression = DirectCast(assignment2.Value, IBinaryOperatorExpression)
Assert.Equal(add2.OperatorKind, CodeAnalysis.Semantics.BinaryOperatorKind.Add)
Assert.True(add2.UsesOperatorMethod)
Assert.NotNull(add2.OperatorMethod)
Assert.Equal(add2.OperatorMethod.Name, "op_Addition")
Dim left2 As IOperation = add2.LeftOperand
......@@ -131,7 +129,6 @@ IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x = x + y')
Assert.Equal(assignment3.Value.Kind, OperationKind.UnaryOperatorExpression)
Dim negate3 As IUnaryOperatorExpression = DirectCast(assignment3.Value, IUnaryOperatorExpression)
Assert.Equal(negate3.OperatorKind, CodeAnalysis.Semantics.UnaryOperatorKind.Minus)
Assert.False(negate3.UsesOperatorMethod)
Assert.Null(negate3.OperatorMethod)
Dim operand3 As IOperation = negate3.Operand
Assert.Equal(operand3.Kind, OperationKind.LocalReferenceExpression)
......@@ -195,7 +192,6 @@ End Module
Assert.NotNull(value1)
Assert.Equal(value1.Local.Name, "y")
Assert.Equal(assignment1.OperatorKind, CodeAnalysis.Semantics.BinaryOperatorKind.Add)
Assert.False(assignment1.UsesOperatorMethod)
Assert.Null(assignment1.OperatorMethod)
comp.VerifyOperationTree(nodes(0), expectedOperationTree:="
......@@ -222,7 +218,6 @@ IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x += y')
Assert.NotNull(value2)
Assert.Equal(value2.Local.Name, "b")
Assert.Equal(assignment2.OperatorKind, CodeAnalysis.Semantics.BinaryOperatorKind.Add)
Assert.True(assignment2.UsesOperatorMethod)
Assert.NotNull(assignment2.OperatorMethod)
Assert.Equal(assignment2.OperatorMethod.Name, "op_Addition")
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Microsoft.CodeAnalysis.Test.Utilities
......@@ -1091,7 +1091,7 @@ End Class]]>.Value
End Function, SymbolFilter.Member).Single()
Dim invocation = CType(result.operation, IInvocationExpression)
Dim argument = invocation.ArgumentsInEvaluationOrder(0)
Dim argument = invocation.Arguments(0)
Dim inConversion = argument.GetInConversion()
Assert.Same(exptectedInMethod, inConversion.MethodSymbol)
......
......@@ -1405,7 +1405,7 @@ Class C
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
IDoLoopStatement (DoLoopKind: Invalid) (LoopKind.Do) (OperationKind.LoopStatement, IsInvalid) (Syntax: 'Do While i ... ntil i <= 0')
IDoLoopStatement (DoLoopKind: None) (LoopKind.Do) (OperationKind.LoopStatement, IsInvalid) (Syntax: 'Do While i ... ntil i <= 0')
Condition:
IBinaryOperatorExpression (BinaryOperatorKind.GreaterThan, Checked) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i > 0')
Left:
......
......@@ -65,6 +65,7 @@ private static bool TryRemoveExistingEnumMembers(ISwitchStatement switchStatemen
switch (clause.CaseKind)
{
default:
case CaseKind.None:
case CaseKind.Relational:
case CaseKind.Range:
// This was some sort of complex switch. For now just ignore
......
......@@ -658,12 +658,12 @@ public override void VisitInvocationExpression(IInvocationExpression operation)
LogCommonPropertiesAndNewLine(operation);
VisitInstanceExpression(operation.Instance);
VisitArguments(operation);
VisitArguments(operation.Arguments);
}
private void VisitArguments(IHasArguments operation)
private void VisitArguments(ImmutableArray<IArgument> arguments)
{
VisitArray(operation.ArgumentsInEvaluationOrder, "Arguments", logElementCount: true);
VisitArray(arguments, "Arguments", logElementCount: true);
}
private void VisitDynamicArguments(HasDynamicArgumentsExpression operation)
......@@ -833,9 +833,9 @@ public override void VisitPropertyReferenceExpression(IPropertyReferenceExpressi
VisitMemberReferenceExpressionCommon(operation);
if (operation.ArgumentsInEvaluationOrder.Length > 0)
if (operation.Arguments.Length > 0)
{
VisitArguments(operation);
VisitArguments(operation.Arguments);
}
}
......@@ -894,7 +894,7 @@ public override void VisitUnaryOperatorExpression(IUnaryOperatorExpression opera
}
LogString($" ({kindStr})");
LogHasOperatorMethodExpressionCommon(operation);
LogHasOperatorMethodExpressionCommon(operation.OperatorMethod);
LogCommonPropertiesAndNewLine(operation);
Visit(operation.Operand, "Operand");
......@@ -921,24 +921,20 @@ public override void VisitBinaryOperatorExpression(IBinaryOperatorExpression ope
}
LogString($" ({kindStr})");
LogHasOperatorMethodExpressionCommon(operation);
LogHasOperatorMethodExpressionCommon(operation.OperatorMethod);
LogCommonPropertiesAndNewLine(operation);
Visit(operation.LeftOperand, "Left");
Visit(operation.RightOperand, "Right");
}
private void LogHasOperatorMethodExpressionCommon(IHasOperatorMethodExpression operation)
private void LogHasOperatorMethodExpressionCommon(IMethodSymbol operatorMethodOpt)
{
Assert.Equal(operation.UsesOperatorMethod, operation.OperatorMethod != null);
if (!operation.UsesOperatorMethod)
if (operatorMethodOpt != null)
{
return;
LogSymbol(operatorMethodOpt, header: " (OperatorMethod");
LogString(")");
}
LogSymbol(operation.OperatorMethod, header: " (OperatorMethod");
LogString(")");
}
public override void VisitConversionExpression(IConversionExpression operation)
......@@ -950,7 +946,7 @@ public override void VisitConversionExpression(IConversionExpression operation)
var isChecked = operation.IsChecked ? "Checked" : "Unchecked";
LogString($" ({isExplicitStr}, {isTryCast}, {isChecked})");
LogHasOperatorMethodExpressionCommon(operation);
LogHasOperatorMethodExpressionCommon(operation.OperatorMethod);
LogCommonPropertiesAndNewLine(operation);
Indent();
LogConversion(operation.Conversion);
......@@ -982,17 +978,17 @@ public override void VisitCoalesceExpression(ICoalesceExpression operation)
public override void VisitIsTypeExpression(IIsTypeExpression operation)
{
LogString(nameof(IIsTypeExpression));
if (operation.IsNotTypeExpression)
if (operation.IsNegated)
{
LogString(" (IsNotExpression)");
}
LogCommonPropertiesAndNewLine(operation);
Visit(operation.Operand, "Operand");
Visit(operation.ValueOperand, "Operand");
Indent();
LogType(operation.IsType, "IsType");
LogType(operation.TypeOperand, "IsType");
LogNewLine();
Unindent();
}
......@@ -1082,7 +1078,7 @@ public override void VisitObjectCreationExpression(IObjectCreationExpression ope
LogString($" (Constructor: {operation.Constructor.ToTestDisplayString()})");
LogCommonPropertiesAndNewLine(operation);
VisitArguments(operation);
VisitArguments(operation.Arguments);
Visit(operation.Initializer, "Initializer");
}
......@@ -1273,7 +1269,7 @@ public override void VisitCompoundAssignmentExpression(ICompoundAssignmentExpres
}
LogString($" ({kindStr})");
LogHasOperatorMethodExpressionCommon(operation);
LogHasOperatorMethodExpressionCommon(operation.OperatorMethod);
LogCommonPropertiesAndNewLine(operation);
Visit(operation.Target, "Left");
......@@ -1296,7 +1292,7 @@ public override void VisitIncrementOrDecrementExpression(IIncrementOrDecrementEx
}
LogString($" ({kindStr})");
LogHasOperatorMethodExpressionCommon(operation);
LogHasOperatorMethodExpressionCommon(operation.OperatorMethod);
LogCommonPropertiesAndNewLine(operation);
Visit(operation.Target, "Target");
......@@ -1499,7 +1495,7 @@ public override void VisitRaiseEventStatement(IRaiseEventStatement operation)
LogCommonPropertiesAndNewLine(operation);
Visit(operation.EventReference, header: "Event Reference");
VisitArguments(operation);
VisitArguments(operation.Arguments);
}
#endregion
......
......@@ -331,7 +331,6 @@ internal override void VisitPlaceholderExpression(IPlaceholderExpression operati
public override void VisitUnaryOperatorExpression(IUnaryOperatorExpression operation)
{
var usesOperatorMethod = operation.UsesOperatorMethod;
var operatorMethod = operation.OperatorMethod;
var unaryOperationKind = operation.OperatorKind;
var isLifted = operation.IsLifted;
......@@ -342,7 +341,6 @@ public override void VisitUnaryOperatorExpression(IUnaryOperatorExpression opera
public override void VisitBinaryOperatorExpression(IBinaryOperatorExpression operation)
{
var usesOperatorMethod = operation.UsesOperatorMethod;
var operatorMethod = operation.OperatorMethod;
var binaryOperationKind = operation.OperatorKind;
var isLifted = operation.IsLifted;
......@@ -354,7 +352,6 @@ public override void VisitBinaryOperatorExpression(IBinaryOperatorExpression ope
public override void VisitConversionExpression(IConversionExpression operation)
{
var usesOperatorMethod = operation.UsesOperatorMethod;
var operatorMethod = operation.OperatorMethod;
var conversion = operation.Conversion;
var isExplicitInCode = operation.IsExplicitInCode;
......@@ -388,7 +385,7 @@ public override void VisitCoalesceExpression(ICoalesceExpression operation)
public override void VisitIsTypeExpression(IIsTypeExpression operation)
{
var isType = operation.IsType;
var isType = operation.TypeOperand;
base.VisitIsTypeExpression(operation);
}
......@@ -548,7 +545,6 @@ public override void VisitSimpleAssignmentExpression(ISimpleAssignmentExpression
public override void VisitCompoundAssignmentExpression(ICompoundAssignmentExpression operation)
{
var usesOperatorMethod = operation.UsesOperatorMethod;
var operatorMethod = operation.OperatorMethod;
var binaryOperationKind = operation.OperatorKind;
......@@ -557,7 +553,6 @@ public override void VisitCompoundAssignmentExpression(ICompoundAssignmentExpres
public override void VisitIncrementOrDecrementExpression(IIncrementOrDecrementExpression operation)
{
var usesOperatorMethod = operation.UsesOperatorMethod;
var operatorMethod = operation.OperatorMethod;
var isPostFix = operation.IsPostfix;
......
......@@ -44,7 +44,7 @@ public sealed override void Initialize(AnalysisContext context)
if (conversion.Type.IsReferenceType &&
conversion.Operand.Type != null &&
conversion.Operand.Type.IsValueType &&
!conversion.UsesOperatorMethod)
conversion.OperatorMethod == null)
{
Report(operationContext, conversion.Syntax);
}
......
......@@ -81,7 +81,7 @@ public sealed override void Initialize(AnalysisContext context)
(operationContext) =>
{
IInvocationExpression invocation = (IInvocationExpression)operationContext.Operation;
foreach (IArgument argument in invocation.ArgumentsInEvaluationOrder)
foreach (IArgument argument in invocation.Arguments)
{
if (argument.Parameter.RefKind == RefKind.Out || argument.Parameter.RefKind == RefKind.Ref)
{
......
......@@ -69,7 +69,7 @@ public sealed override void Initialize(AnalysisContext context)
(operationContext) =>
{
IInvocationExpression invocation = (IInvocationExpression)operationContext.Operation;
foreach (IArgument argument in invocation.ArgumentsInEvaluationOrder)
foreach (IArgument argument in invocation.Arguments)
{
if (argument.Parameter.RefKind == RefKind.Out || argument.Parameter.RefKind == RefKind.Ref)
{
......
......@@ -62,7 +62,7 @@ public sealed override void Initialize(AnalysisContext context)
(operationContext) =>
{
IInvocationExpression invocation = (IInvocationExpression)operationContext.Operation;
foreach (IArgument argument in invocation.ArgumentsInEvaluationOrder)
foreach (IArgument argument in invocation.Arguments)
{
if (argument.Parameter.RefKind == RefKind.Out || argument.Parameter.RefKind == RefKind.Ref)
{
......
......@@ -240,7 +240,7 @@ private void AnalyzeOperation(OperationAnalysisContext operationContext)
// Advance is known to be an assignment of a binary operation to the local used in the test.
IBinaryOperatorExpression advanceOperation = (IBinaryOperatorExpression)advanceAssignment.Value;
if (!advanceOperation.UsesOperatorMethod &&
if (advanceOperation.OperatorMethod == null &&
advanceOperation.LeftOperand.Kind == OperationKind.LocalReferenceExpression &&
((ILocalReferenceExpression)advanceOperation.LeftOperand).Local == testVariable &&
advanceOperation.RightOperand.ConstantValue.HasValue &&
......@@ -553,7 +553,7 @@ public sealed override void Initialize(AnalysisContext context)
{
IInvocationExpression invocation = (IInvocationExpression)operationContext.Operation;
long priorArgumentValue = long.MinValue;
foreach (IArgument argument in invocation.ArgumentsInEvaluationOrder)
foreach (IArgument argument in invocation.Arguments)
{
if (argument.HasErrors(operationContext.Compilation, operationContext.CancellationToken))
{
......@@ -1112,7 +1112,7 @@ public sealed override void Initialize(AnalysisContext context)
{
IInvocationExpression invocation = (IInvocationExpression)operationContext.Operation;
foreach (IArgument argument in invocation.ArgumentsInEvaluationOrder)
foreach (IArgument argument in invocation.Arguments)
{
if (argument.Parameter.IsParams)
{
......@@ -1139,7 +1139,7 @@ public sealed override void Initialize(AnalysisContext context)
operationContext.ReportDiagnostic(Diagnostic.Create(InvalidConstructorDescriptor, creation.Syntax.GetLocation()));
}
foreach (IArgument argument in creation.ArgumentsInEvaluationOrder)
foreach (IArgument argument in creation.Arguments)
{
if (argument.Parameter.IsParams)
{
......@@ -1526,7 +1526,7 @@ public sealed override void Initialize(AnalysisContext context)
(operationContext) =>
{
IBinaryOperatorExpression binary = (IBinaryOperatorExpression)operationContext.Operation;
if (binary.OperatorKind == BinaryOperatorKind.Add && binary.UsesOperatorMethod && binary.OperatorMethod.Name.Contains("Addition"))
if (binary.OperatorKind == BinaryOperatorKind.Add && binary.OperatorMethod != null && binary.OperatorMethod.Name.Contains("Addition"))
{
operationContext.ReportDiagnostic(Diagnostic.Create(OperatorAddMethodDescriptor, binary.Syntax.GetLocation()));
}
......@@ -1542,7 +1542,7 @@ public sealed override void Initialize(AnalysisContext context)
(operationContext) =>
{
IUnaryOperatorExpression unary = (IUnaryOperatorExpression)operationContext.Operation;
if (unary.OperatorKind == UnaryOperatorKind.Minus && unary.UsesOperatorMethod && unary.OperatorMethod.Name.Contains("UnaryNegation"))
if (unary.OperatorKind == UnaryOperatorKind.Minus && unary.OperatorMethod != null && unary.OperatorMethod.Name.Contains("UnaryNegation"))
{
operationContext.ReportDiagnostic(Diagnostic.Create(OperatorMinusMethodDescriptor, unary.Syntax.GetLocation()));
}
......@@ -1580,7 +1580,7 @@ public sealed override void Initialize(AnalysisContext context)
(operationContext) =>
{
var binary = (IBinaryOperatorExpression)operationContext.Operation;
if (binary.UsesOperatorMethod)
if (binary.OperatorMethod != null)
{
operationContext.ReportDiagnostic(
Diagnostic.Create(BinaryUserDefinedOperatorDescriptor,
......@@ -1623,7 +1623,7 @@ public sealed override void Initialize(AnalysisContext context)
var right = binary.RightOperand;
if (!left.HasErrors(operationContext.Compilation, operationContext.CancellationToken) &&
!right.HasErrors(operationContext.Compilation, operationContext.CancellationToken) &&
!binary.UsesOperatorMethod && binary.OperatorMethod == null)
binary.OperatorMethod == null)
{
if (left.Kind == OperationKind.LocalReferenceExpression)
{
......@@ -1657,7 +1657,7 @@ public sealed override void Initialize(AnalysisContext context)
var operandLocal = ((ILocalReferenceExpression)operand).Local;
if (operandLocal.Name == "x")
{
if (!operand.HasErrors(operationContext.Compilation, operationContext.CancellationToken) && !unary.UsesOperatorMethod && unary.OperatorMethod == null)
if (!operand.HasErrors(operationContext.Compilation, operationContext.CancellationToken) && unary.OperatorMethod == null)
{
operationContext.ReportDiagnostic(
Diagnostic.Create(UnaryOperatorDescriptor,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册