Skip to content

Commit

Permalink
Make '^' operation nodes internal (#32918)
Browse files Browse the repository at this point in the history
  • Loading branch information
agocke authored Feb 6, 2019
1 parent e70bf11 commit 19623b8
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7937,7 +7937,7 @@ void M(int arg)
Operand:
ILiteralOperation (OperationKind.Literal, Type: System.Int32, Constant: 0) (Syntax: '0')
RightOperand:
IFromEndIndexOperation (OperationKind.FromEndIndex, Type: System.Index) (Syntax: '^1')
IFromEndIndexOperation (OperationKind.None, Type: System.Index) (Syntax: '^1')
Operand:
ILiteralOperation (OperationKind.Literal, Type: System.Int32, Constant: 1) (Syntax: '1')
";
Expand Down Expand Up @@ -8079,7 +8079,7 @@ void M(int? start, int? end)
Operand:
IParameterReferenceOperation: start (OperationKind.ParameterReference, Type: System.Int32?) (Syntax: 'start')
RightOperand:
IFromEndIndexOperation (IsLifted) (OperationKind.FromEndIndex, Type: System.Index?) (Syntax: '^end')
IFromEndIndexOperation (IsLifted) (OperationKind.None, Type: System.Index?) (Syntax: '^end')
Operand:
IParameterReferenceOperation: end (OperationKind.ParameterReference, Type: System.Int32?) (Syntax: 'end')
";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void M(int arg)
IVariableDeclaratorOperation (Symbol: System.Index x) (OperationKind.VariableDeclarator, Type: null) (Syntax: 'x = ^arg')
Initializer:
IVariableInitializerOperation (OperationKind.VariableInitializer, Type: null) (Syntax: '= ^arg')
IFromEndIndexOperation (OperationKind.FromEndIndex, Type: System.Index) (Syntax: '^arg')
IFromEndIndexOperation (OperationKind.None, Type: System.Index) (Syntax: '^arg')
Operand:
IParameterReferenceOperation: arg (OperationKind.ParameterReference, Type: System.Int32) (Syntax: 'arg')
Initializer:
Expand All @@ -60,7 +60,7 @@ void M(int arg)
Left:
ILocalReferenceOperation: x (IsDeclaration: True) (OperationKind.LocalReference, Type: System.Index, IsImplicit) (Syntax: 'x = ^arg')
Right:
IFromEndIndexOperation (OperationKind.FromEndIndex, Type: System.Index) (Syntax: '^arg')
IFromEndIndexOperation (OperationKind.None, Type: System.Index) (Syntax: '^arg')
Operand:
IParameterReferenceOperation: arg (OperationKind.ParameterReference, Type: System.Int32) (Syntax: 'arg')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3629,7 +3629,7 @@ void M(int arg)
}").VerifyDiagnostics();

string expectedOperationTree = @"
IFromEndIndexOperation (OperationKind.FromEndIndex, Type: System.Index) (Syntax: '^arg')
IFromEndIndexOperation (OperationKind.None, Type: System.Index) (Syntax: '^arg')
Operand:
IParameterReferenceOperation: arg (OperationKind.ParameterReference, Type: System.Int32) (Syntax: 'arg')
";
Expand All @@ -3652,7 +3652,7 @@ void M(int? arg)
}").VerifyDiagnostics();

string expectedOperationTree = @"
IFromEndIndexOperation (IsLifted) (OperationKind.FromEndIndex, Type: System.Index?) (Syntax: '^arg')
IFromEndIndexOperation (IsLifted) (OperationKind.None, Type: System.Index?) (Syntax: '^arg')
Operand:
IParameterReferenceOperation: arg (OperationKind.ParameterReference, Type: System.Int32?) (Syntax: 'arg')
";
Expand All @@ -3675,7 +3675,7 @@ void M(byte arg)
}").VerifyDiagnostics();

string expectedOperationTree = @"
IFromEndIndexOperation (OperationKind.FromEndIndex, Type: System.Index) (Syntax: '^arg')
IFromEndIndexOperation (OperationKind.None, Type: System.Index) (Syntax: '^arg')
Operand:
IConversionOperation (TryCast: False, Unchecked) (OperationKind.Conversion, Type: System.Int32, IsImplicit) (Syntax: 'arg')
Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: True, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6567,7 +6567,7 @@ public override IOperation VisitDelegateCreation(IDelegateCreationOperation oper
operation.Syntax, operation.Type, operation.ConstantValue, IsImplicit(operation));
}

public override IOperation VisitFromEndIndexOperation(IFromEndIndexOperation operation, int? argument)
internal override IOperation VisitFromEndIndexOperation(IFromEndIndexOperation operation, int? argument)
{
return new FromEndIndexOperation(operation.IsLifted, semanticModel: null, operation.Syntax, operation.Type, Visit(operation.Operand), operation.Symbol, isImplicit: IsImplicit(operation));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/Core/Portable/Operations/IIndexOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Operations
/// <remarks>
/// This interface is reserved for implementation by its associated APIs. We reserve the right to change it in the future.
/// </remarks>
public interface IFromEndIndexOperation : IOperation
internal interface IFromEndIndexOperation : IOperation
{
/// <summary>
/// The operand.
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/Core/Portable/Operations/OperationCloner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ public override IOperation VisitStaticLocalInitializationSemaphore(IStaticLocalI
throw ExceptionUtilities.Unreachable;
}

public override IOperation VisitFromEndIndexOperation(IFromEndIndexOperation operation, object argument)
internal override IOperation VisitFromEndIndexOperation(IFromEndIndexOperation operation, object argument)
{
return new FromEndIndexOperation(operation.IsLifted, ((Operation)operation).OwningSemanticModel, operation.Syntax, operation.Type, Visit(operation.Operand), operation.Symbol, operation.IsImplicit);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Compilers/Core/Portable/Operations/OperationKind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ public enum OperationKind

/// <summary>Indicates an <see cref="IRangeOperation"/>.</summary>
Range = 0x63,
/// <summary>Indicates an <see cref="IFromEndIndexOperation"/>.</summary>
FromEndIndex = 0x64,
// Unused, FromEndIndex will be a unary operator: https://github.com/dotnet/roslyn/pull/32918
//FromEndIndex = 0x64,
/// <summary>Indicates an <see cref="IReDimOperation"/>.</summary>
ReDim = 0x65,
/// <summary>Indicates an <see cref="IReDimClauseOperation"/>.</summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/Core/Portable/Operations/OperationNodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9401,7 +9401,7 @@ public override IObjectOrCollectionInitializerOperation Initializer
internal abstract class BaseFromEndIndexOperation : Operation, IFromEndIndexOperation
{
protected BaseFromEndIndexOperation(bool isLifted, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, IMethodSymbol symbol, bool isImplicit) :
base(OperationKind.FromEndIndex, semanticModel, syntax, type, constantValue: default, isImplicit: isImplicit)
base(OperationKind.None, semanticModel, syntax, type, constantValue: default, isImplicit: isImplicit)
{
IsLifted = isLifted;
Symbol = symbol;
Expand Down
4 changes: 2 additions & 2 deletions src/Compilers/Core/Portable/Operations/OperationVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ public virtual void VisitStaticLocalInitializationSemaphore(IStaticLocalInitiali
DefaultVisit(operation);
}

public virtual void VisitFromEndIndexOperation(IFromEndIndexOperation operation)
internal virtual void VisitFromEndIndexOperation(IFromEndIndexOperation operation)
{
DefaultVisit(operation);
}
Expand Down Expand Up @@ -1193,7 +1193,7 @@ public virtual TResult VisitStaticLocalInitializationSemaphore(IStaticLocalIniti
return DefaultVisit(operation, argument);
}

public virtual TResult VisitFromEndIndexOperation(IFromEndIndexOperation operation, TArgument argument)
internal virtual TResult VisitFromEndIndexOperation(IFromEndIndexOperation operation, TArgument argument)
{
return DefaultVisit(operation, argument);
}
Expand Down
7 changes: 0 additions & 7 deletions src/Compilers/Core/Portable/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Microsoft.CodeAnalysis.ITypeSymbol.IsUnmanagedType.get -> bool
Microsoft.CodeAnalysis.OperationKind.Binary = 32 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.ConstructorBody = 89 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.DiscardPattern = 104 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.FromEndIndex = 100 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.MethodBody = 88 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.Range = 99 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.RecursivePattern = 103 -> Microsoft.CodeAnalysis.OperationKind
Expand Down Expand Up @@ -168,10 +167,6 @@ Microsoft.CodeAnalysis.Operations.ICoalesceOperation.ValueConversion.get -> Micr
Microsoft.CodeAnalysis.Operations.IEventAssignmentOperation.EventReference.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Operations.IForLoopOperation.ConditionLocals.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ILocalSymbol>
Microsoft.CodeAnalysis.Operations.IForToLoopOperation.IsChecked.get -> bool
Microsoft.CodeAnalysis.Operations.IFromEndIndexOperation
Microsoft.CodeAnalysis.Operations.IFromEndIndexOperation.IsLifted.get -> bool
Microsoft.CodeAnalysis.Operations.IFromEndIndexOperation.Operand.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Operations.IFromEndIndexOperation.Symbol.get -> Microsoft.CodeAnalysis.IMethodSymbol
Microsoft.CodeAnalysis.Operations.IInstanceReferenceOperation.ReferenceKind.get -> Microsoft.CodeAnalysis.Operations.InstanceReferenceKind
Microsoft.CodeAnalysis.Operations.ILoopOperation.ContinueLabel.get -> Microsoft.CodeAnalysis.ILabelSymbol
Microsoft.CodeAnalysis.Operations.ILoopOperation.ExitLabel.get -> Microsoft.CodeAnalysis.ILabelSymbol
Expand Down Expand Up @@ -213,7 +208,6 @@ virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDiscardPattern(M
virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitFlowAnonymousFunction(Microsoft.CodeAnalysis.FlowAnalysis.IFlowAnonymousFunctionOperation operation) -> void
virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitFlowCapture(Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureOperation operation) -> void
virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitFlowCaptureReference(Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureReferenceOperation operation) -> void
virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitFromEndIndexOperation(Microsoft.CodeAnalysis.Operations.IFromEndIndexOperation operation) -> void
virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitIsNull(Microsoft.CodeAnalysis.FlowAnalysis.IIsNullOperation operation) -> void
virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitRangeOperation(Microsoft.CodeAnalysis.Operations.IRangeOperation operation) -> void
virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitReDim(Microsoft.CodeAnalysis.Operations.IReDimOperation operation) -> void
Expand All @@ -228,7 +222,6 @@ virtual Microsoft.CodeAnalysis.Operations.OperationVisitor<TArgument, TResult>.V
virtual Microsoft.CodeAnalysis.Operations.OperationVisitor<TArgument, TResult>.VisitFlowAnonymousFunction(Microsoft.CodeAnalysis.FlowAnalysis.IFlowAnonymousFunctionOperation operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Operations.OperationVisitor<TArgument, TResult>.VisitFlowCapture(Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureOperation operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Operations.OperationVisitor<TArgument, TResult>.VisitFlowCaptureReference(Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureReferenceOperation operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Operations.OperationVisitor<TArgument, TResult>.VisitFromEndIndexOperation(Microsoft.CodeAnalysis.Operations.IFromEndIndexOperation operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Operations.OperationVisitor<TArgument, TResult>.VisitIsNull(Microsoft.CodeAnalysis.FlowAnalysis.IIsNullOperation operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Operations.OperationVisitor<TArgument, TResult>.VisitRangeOperation(Microsoft.CodeAnalysis.Operations.IRangeOperation operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Operations.OperationVisitor<TArgument, TResult>.VisitReDim(Microsoft.CodeAnalysis.Operations.IReDimOperation operation, TArgument argument) -> TResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,6 @@ propertyReference.Parent is ISimpleAssignmentOperation simpleAssignment &&
case OperationKind.Discard:
case OperationKind.ReDim:
case OperationKind.ReDimClause:
case OperationKind.FromEndIndex:
case OperationKind.Range:
case OperationKind.RecursivePattern:
case OperationKind.DiscardPattern:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1878,7 +1878,7 @@ public override void VisitStaticLocalInitializationSemaphore(IStaticLocalInitial
LogCommonPropertiesAndNewLine(operation);
}

public override void VisitFromEndIndexOperation(IFromEndIndexOperation operation)
internal override void VisitFromEndIndexOperation(IFromEndIndexOperation operation)
{
LogString(nameof(IFromEndIndexOperation));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1421,9 +1421,9 @@ public override void VisitStaticLocalInitializationSemaphore(IStaticLocalInitial
Assert.True(operation.Local.IsStatic);
}

public override void VisitFromEndIndexOperation(IFromEndIndexOperation operation)
internal override void VisitFromEndIndexOperation(IFromEndIndexOperation operation)
{
Assert.Equal(OperationKind.FromEndIndex, operation.Kind);
Assert.Equal(OperationKind.None, operation.Kind);
Assert.Same(operation.Operand, operation.Children.Single());
}

Expand Down

0 comments on commit 19623b8

Please sign in to comment.