diff --git a/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs b/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs index 68a3616c9ebf8d00001ddcd55dfc58f90c1610b7..d49359a7e02867f4cd50444e558454dc5da7ef8e 100644 --- a/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs +++ b/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs @@ -1156,62 +1156,73 @@ private IIfStatement CreateBoundIfStatementOperation(BoundIfStatement boundIfSta return new LazyIfStatement(condition, ifTrueStatement, ifFalseStatement, _semanticModel, syntax, type, constantValue, isImplicit); } - private IWhileUntilLoopStatement CreateBoundWhileStatementOperation(BoundWhileStatement boundWhileStatement) + private IWhileLoopStatement CreateBoundWhileStatementOperation(BoundWhileStatement boundWhileStatement) { - bool isTopTest = true; - bool isWhile = true; Lazy condition = new Lazy(() => Create(boundWhileStatement.Condition)); - LoopKind loopKind = LoopKind.WhileUntil; Lazy body = new Lazy(() => Create(boundWhileStatement.Body)); + ImmutableArray locals = boundWhileStatement.Locals.As(); SyntaxNode syntax = boundWhileStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); bool isImplicit = boundWhileStatement.WasCompilerGenerated; - return new LazyWhileUntilLoopStatement(isTopTest, isWhile, condition, loopKind, body, _semanticModel, syntax, type, constantValue, isImplicit); + return new LazyWhileLoopStatement(condition, body, locals, _semanticModel, syntax, type, constantValue, isImplicit); } - private IWhileUntilLoopStatement CreateBoundDoStatementOperation(BoundDoStatement boundDoStatement) + private IDoLoopStatement CreateBoundDoStatementOperation(BoundDoStatement boundDoStatement) { - bool isTopTest = false; - bool isWhile = true; + DoLoopKind doLoopKind = DoLoopKind.DoWhileBottomLoop; Lazy condition = new Lazy(() => Create(boundDoStatement.Condition)); - LoopKind loopKind = LoopKind.WhileUntil; Lazy body = new Lazy(() => Create(boundDoStatement.Body)); + Lazy ignoredCondition = new Lazy(() => null); + ImmutableArray locals = boundDoStatement.Locals.As(); SyntaxNode syntax = boundDoStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); bool isImplicit = boundDoStatement.WasCompilerGenerated; - return new LazyWhileUntilLoopStatement(isTopTest, isWhile, condition, loopKind, body, _semanticModel, syntax, type, constantValue, isImplicit); + return new LazyDoLoopStatement(doLoopKind, condition, body, ignoredCondition, locals, _semanticModel, syntax, type, constantValue, isImplicit); } private IForLoopStatement CreateBoundForStatementOperation(BoundForStatement boundForStatement) { Lazy> before = new Lazy>(() => ToStatements(boundForStatement.Initializer)); + Lazy condition = new Lazy(() => Create(boundForStatement.Condition)); Lazy> atLoopBottom = new Lazy>(() => ToStatements(boundForStatement.Increment)); ImmutableArray locals = boundForStatement.OuterLocals.As(); - Lazy condition = new Lazy(() => Create(boundForStatement.Condition)); - LoopKind loopKind = LoopKind.For; Lazy body = new Lazy(() => Create(boundForStatement.Body)); SyntaxNode syntax = boundForStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); bool isImplicit = boundForStatement.WasCompilerGenerated; - return new LazyForLoopStatement(before, atLoopBottom, locals, condition, loopKind, body, _semanticModel, syntax, type, constantValue, isImplicit); + return new LazyForLoopStatement(before, condition, atLoopBottom, locals, body, _semanticModel, syntax, type, constantValue, isImplicit); } private IForEachLoopStatement CreateBoundForEachStatementOperation(BoundForEachStatement boundForEachStatement) { - ILocalSymbol iterationVariable = boundForEachStatement.IterationVariables.Length == 1 ? - boundForEachStatement.IterationVariables.FirstOrDefault() : - null; + ImmutableArray locals = boundForEachStatement.IterationVariables.As(); + Lazy loopControlVariable; + if (boundForEachStatement.DeconstructionOpt != null) + { + loopControlVariable = new Lazy(() => Create(boundForEachStatement.DeconstructionOpt)); + } + else if (locals.Length == 1) + { + var local = (LocalSymbol)locals.Single(); + bool isDeclaration = true; + loopControlVariable = new Lazy(() => new LocalReferenceExpression(local, isDeclaration, _semanticModel, local.GetDeclaratorSyntax(), local.Type, local.ConstantValue, local.IsImplicitlyDeclared)); + } + else + { + loopControlVariable = new Lazy(() => null); + } + Lazy collection = new Lazy(() => Create(boundForEachStatement.Expression)); - LoopKind loopKind = LoopKind.ForEach; Lazy body = new Lazy(() => Create(boundForEachStatement.Body)); + Lazy> nextVariables = new Lazy>(() => ImmutableArray.Empty); SyntaxNode syntax = boundForEachStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); bool isImplicit = boundForEachStatement.WasCompilerGenerated; - return new LazyForEachLoopStatement(iterationVariable, collection, loopKind, body, _semanticModel, syntax, type, constantValue, isImplicit); + return new LazyForEachLoopStatement(locals, loopControlVariable, collection, nextVariables, body, _semanticModel, syntax, type, constantValue, isImplicit); } private ISwitchStatement CreateBoundSwitchStatementOperation(BoundSwitchStatement boundSwitchStatement) diff --git a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IForEachLoopStatement.cs b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IForEachLoopStatement.cs index 0bfab26520fa9a75adaa8ada17f737aaf180f5a4..d618d8a5c49578481a9acf15af6f86d4804c008c 100644 --- a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IForEachLoopStatement.cs +++ b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IForEachLoopStatement.cs @@ -5,7 +5,6 @@ using Roslyn.Test.Utilities; using Xunit; - namespace Microsoft.CodeAnalysis.CSharp.UnitTests { public partial class IOperationTests : SemanticModelTestBase @@ -29,7 +28,9 @@ static void Main() } "; string expectedOperationTree = @" -IForEachLoopStatement (Iteration variable: System.String value) (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (st ... }') +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (st ... }') + Locals: Local_1: System.String value + LoopControlVariable: ILocalReferenceExpression: value (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: System.String, Constant: null) (Syntax: 'foreach (st ... }') Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Collections.IEnumerable) (Syntax: 'pets') Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: True, IsUserDefined: False) (MethodSymbol: null) Operand: ILocalReferenceExpression: pets (OperationKind.LocalReferenceExpression, Type: System.String[]) (Syntax: 'pets') @@ -42,6 +43,7 @@ static void Main() ILocalReferenceExpression: value (OperationKind.LocalReferenceExpression, Type: System.String) (Syntax: 'value') InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + NextVariables(0) "; VerifyOperationTreeForTest(source, expectedOperationTree); } @@ -71,7 +73,9 @@ static void Main(string[] args) } "; string expectedOperationTree = @" -IForEachLoopStatement (Iteration variable: System.String item) (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (st ... }') +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (st ... }') + Locals: Local_1: System.String item + LoopControlVariable: ILocalReferenceExpression: item (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: System.String, Constant: null) (Syntax: 'foreach (st ... }') Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Collections.Generic.List) (Syntax: 'list') Conversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) Operand: ILocalReferenceExpression: list (OperationKind.LocalReferenceExpression, Type: System.Collections.Generic.List) (Syntax: 'list') @@ -84,6 +88,7 @@ static void Main(string[] args) ILocalReferenceExpression: item (OperationKind.LocalReferenceExpression, Type: System.String) (Syntax: 'item') InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + NextVariables(0) "; VerifyOperationTreeForTest(source, expectedOperationTree); } @@ -114,7 +119,9 @@ static void Main() } "; string expectedOperationTree = @" -IForEachLoopStatement (Iteration variable: System.Collections.Generic.KeyValuePair pair) (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (Ke ... }') +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (Ke ... }') + Locals: Local_1: System.Collections.Generic.KeyValuePair pair + LoopControlVariable: ILocalReferenceExpression: pair (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: System.Collections.Generic.KeyValuePair, Constant: null) (Syntax: 'foreach (Ke ... }') Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Collections.Generic.Dictionary) (Syntax: '_h') Conversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) Operand: IFieldReferenceExpression: System.Collections.Generic.Dictionary Program._h (Static) (OperationKind.FieldReferenceExpression, Type: System.Collections.Generic.Dictionary) (Syntax: '_h') @@ -142,6 +149,7 @@ static void Main() Instance Receiver: ILocalReferenceExpression: pair (OperationKind.LocalReferenceExpression, Type: System.Collections.Generic.KeyValuePair) (Syntax: 'pair') InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + NextVariables(0) "; VerifyOperationTreeForTest(source, expectedOperationTree); } @@ -169,7 +177,9 @@ static void Main() } "; string expectedOperationTree = @" -IForEachLoopStatement (Iteration variable: System.Int32 num) (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (in ... }') +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (in ... }') + Locals: Local_1: System.Int32 num + LoopControlVariable: ILocalReferenceExpression: num (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: System.Int32, Constant: null) (Syntax: 'foreach (in ... }') Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Collections.IEnumerable) (Syntax: 'numbers') Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: True, IsUserDefined: False) (MethodSymbol: null) Operand: ILocalReferenceExpression: numbers (OperationKind.LocalReferenceExpression, Type: System.Int32[]) (Syntax: 'numbers') @@ -189,6 +199,7 @@ static void Main() ILocalReferenceExpression: num (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'num') InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + NextVariables(0) "; VerifyOperationTreeForTest(source, expectedOperationTree); } @@ -216,7 +227,9 @@ static void Main() } "; string expectedOperationTree = @" -IForEachLoopStatement (Iteration variable: System.Int32 num) (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (in ... }') +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (in ... }') + Locals: Local_1: System.Int32 num + LoopControlVariable: ILocalReferenceExpression: num (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: System.Int32, Constant: null) (Syntax: 'foreach (in ... }') Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Collections.IEnumerable) (Syntax: 'numbers') Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: True, IsUserDefined: False) (MethodSymbol: null) Operand: ILocalReferenceExpression: numbers (OperationKind.LocalReferenceExpression, Type: System.Int32[]) (Syntax: 'numbers') @@ -236,6 +249,7 @@ static void Main() ILocalReferenceExpression: num (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'num') InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + NextVariables(0) "; VerifyOperationTreeForTest(source, expectedOperationTree); } @@ -261,7 +275,9 @@ orderby letter } "; string expectedOperationTree = @" -IForEachLoopStatement (Iteration variable: System.String value) (LoopKind.ForEach) (OperationKind.LoopStatement, IsInvalid) (Syntax: 'foreach (st ... }') +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement, IsInvalid) (Syntax: 'foreach (st ... }') + Locals: Local_1: System.String value + LoopControlVariable: ILocalReferenceExpression: value (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: System.String, Constant: null, IsInvalid) (Syntax: 'foreach (st ... }') Collection: ILocalReferenceExpression: sorted (OperationKind.LocalReferenceExpression, Type: ?, IsInvalid) (Syntax: 'sorted') Body: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'System.Cons ... ine(value);') @@ -272,6 +288,7 @@ orderby letter ILocalReferenceExpression: value (OperationKind.LocalReferenceExpression, Type: System.String) (Syntax: 'value') InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + NextVariables(0) "; VerifyOperationTreeForTest(source, expectedOperationTree); } @@ -314,7 +331,9 @@ static void Main(string[] args) } "; string expectedOperationTree = @" -IForEachLoopStatement (Iteration variable: System.Reflection.FieldInfo fi) (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (Fi ... }') +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (Fi ... }') + Locals: Local_1: System.Reflection.FieldInfo fi + LoopControlVariable: ILocalReferenceExpression: fi (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: System.Reflection.FieldInfo, Constant: null) (Syntax: 'foreach (Fi ... }') Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Collections.IEnumerable) (Syntax: 'employee.Ge ... GetFields()') Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: True, IsUserDefined: False) (MethodSymbol: null) Operand: IInvocationExpression ( System.Reflection.FieldInfo[] System.Type.GetFields()) (OperationKind.InvocationExpression, Type: System.Reflection.FieldInfo[]) (Syntax: 'employee.Ge ... GetFields()') @@ -350,6 +369,7 @@ static void Main(string[] args) OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + NextVariables(0) "; VerifyOperationTreeForTest(source, expectedOperationTree); } @@ -374,7 +394,9 @@ public void M() "; string expectedOperationTree = @" -IForEachLoopStatement (Iteration variable: System.Char c) (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (ch ... }') +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (ch ... }') + Locals: Local_1: System.Char c + LoopControlVariable: ILocalReferenceExpression: c (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: System.Char, Constant: null) (Syntax: 'foreach (ch ... }') Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.String) (Syntax: 's') Conversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) Operand: ILocalReferenceExpression: s (OperationKind.LocalReferenceExpression, Type: System.String, Constant: """") (Syntax: 's') @@ -387,6 +409,7 @@ public void M() ILocalReferenceExpression: c (OperationKind.LocalReferenceExpression, Type: System.Char) (Syntax: 'c') InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + NextVariables(0) "; VerifyOperationTreeForTest(source, expectedOperationTree); } @@ -415,7 +438,9 @@ static void Main() } "; string expectedOperationTree = @" -IForEachLoopStatement (Iteration variable: System.Collections.Generic.KeyValuePair pair) (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (va ... }') +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (va ... }') + Locals: Local_1: System.Collections.Generic.KeyValuePair pair + LoopControlVariable: ILocalReferenceExpression: pair (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: System.Collections.Generic.KeyValuePair, Constant: null) (Syntax: 'foreach (va ... }') Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Collections.Generic.Dictionary) (Syntax: '_f') Conversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) Operand: IFieldReferenceExpression: System.Collections.Generic.Dictionary Program._f (Static) (OperationKind.FieldReferenceExpression, Type: System.Collections.Generic.Dictionary) (Syntax: '_f') @@ -443,6 +468,7 @@ static void Main() Instance Receiver: ILocalReferenceExpression: pair (OperationKind.LocalReferenceExpression, Type: System.Collections.Generic.KeyValuePair) (Syntax: 'pair') InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + NextVariables(0) "; VerifyOperationTreeForTest(source, expectedOperationTree); } @@ -465,7 +491,9 @@ static void Main() } "; string expectedOperationTree = @" -IForEachLoopStatement (Iteration variable: MissingType x) (LoopKind.ForEach) (OperationKind.LoopStatement, IsInvalid) (Syntax: 'foreach (Mi ... }') +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement, IsInvalid) (Syntax: 'foreach (Mi ... }') + Locals: Local_1: MissingType x + LoopControlVariable: ILocalReferenceExpression: x (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: MissingType, Constant: null, IsInvalid) (Syntax: 'foreach (Mi ... }') Collection: ILocalReferenceExpression: sequence (OperationKind.LocalReferenceExpression, Type: System.Collections.IEnumerable) (Syntax: 'sequence') Body: IBlockStatement (1 statements, 1 locals) (OperationKind.BlockStatement) (Syntax: '{ ... }') Locals: Local_1: System.Boolean b @@ -482,6 +510,7 @@ static void Main() ILiteralExpression (OperationKind.LiteralExpression, Type: null, Constant: null) (Syntax: 'null') InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + NextVariables(0) "; VerifyOperationTreeForTest(source, expectedOperationTree); } @@ -502,9 +531,12 @@ static void Main() } "; string expectedOperationTree = @" -IForEachLoopStatement (Iteration variable: System.Int32 x) (LoopKind.ForEach) (OperationKind.LoopStatement, IsInvalid) (Syntax: 'foreach (in ... }') +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement, IsInvalid) (Syntax: 'foreach (in ... }') + Locals: Local_1: System.Int32 x + LoopControlVariable: ILocalReferenceExpression: x (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: System.Int32, Constant: null, IsInvalid) (Syntax: 'foreach (in ... }') Collection: ILiteralExpression (OperationKind.LiteralExpression, Type: null, Constant: null, IsInvalid) (Syntax: 'null') Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') + NextVariables(0) "; VerifyOperationTreeForTest(source, expectedOperationTree); } @@ -525,11 +557,14 @@ static void Main(string[] args) } "; string expectedOperationTree = @" -IForEachLoopStatement (Iteration variable: System.Int32 x) (LoopKind.ForEach) (OperationKind.LoopStatement, IsInvalid) (Syntax: 'foreach (in ... }') +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement, IsInvalid) (Syntax: 'foreach (in ... }') + Locals: Local_1: System.Int32 x + LoopControlVariable: ILocalReferenceExpression: x (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: System.Int32, Constant: null, IsInvalid) (Syntax: 'foreach (in ... }') Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Collections.IEnumerable) (Syntax: 'args') Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: True, IsUserDefined: False) (MethodSymbol: null) Operand: IParameterReferenceExpression: args (OperationKind.ParameterReferenceExpression, Type: System.String[]) (Syntax: 'args') Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') + NextVariables(0) "; VerifyOperationTreeForTest(source, expectedOperationTree); } @@ -548,7 +583,9 @@ void F(int[] a) } "; string expectedOperationTree = @" -IForEachLoopStatement (Iteration variable: System.Int32 x) (LoopKind.ForEach) (OperationKind.LoopStatement, IsInvalid) (Syntax: 'foreach (in ... a) { x++; }') +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement, IsInvalid) (Syntax: 'foreach (in ... a) { x++; }') + Locals: Local_1: System.Int32 x + LoopControlVariable: ILocalReferenceExpression: x (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: System.Int32, Constant: null, IsInvalid) (Syntax: 'foreach (in ... a) { x++; }') Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Collections.IEnumerable) (Syntax: 'a') Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: True, IsUserDefined: False) (MethodSymbol: null) Operand: IParameterReferenceExpression: a (OperationKind.ParameterReferenceExpression, Type: System.Int32[]) (Syntax: 'a') @@ -558,6 +595,7 @@ void F(int[] a) Target: IInvalidExpression (OperationKind.InvalidExpression, Type: System.Int32, IsInvalid) (Syntax: 'x') Children(1): ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32, IsInvalid) (Syntax: 'x') + NextVariables(0) "; VerifyOperationTreeForTest(source, expectedOperationTree); } @@ -588,11 +626,14 @@ class Enumerator "; string expectedOperationTree = @" -IForEachLoopStatement (Iteration variable: System.Int64 x) (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (lo ... x in e) { }') +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (lo ... x in e) { }') + Locals: Local_1: System.Int64 x + LoopControlVariable: ILocalReferenceExpression: x (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: System.Int64, Constant: null) (Syntax: 'foreach (lo ... x in e) { }') Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: Enumerable) (Syntax: 'e') Conversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) Operand: IParameterReferenceExpression: e (OperationKind.ParameterReferenceExpression, Type: Enumerable) (Syntax: 'e') Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: '{ }') + NextVariables(0) "; VerifyOperationTreeForTest(source, expectedOperationTree); } @@ -611,11 +652,14 @@ void F(string s) } "; string expectedOperationTree = @" -IForEachLoopStatement (Iteration variable: System.Char x) (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (var x in s) { }') +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (var x in s) { }') + Locals: Local_1: System.Char x + LoopControlVariable: ILocalReferenceExpression: x (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: System.Char, Constant: null) (Syntax: 'foreach (var x in s) { }') Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.String) (Syntax: 's') Conversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) Operand: IParameterReferenceExpression: s (OperationKind.ParameterReferenceExpression, Type: System.String) (Syntax: 's') Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: '{ }') + NextVariables(0) "; VerifyOperationTreeForTest(source, expectedOperationTree); } @@ -636,11 +680,14 @@ class var { } } "; string expectedOperationTree = @" -IForEachLoopStatement (Iteration variable: C.var x) (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (var x in a) { }') +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (var x in a) { }') + Locals: Local_1: C.var x + LoopControlVariable: ILocalReferenceExpression: x (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: C.var, Constant: null) (Syntax: 'foreach (var x in a) { }') Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Collections.IEnumerable) (Syntax: 'a') Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: True, IsUserDefined: False) (MethodSymbol: null) Operand: IParameterReferenceExpression: a (OperationKind.ParameterReferenceExpression, Type: C.var[]) (Syntax: 'a') Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: '{ }') + NextVariables(0) "; VerifyOperationTreeForTest(source, expectedOperationTree); } @@ -659,11 +706,14 @@ void F(dynamic d) } "; string expectedOperationTree = @" -IForEachLoopStatement (Iteration variable: System.Int32 x) (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (int x in d) { }') +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (int x in d) { }') + Locals: Local_1: System.Int32 x + LoopControlVariable: ILocalReferenceExpression: x (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: System.Int32, Constant: null) (Syntax: 'foreach (int x in d) { }') Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Collections.IEnumerable) (Syntax: 'd') Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) Operand: IParameterReferenceExpression: d (OperationKind.ParameterReferenceExpression, Type: dynamic) (Syntax: 'd') Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: '{ }') + NextVariables(0) "; VerifyOperationTreeForTest(source, expectedOperationTree); } @@ -690,7 +740,9 @@ public class Enumerable } "; string expectedOperationTree = @" -IForEachLoopStatement (Iteration variable: System.Object x) (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (ob ... }') +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (ob ... }') + Locals: Local_1: System.Object x + LoopControlVariable: ILocalReferenceExpression: x (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: System.Object, Constant: null) (Syntax: 'foreach (ob ... }') Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: Enumerable) (Syntax: 'new Enumerable()') Conversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) Operand: IObjectCreationExpression (Constructor: Enumerable..ctor()) (OperationKind.ObjectCreationExpression, Type: Enumerable) (Syntax: 'new Enumerable()') @@ -705,6 +757,7 @@ public class Enumerable ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Object) (Syntax: 'x') InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + NextVariables(0) "; VerifyOperationTreeForTest(source, expectedOperationTree); } @@ -725,13 +778,16 @@ static void Main(string[] args) } "; string expectedOperationTree = @" -IForEachLoopStatement (Iteration variable: System.String x) (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (st ... e)args) { }') +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (st ... e)args) { }') + Locals: Local_1: System.String x + LoopControlVariable: ILocalReferenceExpression: x (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: System.String, Constant: null) (Syntax: 'foreach (st ... e)args) { }') Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Collections.IEnumerable) (Syntax: '(IEnumerable)args') Conversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) Operand: IConversionExpression (Explicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Collections.IEnumerable) (Syntax: '(IEnumerable)args') Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: True, IsUserDefined: False) (MethodSymbol: null) Operand: IParameterReferenceExpression: args (OperationKind.ParameterReferenceExpression, Type: System.String[]) (Syntax: 'args') Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: '{ }') + NextVariables(0) "; VerifyOperationTreeForTest(source, expectedOperationTree); @@ -760,7 +816,9 @@ static void Main() } "; string expectedOperationTree = @" -IForEachLoopStatement (Iteration variable: System.Int32 num) (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (in ... }') +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (in ... }') + Locals: Local_1: System.Int32 num + LoopControlVariable: ILocalReferenceExpression: num (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: System.Int32, Constant: null) (Syntax: 'foreach (in ... }') Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Collections.IEnumerable) (Syntax: 'numbers') Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: True, IsUserDefined: False) (MethodSymbol: null) Operand: ILocalReferenceExpression: numbers (OperationKind.LocalReferenceExpression, Type: System.Int32[]) (Syntax: 'numbers') @@ -788,8 +846,178 @@ static void Main() ILocalReferenceExpression: num (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'num') InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + NextVariables(0) "; VerifyOperationTreeForTest(source, expectedOperationTree); } + + [CompilerTrait(CompilerFeature.IOperation)] + [Fact, WorkItem(17602, "https://github.com/dotnet/roslyn/issues/17602")] + public void IForEachLoopStatement_WithDeconstructDeclaration() + { + string source = @" +class X +{ + public static void M((int, int)[] x) + { + /**/foreach (var (a, b) in x) + { + }/**/ + } +} +"; + string expectedOperationTree = @" +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (va ... }') + Locals: Local_1: System.Int32 a + Local_2: System.Int32 b + LoopControlVariable: IOperation: (OperationKind.None) (Syntax: 'var (a, b)') + Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Collections.IEnumerable) (Syntax: 'x') + Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: True, IsUserDefined: False) (MethodSymbol: null) + Operand: IParameterReferenceExpression: x (OperationKind.ParameterReferenceExpression, Type: (System.Int32, System.Int32)[]) (Syntax: 'x') + Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') + NextVariables(0) +"; + var expectedDiagnostics = DiagnosticDescription.None; + + VerifyOperationTreeAndDiagnosticsForTest(source, expectedOperationTree, expectedDiagnostics); + } + + [CompilerTrait(CompilerFeature.IOperation)] + [Fact, WorkItem(17602, "https://github.com/dotnet/roslyn/issues/17602")] + public void IForEachLoopStatement_WithNestedDeconstructDeclaration() + { + string source = @" +class X +{ + public static void M((int, (int, int))[] x) + { + /**/foreach (var (a, (b, c)) in x) + { + }/**/ + } +} +"; + string expectedOperationTree = @" +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (va ... }') + Locals: Local_1: System.Int32 a + Local_2: System.Int32 b + Local_3: System.Int32 c + LoopControlVariable: IOperation: (OperationKind.None) (Syntax: 'var (a, (b, c))') + Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Collections.IEnumerable) (Syntax: 'x') + Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: True, IsUserDefined: False) (MethodSymbol: null) + Operand: IParameterReferenceExpression: x (OperationKind.ParameterReferenceExpression, Type: (System.Int32, (System.Int32, System.Int32))[]) (Syntax: 'x') + Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') + NextVariables(0) +"; + var expectedDiagnostics = DiagnosticDescription.None; + + VerifyOperationTreeAndDiagnosticsForTest(source, expectedOperationTree, expectedDiagnostics); + } + + [CompilerTrait(CompilerFeature.IOperation)] + [Fact, WorkItem(17602, "https://github.com/dotnet/roslyn/issues/17602")] + public void IForEachLoopStatement_WithInvalidLoopControlVariable() + { + string source = @" +class X +{ + public static void M((int, int)[] x) + /**/{ + foreach (i, j in x) + { + } + }/**/ +} +"; + string expectedOperationTree = @" +IBlockStatement (4 statements) (OperationKind.BlockStatement, IsInvalid) (Syntax: '{ ... }') + IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement, IsInvalid) (Syntax: 'foreach (i') + LoopControlVariable: null + Collection: IInvalidExpression (OperationKind.InvalidExpression, Type: null, IsInvalid) (Syntax: '') + Children(0) + Body: IExpressionStatement (OperationKind.ExpressionStatement, IsInvalid) (Syntax: '') + Expression: IInvalidExpression (OperationKind.InvalidExpression, Type: null, IsInvalid) (Syntax: '') + Children(0) + NextVariables(0) + IExpressionStatement (OperationKind.ExpressionStatement, IsInvalid) (Syntax: 'j ') + Expression: IInvalidExpression (OperationKind.InvalidExpression, Type: ?, IsInvalid) (Syntax: 'j') + Children(0) + IExpressionStatement (OperationKind.ExpressionStatement, IsInvalid) (Syntax: 'x') + Expression: IParameterReferenceExpression: x (OperationKind.ParameterReferenceExpression, Type: (System.Int32, System.Int32)[], IsInvalid) (Syntax: 'x') + IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') +"; + var expectedDiagnostics = new DiagnosticDescription[] { + // CS1515: 'in' expected + // foreach (i, j in x) + Diagnostic(ErrorCode.ERR_InExpected, ",").WithLocation(6, 19), + // CS0230: Type and identifier are both required in a foreach statement + // foreach (i, j in x) + Diagnostic(ErrorCode.ERR_BadForeachDecl, ",").WithLocation(6, 19), + // CS1525: Invalid expression term ',' + // foreach (i, j in x) + Diagnostic(ErrorCode.ERR_InvalidExprTerm, ",").WithArguments(",").WithLocation(6, 19), + // CS1026: ) expected + // foreach (i, j in x) + Diagnostic(ErrorCode.ERR_CloseParenExpected, ",").WithLocation(6, 19), + // CS1525: Invalid expression term ',' + // foreach (i, j in x) + Diagnostic(ErrorCode.ERR_InvalidExprTerm, ",").WithArguments(",").WithLocation(6, 19), + // CS1002: ; expected + // foreach (i, j in x) + Diagnostic(ErrorCode.ERR_SemicolonExpected, ",").WithLocation(6, 19), + // CS1513: } expected + // foreach (i, j in x) + Diagnostic(ErrorCode.ERR_RbraceExpected, ",").WithLocation(6, 19), + // CS1002: ; expected + // foreach (i, j in x) + Diagnostic(ErrorCode.ERR_SemicolonExpected, "in").WithLocation(6, 23), + // CS1513: } expected + // foreach (i, j in x) + Diagnostic(ErrorCode.ERR_RbraceExpected, "in").WithLocation(6, 23), + // CS1002: ; expected + // foreach (i, j in x) + Diagnostic(ErrorCode.ERR_SemicolonExpected, ")").WithLocation(6, 27), + // CS1513: } expected + // foreach (i, j in x) + Diagnostic(ErrorCode.ERR_RbraceExpected, ")").WithLocation(6, 27), + // CS0103: The name 'j' does not exist in the current context + // foreach (i, j in x) + Diagnostic(ErrorCode.ERR_NameNotInContext, "j").WithArguments("j").WithLocation(6, 21) + }; + + VerifyOperationTreeAndDiagnosticsForTest(source, expectedOperationTree, expectedDiagnostics); + } + + [CompilerTrait(CompilerFeature.IOperation)] + [Fact, WorkItem(17602, "https://github.com/dotnet/roslyn/issues/17602")] + public void IForEachLoopStatement_WithInvalidLoopControlVariable_02() + { + string source = @" +class X +{ + public static void M(int[] x) + /**/{ + foreach (x[0] in x) + { + } + }/**/ +} +"; + string expectedOperationTree = @" +IBlockStatement (1 statements) (OperationKind.BlockStatement, IsInvalid) (Syntax: '{ ... }') + IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement, IsInvalid) (Syntax: 'foreach (x[ ... }') + LoopControlVariable: null + Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Collections.IEnumerable) (Syntax: 'x') + Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: True, IsUserDefined: False) (MethodSymbol: null) + Operand: IParameterReferenceExpression: x (OperationKind.ParameterReferenceExpression, Type: System.Int32[]) (Syntax: 'x') + Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') + NextVariables(0) +"; + var expectedDiagnostics = new DiagnosticDescription[] { + Diagnostic(ErrorCode.ERR_BadForeachDecl, "in").WithLocation(6, 23) + }; + + VerifyOperationTreeAndDiagnosticsForTest(source, expectedOperationTree, expectedDiagnostics); + } } } diff --git a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IForLoopStatement.cs b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IForLoopStatement.cs index 1aeb66e03d07437f1b5d9cd69d4c95a8c31d3b92..81463729fd6cdac70e6e3baf7586179c45bcd3cc 100644 --- a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IForLoopStatement.cs +++ b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IForLoopStatement.cs @@ -30,10 +30,10 @@ static void Main() "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int i ... }') + Locals: Local_1: System.Int32 i Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i < 3') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 3) (Syntax: '3') - Locals: Local_1: System.Int32 i Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'i = 0') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'i = 0') @@ -415,10 +415,10 @@ static void Main(string[] args) "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int k ... }') + Locals: Local_1: System.Int32 k Condition: IBinaryOperatorExpression (BinaryOperatorKind.GreaterThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'k > 100') Left: ILocalReferenceExpression: k (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'k') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 100) (Syntax: '100') - Locals: Local_1: System.Int32 k Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'k = 200') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'k = 200') @@ -491,10 +491,10 @@ static void Main(string[] args) "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int i ... = i + 1) ;') + Locals: Local_1: System.Int32 i Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i < 100') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 100) (Syntax: '100') - Locals: Local_1: System.Int32 i Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'i = 10') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'i = 10') @@ -532,10 +532,10 @@ static void Main(string[] args) "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int i ... }') + Locals: Local_1: System.Int32 i Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i < 100') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 100) (Syntax: '100') - Locals: Local_1: System.Int32 i Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'i = 0') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'i = 0') @@ -550,10 +550,10 @@ static void Main(string[] args) Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1') Body: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int j ... }') + Locals: Local_1: System.Int32 j Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'j < 10') Left: ILocalReferenceExpression: j (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'j') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') - Locals: Local_1: System.Int32 j Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'j = 0') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'j = 0') @@ -593,10 +593,10 @@ static void Main(string[] args) "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int i ... }') + Locals: Local_1: System.Int32 i Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i < 10') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') - Locals: Local_1: System.Int32 i Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'i = 0') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'i = 0') @@ -611,10 +611,10 @@ static void Main(string[] args) Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1') Body: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int j ... }') + Locals: Local_1: System.Int32 j Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'j < 10') Left: ILocalReferenceExpression: j (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'j') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') - Locals: Local_1: System.Int32 j Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'j = 0') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'j = 0') @@ -657,10 +657,10 @@ static void Main(string[] args) "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int i ... }') + Locals: Local_1: System.Int32 i Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i < 5') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 5) (Syntax: '5') - Locals: Local_1: System.Int32 i Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'i = 0') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'i = 0') @@ -675,10 +675,10 @@ static void Main(string[] args) Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1') Body: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int j ... }') + Locals: Local_1: System.Int32 j Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i < j') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILocalReferenceExpression: j (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'j') - Locals: Local_1: System.Int32 j Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'j = i + 1') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'j = i + 1') @@ -721,10 +721,10 @@ static void Main(string[] args) "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int i ... }') + Locals: Local_1: System.Int32 i Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i < 5') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 5) (Syntax: '5') - Locals: Local_1: System.Int32 i Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'i = 0') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'i = 0') @@ -739,10 +739,10 @@ static void Main(string[] args) Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1') Body: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int j ... }') + Locals: Local_1: System.Int32 j Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'j < 10') Left: ILocalReferenceExpression: j (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'j') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') - Locals: Local_1: System.Int32 j Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'j = 0') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'j = 0') @@ -790,10 +790,10 @@ static void Main(string[] args) "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int i ... }') + Locals: Local_1: System.Int32 i Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i < 5') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 5) (Syntax: '5') - Locals: Local_1: System.Int32 i Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'i = 0') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'i = 0') @@ -808,10 +808,10 @@ static void Main(string[] args) Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1') Body: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int j ... }') + Locals: Local_1: System.Int32 j Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'j < 10') Left: ILocalReferenceExpression: j (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'j') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') - Locals: Local_1: System.Int32 j Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'j = 1') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'j = 1') @@ -875,10 +875,10 @@ static void Main(string[] args) "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int i ... }') + Locals: Local_1: System.Int32 i Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i < 5') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 5) (Syntax: '5') - Locals: Local_1: System.Int32 i Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'i = 0') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'i = 0') @@ -893,10 +893,10 @@ static void Main(string[] args) Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1') Body: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int j ... }') + Locals: Local_1: System.Int32 j Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'j < 10') Left: ILocalReferenceExpression: j (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'j') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') - Locals: Local_1: System.Int32 j Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'j = 0') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'j = 0') @@ -944,10 +944,10 @@ static void Main(string[] args) "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int i ... }') + Locals: Local_1: System.Int32 i Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i < 10') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') - Locals: Local_1: System.Int32 i Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'i = 0') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'i = 0') @@ -962,10 +962,10 @@ static void Main(string[] args) Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1') Body: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int j ... }') + Locals: Local_1: System.Int32 j Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'j < 10') Left: ILocalReferenceExpression: j (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'j') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') - Locals: Local_1: System.Int32 j Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'j = 0') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'j = 0') @@ -1004,10 +1004,10 @@ static void Main(string[] args) "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int i ... }') + Locals: Local_1: System.Int32 i Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i < 10') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') - Locals: Local_1: System.Int32 i Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'i = 0') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'i = 0') @@ -1016,10 +1016,10 @@ static void Main(string[] args) AtLoopBottom(0) Body: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int j ... }') + Locals: Local_1: System.Int32 j Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'j < 5') Left: ILocalReferenceExpression: j (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'j') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 5) (Syntax: '5') - Locals: Local_1: System.Int32 j Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'j = 0') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'j = 0') @@ -1052,11 +1052,11 @@ static void Main(string[] args) "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int i ... }') + Locals: Local_1: System.Int32 i + Local_2: System.Int32 j Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i < 5') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 5) (Syntax: '5') - Locals: Local_1: System.Int32 i - Local_2: System.Int32 j Before: IVariableDeclarationStatement (2 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'int i = 0, j = 1') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'i = 0') @@ -1102,12 +1102,12 @@ static void Main(string[] args) "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int i ... }') + Locals: Local_1: System.Int32 i Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i < 50 - x') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: IBinaryOperatorExpression (BinaryOperatorKind.Subtract) (OperationKind.BinaryOperatorExpression, Type: System.Int32) (Syntax: '50 - x') Left: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 50) (Syntax: '50') Right: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x') - Locals: Local_1: System.Int32 i Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'i = 0') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'i = 0') @@ -1194,11 +1194,11 @@ public class F "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (F f = ... }') + Locals: Local_1: F f Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'f.i < 5') Left: IFieldReferenceExpression: System.Int32 F.i (OperationKind.FieldReferenceExpression, Type: System.Int32) (Syntax: 'f.i') Instance Receiver: ILocalReferenceExpression: f (OperationKind.LocalReferenceExpression, Type: F) (Syntax: 'f') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 5) (Syntax: '5') - Locals: Local_1: F f Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'f = new F { ... s = ""abc"" }') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'f = new F { ... s = ""abc"" }') @@ -1313,10 +1313,10 @@ static void Main(string[] args) "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (var i ... = i + 1) ;') + Locals: Local_1: System.Int32 i Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i < 5') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 5) (Syntax: '5') - Locals: Local_1: System.Int32 i Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'i = 1') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'i = 1') @@ -1361,8 +1361,8 @@ static void Main(string[] args) "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (IEnume ... }') - Condition: null Locals: Local_1: System.Collections.Generic.IEnumerable str + Condition: null Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'str = from ... select w') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'str = from ... select w') @@ -1443,7 +1443,9 @@ static void Main(string[] args) OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) AtLoopBottom(0) Body: IBlockStatement (2 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') - IForEachLoopStatement (Iteration variable: System.String item) (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (va ... }') + IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (va ... }') + Locals: Local_1: System.String item + LoopControlVariable: ILocalReferenceExpression: item (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: System.String, Constant: null) (Syntax: 'foreach (va ... }') Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Collections.Generic.IEnumerable) (Syntax: 'str') Conversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) Operand: ILocalReferenceExpression: str (OperationKind.LocalReferenceExpression, Type: System.Collections.Generic.IEnumerable) (Syntax: 'str') @@ -1456,6 +1458,7 @@ static void Main(string[] args) ILocalReferenceExpression: item (OperationKind.LocalReferenceExpression, Type: System.String) (Syntax: 'item') InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + NextVariables(0) IReturnStatement (OperationKind.ReturnStatement) (Syntax: 'return;') ReturnedValue: null "; @@ -1495,10 +1498,10 @@ private static IEnumerable fun() "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int i ... }') + Locals: Local_1: System.Int32 i Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i < 5') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 5) (Syntax: '5') - Locals: Local_1: System.Int32 i Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'i = 0') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'i = 0') @@ -1673,10 +1676,10 @@ static void Main(string[] args) "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int i ... }') + Locals: Local_1: System.Int32 i Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i < 5') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 5) (Syntax: '5') - Locals: Local_1: System.Int32 i Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'i = 1') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'i = 1') @@ -1748,6 +1751,7 @@ public class C1 "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (C1 i = ... l; i++) { }') + Locals: Local_1: C1 i Condition: IBinaryOperatorExpression (BinaryOperatorKind.Equals) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i == null') Left: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Object) (Syntax: 'i') Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: True, IsUserDefined: False) (MethodSymbol: null) @@ -1755,7 +1759,6 @@ public class C1 Right: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Object, Constant: null) (Syntax: 'null') Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: True, IsUserDefined: False) (MethodSymbol: null) Operand: ILiteralExpression (OperationKind.LiteralExpression, Type: null, Constant: null) (Syntax: 'null') - Locals: Local_1: C1 i Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'i = new C1()') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'i = new C1()') @@ -1791,10 +1794,10 @@ static void Main(string[] args) "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int j ... }') + Locals: Local_1: System.Int32 j Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'j < 5') Left: ILocalReferenceExpression: j (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'j') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 5) (Syntax: '5') - Locals: Local_1: System.Int32 j Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'j = i++') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'j = i++') @@ -1838,10 +1841,10 @@ static void Main(string[] args) "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int j ... }') + Locals: Local_1: System.Int32 j Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'j < 5') Left: ILocalReferenceExpression: j (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'j') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 5) (Syntax: '5') - Locals: Local_1: System.Int32 j Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'j = ++i') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'j = ++i') @@ -1883,11 +1886,11 @@ static void Main(string[] args) "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int i ... }') + Locals: Local_1: System.Int32 i Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: '++i < 5') Left: IIncrementExpression (PrefixIncrement) (OperationKind.IncrementExpression, Type: System.Int32) (Syntax: '++i') Target: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 5) (Syntax: '5') - Locals: Local_1: System.Int32 i Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'i = 0') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'i = 0') @@ -1930,6 +1933,7 @@ static int foo(int x) "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (int i ... }') + Locals: Local_1: System.Int32 i Condition: IBinaryOperatorExpression (BinaryOperatorKind.GreaterThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'foo(i--) > -5') Left: IInvocationExpression (System.Int32 Program.foo(System.Int32 x)) (OperationKind.InvocationExpression, Type: System.Int32) (Syntax: 'foo(i--)') Instance Receiver: null @@ -1941,7 +1945,6 @@ static int foo(int x) OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) Right: IUnaryOperatorExpression (UnaryOperatorKind.Minus) (OperationKind.UnaryOperatorExpression, Type: System.Int32, Constant: -5) (Syntax: '-5') Operand: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 5) (Syntax: '5') - Locals: Local_1: System.Int32 i Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'i = 0') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'i = 0') @@ -2012,11 +2015,11 @@ static void Main(string[] args) "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement, IsInvalid) (Syntax: 'for (int k ... 100, j > 5;') + Locals: Local_1: System.Int32 k + Local_2: System.Int32 j Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean, IsInvalid) (Syntax: 'k < 100') Left: ILocalReferenceExpression: k (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'k') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 100, IsInvalid) (Syntax: '100') - Locals: Local_1: System.Int32 k - Local_2: System.Int32 j Before: IVariableDeclarationStatement (2 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'int k = 0, j = 0') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'k = 0') @@ -2057,11 +2060,11 @@ private void M() "; string expectedOperationTree = @" IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'for (var j ... }') + Locals: Local_1: System.Int32 j + Local_2: System.Int32 i Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i < 10') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') - Locals: Local_1: System.Int32 j - Local_2: System.Int32 i Before: IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'j = int.Try ... i) ? i : 0') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'j = int.Try ... i) ? i : 0') diff --git a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IParameterReferenceExpression.cs b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IParameterReferenceExpression.cs index c8e7a08d3aedfadd09247b83eb15374faa831207..eb9894942166cbc9271ead0e0e5ac1f821cf40ac 100644 --- a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IParameterReferenceExpression.cs +++ b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IParameterReferenceExpression.cs @@ -993,7 +993,9 @@ static IEnumerable MyIterator(IEnumerable source, Func predica string expectedOperationTree = @" ILocalFunctionStatement (Symbol: System.Collections.Generic.IEnumerable Iterator()) (OperationKind.LocalFunctionStatement) (Syntax: 'IEnumerable ... }') IBlockStatement (2 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') - IForEachLoopStatement (Iteration variable: T element) (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (va ... rn element;') + IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (va ... rn element;') + Locals: Local_1: T element + LoopControlVariable: ILocalReferenceExpression: element (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: T, Constant: null) (Syntax: 'foreach (va ... rn element;') Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Collections.Generic.IEnumerable) (Syntax: 'source') Conversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) Operand: IParameterReferenceExpression: source (OperationKind.ParameterReferenceExpression, Type: System.Collections.Generic.IEnumerable) (Syntax: 'source') @@ -1008,6 +1010,7 @@ static IEnumerable MyIterator(IEnumerable source, Func predica IfTrue: IReturnStatement (OperationKind.YieldReturnStatement) (Syntax: 'yield return element;') ReturnedValue: ILocalReferenceExpression: element (OperationKind.LocalReferenceExpression, Type: T) (Syntax: 'element') IfFalse: null + NextVariables(0) IReturnStatement (OperationKind.YieldBreakStatement) (Syntax: '{ ... }') ReturnedValue: null "; diff --git a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_ITupleExpression.cs b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_ITupleExpression.cs index 1168e7c6dfca47e550f745d2b6bde3f2a23a06e5..fda91f2f10465054bdc2c9269ac0bda19de328f1 100644 --- a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_ITupleExpression.cs +++ b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_ITupleExpression.cs @@ -984,7 +984,10 @@ public void M() } "; string expectedOperationTree = @" -IForEachLoopStatement (Iteration variable: null) (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (va ... }') +IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (va ... }') + Locals: Local_1: System.UInt32 x + Local_2: System.UInt32 y + LoopControlVariable: IOperation: (OperationKind.None) (Syntax: 'var (x, y)') Collection: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Collections.IEnumerable) (Syntax: 'new Point[] ... int(0, 1) }') Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: True, IsUserDefined: False) (MethodSymbol: null) Operand: IArrayCreationExpression (Element Type: Point) (OperationKind.ArrayCreationExpression, Type: Point[]) (Syntax: 'new Point[] ... int(0, 1) }') @@ -1004,6 +1007,7 @@ public void M() OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) Initializer: null Body: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') + NextVariables(0) "; var expectedDiagnostics = DiagnosticDescription.None; diff --git a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IWhileUntilLoopStatement.cs b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IWhileUntilLoopStatement.cs index a79f685ee81d4c41b840f6b21161c29878aad320..203a20106119475d5c25d2a6ea3e1e2647ed6a9a 100644 --- a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IWhileUntilLoopStatement.cs +++ b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IWhileUntilLoopStatement.cs @@ -1,4 +1,4 @@ -// 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 Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Test.Utilities; @@ -33,10 +33,11 @@ static void Main() } "; string expectedOperationTree = @" -IWhileUntilLoopStatement (IsTopTest: False, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement) (Syntax: 'do ... le (i < 4);') +IDoLoopStatement (DoLoopKind: DoWhileBottomLoop) (LoopKind.Do) (OperationKind.LoopStatement) (Syntax: 'do ... le (i < 4);') Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i < 4') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 4) (Syntax: '4') + IgnoredCondition: null Body: IBlockStatement (2 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'sum += ids[i];') Expression: ICompoundAssignmentExpression (BinaryOperatorKind.Add) (OperationKind.CompoundAssignmentExpression, Type: System.Int32) (Syntax: 'sum += ids[i]') @@ -76,7 +77,7 @@ static int SumWhile() } "; string expectedOperationTree = @" -IWhileUntilLoopStatement (IsTopTest: True, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement) (Syntax: 'while (i < ... }') +IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement) (Syntax: 'while (i < ... }') Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i < 5') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 5) (Syntax: '5') @@ -117,7 +118,7 @@ static void Main() } "; string expectedOperationTree = @" -IWhileUntilLoopStatement (IsTopTest: True, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement) (Syntax: 'while (cond ... }') +IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement) (Syntax: 'while (cond ... }') Condition: ILocalReferenceExpression: condition (OperationKind.LocalReferenceExpression, Type: System.Boolean) (Syntax: 'condition') Body: IBlockStatement (2 statements, 1 locals) (OperationKind.BlockStatement) (Syntax: '{ ... }') Locals: Local_1: System.Int32 value @@ -166,7 +167,7 @@ static void Main() } "; string expectedOperationTree = @" -IWhileUntilLoopStatement (IsTopTest: True, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement) (Syntax: 'while (true ... }') +IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement) (Syntax: 'while (true ... }') Condition: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Boolean, Constant: True) (Syntax: 'true') Body: IBlockStatement (3 statements, 1 locals) (OperationKind.BlockStatement) (Syntax: '{ ... }') Locals: Local_1: System.Int32 value @@ -227,7 +228,7 @@ static void Main() } "; string expectedOperationTree = @" -IWhileUntilLoopStatement (IsTopTest: True, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement) (Syntax: 'while (true ... }') +IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement) (Syntax: 'while (true ... }') Condition: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Boolean, Constant: True) (Syntax: 'true') Body: IBlockStatement (3 statements, 1 locals) (OperationKind.BlockStatement) (Syntax: '{ ... }') Locals: Local_1: System.Int32 value @@ -285,7 +286,7 @@ static void Main() } "; string expectedOperationTree = @" -IWhileUntilLoopStatement (IsTopTest: True, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement) (Syntax: 'while ((i = ... }') +IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement) (Syntax: 'while ((i = ... }') Condition: IBinaryOperatorExpression (BinaryOperatorKind.GreaterThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: '(i = value) >= 0') Left: ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'i = value') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') @@ -336,7 +337,7 @@ static void Main() } "; string expectedOperationTree = @" -IWhileUntilLoopStatement (IsTopTest: True, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement, IsInvalid) (Syntax: 'while (numb ... }') +IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement, IsInvalid) (Syntax: 'while (numb ... }') Condition: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Boolean, IsInvalid) (Syntax: 'number') Conversion: CommonConversion (Exists: False, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) Operand: ILocalReferenceExpression: number (OperationKind.LocalReferenceExpression, Type: System.Int32, IsInvalid) (Syntax: 'number') @@ -372,7 +373,7 @@ public static int GetFirstEvenNumber(int number) "; string expectedOperationTree = @" -IWhileUntilLoopStatement (IsTopTest: True, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement) (Syntax: 'while (true ... }') +IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement) (Syntax: 'while (true ... }') Condition: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Boolean, Constant: True) (Syntax: 'true') Body: IBlockStatement (2 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') IIfStatement (OperationKind.IfStatement) (Syntax: 'if ((number ... }') @@ -419,7 +420,7 @@ public static int GetFirstEvenNumber(int number) } "; string expectedOperationTree = @" -IWhileUntilLoopStatement (IsTopTest: True, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement) (Syntax: 'while (true ... }') +IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement) (Syntax: 'while (true ... }') Condition: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Boolean, Constant: True) (Syntax: 'true') Body: IBlockStatement (3 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') IIfStatement (OperationKind.IfStatement) (Syntax: 'if ((number ... }') @@ -464,7 +465,7 @@ static void Main() } "; string expectedOperationTree = @" -IWhileUntilLoopStatement (IsTopTest: True, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement, IsInvalid) (Syntax: 'while () ... }') +IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement, IsInvalid) (Syntax: 'while () ... }') Condition: IInvalidExpression (OperationKind.InvalidExpression, Type: null, IsInvalid) (Syntax: '') Children(0) Body: IBlockStatement (2 statements, 1 locals) (OperationKind.BlockStatement) (Syntax: '{ ... }') @@ -506,7 +507,7 @@ static void Main() } "; string expectedOperationTree = @" -IWhileUntilLoopStatement (IsTopTest: True, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement) (Syntax: 'while(i <= ... }') +IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement) (Syntax: 'while(i <= ... }') Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i <= 10') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') @@ -538,7 +539,7 @@ static void Main() } "; string expectedOperationTree = @" -IWhileUntilLoopStatement (IsTopTest: True, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement) (Syntax: 'while(i <= ... }') +IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement) (Syntax: 'while(i <= ... }') Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i <= 10') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') @@ -590,7 +591,7 @@ static void Main() } "; string expectedOperationTree = @" -IWhileUntilLoopStatement (IsTopTest: True, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement) (Syntax: 'while(i<10) ... }') +IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement) (Syntax: 'while(i<10) ... }') Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i<10') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') @@ -603,7 +604,7 @@ static void Main() IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'int j = 0;') Variables: Local_1: System.Int32 j Initializer: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 0) (Syntax: '0') - IWhileUntilLoopStatement (IsTopTest: True, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement) (Syntax: 'while (j < ... }') + IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement) (Syntax: 'while (j < ... }') Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'j < 10') Left: ILocalReferenceExpression: j (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'j') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') @@ -657,7 +658,7 @@ static void Main() } "; string expectedOperationTree = @" -IWhileUntilLoopStatement (IsTopTest: True, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement) (Syntax: 'while(i<10) ... }') +IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement) (Syntax: 'while(i<10) ... }') Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i<10') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') @@ -670,7 +671,7 @@ static void Main() IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'int j = 0;') Variables: Local_1: System.Int32 j Initializer: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 0) (Syntax: '0') - IWhileUntilLoopStatement (IsTopTest: True, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement) (Syntax: 'while (j < ... }') + IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement) (Syntax: 'while (j < ... }') Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'j < 10') Left: ILocalReferenceExpression: j (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'j') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') @@ -748,7 +749,7 @@ public void Next() } "; string expectedOperationTree = @" -IWhileUntilLoopStatement (IsTopTest: True, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement) (Syntax: 'while (d.Do ... }') +IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement) (Syntax: 'while (d.Do ... }') Condition: IUnaryOperatorExpression (UnaryOperatorKind.True) (OperationKind.UnaryOperatorExpression, Type: System.Boolean) (Syntax: 'd.Done') Operand: IDynamicMemberReferenceExpression (Member Name: ""Done"", Containing Type: null) (OperationKind.DynamicMemberReferenceExpression, Type: dynamic) (Syntax: 'd.Done') Type Arguments(0) @@ -783,7 +784,7 @@ static void Main(string[] args) "; string expectedOperationTree = @" -IWhileUntilLoopStatement (IsTopTest: True, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement) (Syntax: 'while ( ++i ... }') +IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement) (Syntax: 'while ( ++i ... }') Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: '++i < 5') Left: IIncrementExpression (PrefixIncrement) (OperationKind.IncrementExpression, Type: System.Int32) (Syntax: '++i') Target: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') @@ -818,7 +819,7 @@ static void Main(string[] args) } }"; string expectedOperationTree = @" -IWhileUntilLoopStatement (IsTopTest: True, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement) (Syntax: 'while (i > ... }') +IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement) (Syntax: 'while (i > ... }') Condition: IBinaryOperatorExpression (BinaryOperatorKind.GreaterThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i > 0') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 0) (Syntax: '0') @@ -848,7 +849,7 @@ bool foo() } "; string expectedOperationTree = @" -IWhileUntilLoopStatement (IsTopTest: True, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement) (Syntax: 'while (b == ... }') +IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement) (Syntax: 'while (b == ... }') Condition: IBinaryOperatorExpression (BinaryOperatorKind.Equals) (OperationKind.BinaryOperatorExpression, Type: System.Boolean, Constant: True) (Syntax: 'b == b') Left: ILocalReferenceExpression: b (OperationKind.LocalReferenceExpression, Type: System.Boolean, Constant: True) (Syntax: 'b') Right: ILocalReferenceExpression: b (OperationKind.LocalReferenceExpression, Type: System.Boolean, Constant: True) (Syntax: 'b') @@ -885,7 +886,7 @@ public void TryMethod() } "; string expectedOperationTree = @" -IWhileUntilLoopStatement (IsTopTest: True, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement) (Syntax: 'while (x-- ... }') +IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement) (Syntax: 'while (x-- ... }') Condition: IBinaryOperatorExpression (BinaryOperatorKind.GreaterThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'x-- > 0') Left: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Int32) (Syntax: 'x--') Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: True, IsReference: False, IsUserDefined: False) (MethodSymbol: null) @@ -948,7 +949,8 @@ static bool TakeOutParam(T y, out T x) } "; string expectedOperationTree = @" -IWhileUntilLoopStatement (IsTopTest: True, IsWhile: True) (LoopKind.WhileUntil) (OperationKind.LoopStatement) (Syntax: 'while (Dumm ... }') +IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement) (Syntax: 'while (Dumm ... }') + Locals: Local_1: System.Int32 x1 Condition: IInvocationExpression (System.Boolean X.Dummy(System.Boolean x, System.Object y, System.Object z)) (OperationKind.InvocationExpression, Type: System.Boolean) (Syntax: 'Dummy(f, Ta ... ar x1), x1)') Instance Receiver: null Arguments(3): @@ -997,5 +999,82 @@ static bool TakeOutParam(T y, out T x) "; VerifyOperationTreeForTest(source, expectedOperationTree); } + + [CompilerTrait(CompilerFeature.IOperation)] + [Fact, WorkItem(17602, "https://github.com/dotnet/roslyn/issues/17602")] + public void IWhileUntilLoopStatement_DoWithOutVar() + { + string source = @" +class X +{ + public static void Main() + { + bool f = true; + + /**/do + { + f = false; + } while (Dummy(f, TakeOutParam((f ? 1 : 2), out var x1), x1));/**/ + } + + static bool Dummy(bool x, object y, object z) + { + System.Console.WriteLine(z); + return x; + } + + static bool TakeOutParam(T y, out T x) + { + x = y; + return true; + } +} +"; + string expectedOperationTree = @" +IDoLoopStatement (DoLoopKind: DoWhileBottomLoop) (LoopKind.Do) (OperationKind.LoopStatement) (Syntax: 'do ... x1), x1));') + Locals: Local_1: System.Int32 x1 + Condition: IInvocationExpression (System.Boolean X.Dummy(System.Boolean x, System.Object y, System.Object z)) (OperationKind.InvocationExpression, Type: System.Boolean) (Syntax: 'Dummy(f, Ta ... ar x1), x1)') + Instance Receiver: null + Arguments(3): + IArgument (ArgumentKind.Explicit, Matching Parameter: x) (OperationKind.Argument) (Syntax: 'f') + ILocalReferenceExpression: f (OperationKind.LocalReferenceExpression, Type: System.Boolean) (Syntax: 'f') + InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + IArgument (ArgumentKind.Explicit, Matching Parameter: y) (OperationKind.Argument) (Syntax: 'TakeOutPara ... out var x1)') + IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Object) (Syntax: 'TakeOutPara ... out var x1)') + Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + Operand: IInvocationExpression (System.Boolean X.TakeOutParam(System.Int32 y, out System.Int32 x)) (OperationKind.InvocationExpression, Type: System.Boolean) (Syntax: 'TakeOutPara ... out var x1)') + Instance Receiver: null + Arguments(2): + IArgument (ArgumentKind.Explicit, Matching Parameter: y) (OperationKind.Argument) (Syntax: 'f ? 1 : 2') + IConditionalExpression (OperationKind.ConditionalExpression, Type: System.Int32) (Syntax: 'f ? 1 : 2') + Condition: ILocalReferenceExpression: f (OperationKind.LocalReferenceExpression, Type: System.Boolean) (Syntax: 'f') + WhenTrue: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1') + WhenFalse: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 2) (Syntax: '2') + InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + IArgument (ArgumentKind.Explicit, Matching Parameter: x) (OperationKind.Argument) (Syntax: 'var x1') + ILocalReferenceExpression: x1 (IsDeclaration: True) (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'var x1') + InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + IArgument (ArgumentKind.Explicit, Matching Parameter: z) (OperationKind.Argument) (Syntax: 'x1') + IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Object) (Syntax: 'x1') + Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + Operand: ILocalReferenceExpression: x1 (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x1') + InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + IgnoredCondition: null + Body: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') + IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'f = false;') + Expression: ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Boolean) (Syntax: 'f = false') + Left: ILocalReferenceExpression: f (OperationKind.LocalReferenceExpression, Type: System.Boolean) (Syntax: 'f') + Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Boolean, Constant: False) (Syntax: 'false') +"; + var expectedDiagnostics = DiagnosticDescription.None; + + VerifyOperationTreeAndDiagnosticsForTest(source, expectedOperationTree, expectedDiagnostics); + } } } diff --git a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs index 5075edb13c0b86de3e2a274a8e8a5788d760d014..8bdc47ed114611a85efd34ab7741be3c1579e39b 100644 --- a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs +++ b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs @@ -1698,33 +1698,47 @@ public LazyFixedStatement(Lazy variables, Lazy - /// Represents a C# foreach statement or a VB For Each statement. + /// Represents a C# 'foreach' statement or a VB 'For Each' statement. /// internal abstract partial class BaseForEachLoopStatement : LoopStatement, IForEachLoopStatement { - public BaseForEachLoopStatement(ILocalSymbol iterationVariable, LoopKind loopKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : - base(loopKind, OperationKind.LoopStatement, semanticModel, syntax, type, constantValue, isImplicit) + public BaseForEachLoopStatement(ImmutableArray locals, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(LoopKind.ForEach, locals, OperationKind.LoopStatement, semanticModel, syntax, type, constantValue, isImplicit) { - IterationVariable = iterationVariable; } - /// - /// Iteration variable of the loop. - /// - public ILocalSymbol IterationVariable { get; } + protected abstract IOperation LoopControlVariableImpl { get; } protected abstract IOperation CollectionImpl { get; } + protected abstract ImmutableArray NextVariablesImpl { get; } public override IEnumerable Children { get { + if (LoopControlVariable != null) + { + yield return LoopControlVariable; + } yield return Collection; yield return Body; + foreach (var expression in NextVariables) + { + yield return expression; + } } } /// + /// Optional loop control variable in VB that refers to the operation for declaring a new local variable or reference an existing variable or an expression. + /// This field is always null for C#. + /// + public IOperation LoopControlVariable => Operation.SetParentOperation(LoopControlVariableImpl, this); + /// /// Collection value over which the loop iterates. /// public IOperation Collection => Operation.SetParentOperation(CollectionImpl, this); - + /// + /// Optional list of comma separate operations to execute at loop bottom for VB. + /// This list is always empty for C#. + /// + public ImmutableArray NextVariables => Operation.SetParentOperation(NextVariablesImpl, this); public override void Accept(OperationVisitor visitor) { visitor.VisitForEachLoopStatement(this); @@ -1736,57 +1750,63 @@ public override void Accept(OperationVisitor visitor) } /// - /// Represents a C# foreach statement or a VB For Each statement. + /// Represents a C# 'foreach' statement or a VB 'For Each' statement. /// internal sealed partial class ForEachLoopStatement : BaseForEachLoopStatement, IForEachLoopStatement { - public ForEachLoopStatement(ILocalSymbol iterationVariable, IOperation collection, LoopKind loopKind, IOperation body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : - base(iterationVariable, loopKind, semanticModel, syntax, type, constantValue, isImplicit) + public ForEachLoopStatement(ImmutableArray locals, IOperation loopControlVariable, IOperation collection, ImmutableArray nextVariables, IOperation body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(locals, semanticModel, syntax, type, constantValue, isImplicit) { + LoopControlVariableImpl = loopControlVariable; CollectionImpl = collection; + NextVariablesImpl = nextVariables; BodyImpl = body; } + protected override IOperation LoopControlVariableImpl { get; } protected override IOperation CollectionImpl { get; } + protected override ImmutableArray NextVariablesImpl { get; } protected override IOperation BodyImpl { get; } } /// - /// Represents a C# foreach statement or a VB For Each statement. + /// Represents a C# 'foreach' statement or a VB 'For Each' statement. /// internal sealed partial class LazyForEachLoopStatement : BaseForEachLoopStatement, IForEachLoopStatement { + private readonly Lazy _lazyLoopControlVariable; private readonly Lazy _lazyCollection; + private readonly Lazy> _lazyNextVariables; private readonly Lazy _lazyBody; - public LazyForEachLoopStatement(ILocalSymbol iterationVariable, Lazy collection, LoopKind loopKind, Lazy body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : - base(iterationVariable, loopKind, semanticModel, syntax, type, constantValue, isImplicit) + public LazyForEachLoopStatement(ImmutableArray locals, Lazy loopControlVariable, Lazy collection, Lazy> nextVariables, Lazy body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(locals, semanticModel, syntax, type, constantValue, isImplicit) { + _lazyLoopControlVariable = loopControlVariable ?? throw new System.ArgumentNullException(nameof(loopControlVariable)); _lazyCollection = collection ?? throw new System.ArgumentNullException(nameof(collection)); + _lazyNextVariables = nextVariables ?? throw new System.ArgumentNullException(nameof(nextVariables)); _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); } + protected override IOperation LoopControlVariableImpl => _lazyLoopControlVariable.Value; protected override IOperation CollectionImpl => _lazyCollection.Value; + protected override ImmutableArray NextVariablesImpl => _lazyNextVariables.Value; protected override IOperation BodyImpl => _lazyBody.Value; } /// - /// Represents a C# for statement or a VB For statement. + /// Represents a C# 'for' loop statement. /// - internal abstract partial class BaseForLoopStatement : ForWhileUntilLoopStatement, IForLoopStatement + internal abstract partial class BaseForLoopStatement : LoopStatement, IForLoopStatement { - public BaseForLoopStatement(ImmutableArray locals, LoopKind loopKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : - base(loopKind, OperationKind.LoopStatement, semanticModel, syntax, type, constantValue, isImplicit) + public BaseForLoopStatement(ImmutableArray locals, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(LoopKind.For, locals, OperationKind.LoopStatement, semanticModel, syntax, type, constantValue, isImplicit) { - Locals = locals; } protected abstract ImmutableArray BeforeImpl { get; } + protected abstract IOperation ConditionImpl { get; } protected abstract ImmutableArray AtLoopBottomImpl { get; } - /// - /// Declarations local to the loop. - /// - public ImmutableArray Locals { get; } public override IEnumerable Children { get @@ -1796,19 +1816,23 @@ public override IEnumerable Children yield return before; } yield return Condition; - yield return Body; foreach (var atLoopBottom in AtLoopBottom) { yield return atLoopBottom; } + yield return Body; } } /// - /// Statements to execute before entry to the loop. For C# these come from the first clause of the for statement. For VB these initialize the index variable of the For statement. + /// List of operations to execute before entry to the loop. This comes from the first clause of the for statement. /// public ImmutableArray Before => Operation.SetParentOperation(BeforeImpl, this); /// - /// Statements to execute at the bottom of the loop. For C# these come from the third clause of the for statement. For VB these increment the index variable of the For statement. + /// Condition of the loop. This comes from the second clause of the for statement. + /// + public IOperation Condition => Operation.SetParentOperation(ConditionImpl, this); + /// + /// List of operations to execute at the bottom of the loop. This comes from the third clause of the for statement. /// public ImmutableArray AtLoopBottom => Operation.SetParentOperation(AtLoopBottomImpl, this); @@ -1823,67 +1847,171 @@ public override void Accept(OperationVisitor visitor) } /// - /// Represents a C# for statement or a VB For statement. + /// Represents a C# 'for' loop statement. /// internal sealed partial class ForLoopStatement : BaseForLoopStatement, IForLoopStatement { - public ForLoopStatement(ImmutableArray before, ImmutableArray atLoopBottom, ImmutableArray locals, IOperation condition, LoopKind loopKind, IOperation body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : - base(locals, loopKind, semanticModel, syntax, type, constantValue, isImplicit) + public ForLoopStatement(ImmutableArray before, IOperation condition, ImmutableArray atLoopBottom, ImmutableArray locals, IOperation body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(locals, semanticModel, syntax, type, constantValue, isImplicit) { BeforeImpl = before; - AtLoopBottomImpl = atLoopBottom; ConditionImpl = condition; + AtLoopBottomImpl = atLoopBottom; BodyImpl = body; } protected override ImmutableArray BeforeImpl { get; } - protected override ImmutableArray AtLoopBottomImpl { get; } protected override IOperation ConditionImpl { get; } + protected override ImmutableArray AtLoopBottomImpl { get; } protected override IOperation BodyImpl { get; } } /// - /// Represents a C# for statement or a VB For statement. + /// Represents a C# 'for' loop statement. /// internal sealed partial class LazyForLoopStatement : BaseForLoopStatement, IForLoopStatement { private readonly Lazy> _lazyBefore; - private readonly Lazy> _lazyAtLoopBottom; private readonly Lazy _lazyCondition; + private readonly Lazy> _lazyAtLoopBottom; private readonly Lazy _lazyBody; - public LazyForLoopStatement(Lazy> before, Lazy> atLoopBottom, ImmutableArray locals, Lazy condition, LoopKind loopKind, Lazy body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : - base(locals, loopKind, semanticModel, syntax, type, constantValue, isImplicit) + public LazyForLoopStatement(Lazy> before, Lazy condition, Lazy> atLoopBottom, ImmutableArray locals, Lazy body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(locals, semanticModel, syntax, type, constantValue, isImplicit) { - _lazyBefore = before; - _lazyAtLoopBottom = atLoopBottom; + _lazyBefore = before ?? throw new System.ArgumentNullException(nameof(before)); _lazyCondition = condition ?? throw new System.ArgumentNullException(nameof(condition)); + _lazyAtLoopBottom = atLoopBottom ?? throw new System.ArgumentNullException(nameof(atLoopBottom)); _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); } protected override ImmutableArray BeforeImpl => _lazyBefore.Value; - - protected override ImmutableArray AtLoopBottomImpl => _lazyAtLoopBottom.Value; - protected override IOperation ConditionImpl => _lazyCondition.Value; - + protected override ImmutableArray AtLoopBottomImpl => _lazyAtLoopBottom.Value; protected override IOperation BodyImpl => _lazyBody.Value; } /// - /// Represents a C# while, for, or do statement, or a VB While, For, or Do statement. + /// Represents a VB 'For To' loop statement. /// - internal abstract partial class ForWhileUntilLoopStatement : LoopStatement, IForWhileUntilLoopStatement + internal abstract partial class BaseForToLoopStatement : LoopStatement, IForToLoopStatement { - protected ForWhileUntilLoopStatement(LoopKind loopKind, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : - base(loopKind, kind, semanticModel, syntax, type, constantValue, isImplicit) + public BaseForToLoopStatement(ImmutableArray locals, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(LoopKind.ForTo, locals, OperationKind.LoopStatement, semanticModel, syntax, type, constantValue, isImplicit) { } - protected abstract IOperation ConditionImpl { get; } + + protected abstract IOperation LoopControlVariableImpl { get; } + protected abstract IOperation InitialValueImpl { get; } + protected abstract IOperation LimitValueImpl { get; } + protected abstract IOperation StepValueImpl { get; } + protected abstract ImmutableArray NextVariablesImpl { get; } + public override IEnumerable Children + { + get + { + if (LoopControlVariable != null) + { + yield return LoopControlVariable; + } + yield return InitialValue; + yield return LimitValue; + yield return StepValue; + yield return Body; + foreach (var expression in NextVariables) + { + yield return expression; + } + } + } /// - /// Condition of the loop. + /// Loop control variable refers to the operation for declaring a new local variable or reference an existing variable or an expression. /// - public IOperation Condition => Operation.SetParentOperation(ConditionImpl, this); + public IOperation LoopControlVariable => Operation.SetParentOperation(LoopControlVariableImpl, this); + + /// + /// Operation for setting the initial value of the loop control variable. This comes from the expression between the 'For' and 'To' keywords. + /// + public IOperation InitialValue => Operation.SetParentOperation(InitialValueImpl, this); + + /// + /// Operation for the limit value of the loop control variable. This comes from the expression after the 'To' keyword. + /// + public IOperation LimitValue => Operation.SetParentOperation(LimitValueImpl, this); + + /// + /// Optional operation for the step value of the loop control variable. This comes from the expression after the 'Step' keyword. + /// + public IOperation StepValue => Operation.SetParentOperation(StepValueImpl, this); + + /// + /// Optional list of comma separated next variables at loop bottom. + /// + public ImmutableArray NextVariables => Operation.SetParentOperation(NextVariablesImpl, this); + + public override void Accept(OperationVisitor visitor) + { + visitor.VisitForToLoopStatement(this); + } + public override TResult Accept(OperationVisitor visitor, TArgument argument) + { + return visitor.VisitForToLoopStatement(this, argument); + } + } + + /// + /// Represents a VB 'For To' loop statement. + /// + internal sealed partial class ForToLoopStatement : BaseForToLoopStatement, IForToLoopStatement + { + public ForToLoopStatement(ImmutableArray locals, IOperation loopControlVariable, IOperation initialValue, IOperation limitValue, IOperation stepValue, IOperation body, ImmutableArray nextVariables, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(locals, semanticModel, syntax, type, constantValue, isImplicit) + { + LoopControlVariableImpl = loopControlVariable; + InitialValueImpl = initialValue; + LimitValueImpl = limitValue; + StepValueImpl = stepValue; + BodyImpl = body; + NextVariablesImpl = nextVariables; + } + + protected override IOperation LoopControlVariableImpl { get; } + protected override IOperation InitialValueImpl { get; } + protected override IOperation LimitValueImpl { get; } + protected override IOperation StepValueImpl { get; } + protected override IOperation BodyImpl { get; } + protected override ImmutableArray NextVariablesImpl { get; } + } + + /// + /// Represents a VB 'For To' loop statement. + /// + internal sealed partial class LazyForToLoopStatement : BaseForToLoopStatement, IForToLoopStatement + { + private readonly Lazy _lazyLoopControlVariable; + private readonly Lazy _lazyInitialValue; + private readonly Lazy _lazyLimitValue; + private readonly Lazy _lazyStepValue; + private readonly Lazy _lazyBody; + private readonly Lazy> _lazyNextVariables; + + public LazyForToLoopStatement(ImmutableArray locals, Lazy loopControlVariable, Lazy initialValue, Lazy limitValue, Lazy stepValue, Lazy body, Lazy> nextVariables, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(locals, semanticModel, syntax, type, constantValue, isImplicit) + { + _lazyLoopControlVariable = loopControlVariable ?? throw new System.ArgumentNullException(nameof(loopControlVariable)); + _lazyInitialValue = initialValue ?? throw new System.ArgumentNullException(nameof(initialValue)); + _lazyLimitValue = limitValue ?? throw new System.ArgumentNullException(nameof(limitValue)); + _lazyStepValue = stepValue ?? throw new System.ArgumentNullException(nameof(stepValue)); + _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); + _lazyNextVariables = nextVariables ?? throw new System.ArgumentNullException(nameof(nextVariables)); + } + + protected override IOperation LoopControlVariableImpl => _lazyLoopControlVariable.Value; + protected override IOperation InitialValueImpl => _lazyInitialValue.Value; + protected override IOperation LimitValueImpl => _lazyLimitValue.Value; + protected override IOperation StepValueImpl => _lazyStepValue.Value; + protected override IOperation BodyImpl => _lazyBody.Value; + protected override ImmutableArray NextVariablesImpl => _lazyNextVariables.Value; } /// @@ -2903,10 +3031,11 @@ public LazyLockStatement(Lazy lockedObject, Lazy body, S /// internal abstract partial class LoopStatement : Operation, ILoopStatement { - protected LoopStatement(LoopKind loopKind, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + protected LoopStatement(LoopKind loopKind, ImmutableArray locals, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(kind, semanticModel, syntax, type, constantValue, isImplicit) { LoopKind = loopKind; + Locals = locals; } protected abstract IOperation BodyImpl { get; } /// @@ -2914,6 +3043,10 @@ internal abstract partial class LoopStatement : Operation, ILoopStatement /// public LoopKind LoopKind { get; } /// + /// Declarations local to the loop. + /// + public ImmutableArray Locals { get; } + /// /// Body of the loop. /// public IOperation Body => Operation.SetParentOperation(BodyImpl, this); @@ -4188,60 +4321,6 @@ internal abstract partial class SymbolInitializer : Operation, ISymbolInitialize public IOperation Value => Operation.SetParentOperation(ValueImpl, this); } - /// - /// Represents a reference to a local variable synthesized by language analysis. - /// - internal abstract partial class BaseSyntheticLocalReferenceExpression : Operation, ISyntheticLocalReferenceExpression - { - protected BaseSyntheticLocalReferenceExpression(SyntheticLocalKind syntheticLocalKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : - base(OperationKind.SyntheticLocalReferenceExpression, semanticModel, syntax, type, constantValue, isImplicit) - { - SyntheticLocalKind = syntheticLocalKind; - } - /// - /// Kind of the synthetic local. - /// - public SyntheticLocalKind SyntheticLocalKind { get; } - - public override IEnumerable Children - { - get - { - yield break; - } - } - public override void Accept(OperationVisitor visitor) - { - visitor.VisitSyntheticLocalReferenceExpression(this); - } - public override TResult Accept(OperationVisitor visitor, TArgument argument) - { - return visitor.VisitSyntheticLocalReferenceExpression(this, argument); - } - } - - /// - /// Represents a reference to a local variable synthesized by language analysis. - /// - internal sealed partial class SyntheticLocalReferenceExpression : BaseSyntheticLocalReferenceExpression, ISyntheticLocalReferenceExpression - { - public SyntheticLocalReferenceExpression(SyntheticLocalKind syntheticLocalKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : - base(syntheticLocalKind, semanticModel, syntax, type, constantValue, isImplicit) - { - } - } - - /// - /// Represents a reference to a local variable synthesized by language analysis. - /// - internal sealed partial class LazySyntheticLocalReferenceExpression : BaseSyntheticLocalReferenceExpression, ISyntheticLocalReferenceExpression - { - public LazySyntheticLocalReferenceExpression(SyntheticLocalKind syntheticLocalKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : - base(syntheticLocalKind, semanticModel, syntax, type, constantValue, isImplicit) - { - } - } - /// /// Represents a C# try or a VB Try statement. /// @@ -4896,24 +4975,102 @@ public LazyVariableDeclarationStatement(Lazy - /// Represents a C# while or do statement, or a VB While or Do statement. + /// Represents a C# 'do while' or VB 'Do While' or 'Do Until' loop statement. /// - internal abstract partial class BaseWhileUntilLoopStatement : ForWhileUntilLoopStatement, IWhileUntilLoopStatement + internal abstract partial class BaseDoLoopStatement : LoopStatement, IDoLoopStatement { - public BaseWhileUntilLoopStatement(bool isTopTest, bool isWhile, LoopKind loopKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : - base(loopKind, OperationKind.LoopStatement, semanticModel, syntax, type, constantValue, isImplicit) + public BaseDoLoopStatement(DoLoopKind doLoopKind, ImmutableArray locals, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(LoopKind.Do, locals, OperationKind.LoopStatement, semanticModel, syntax, type, constantValue, isImplicit) { - IsTopTest = isTopTest; - IsWhile = isWhile; + DoLoopKind = doLoopKind; } /// - /// True if the loop test executes at the top of the loop; false if the loop test executes at the bottom of the loop. + /// Represents kind of do loop statement. /// - public bool IsTopTest { get; } + public DoLoopKind DoLoopKind { get; } + protected abstract IOperation ConditionImpl { get; } + protected abstract IOperation IgnoredConditionImpl { get; } + public override IEnumerable Children + { + get + { + yield return Condition; + yield return Body; + if (IgnoredCondition != null) + { + yield return IgnoredCondition; + } + } + } /// - /// True if the loop is a while loop; false if the loop is an until loop. + /// Condition of the loop. /// - public bool IsWhile { get; } + public IOperation Condition => Operation.SetParentOperation(ConditionImpl, this); + /// + /// Additional conditional supplied for loop in error cases, which is ignored by the compiler. + /// For example, for VB 'Do While' or 'Do Until' loop with syntax errors where both the top and bottom conditions are provided. + /// The top condition is preferred and exposed as and the bottom condition is ignored and exposed by this property. + /// This property should be null for all non-error cases. + /// + public IOperation IgnoredCondition => Operation.SetParentOperation(IgnoredConditionImpl, this); + public override void Accept(OperationVisitor visitor) + { + visitor.VisitDoLoopStatement(this); + } + public override TResult Accept(OperationVisitor visitor, TArgument argument) + { + return visitor.VisitDoLoopStatement(this, argument); + } + } + + /// + /// Represents a C# 'do while' or VB 'Do While' or 'Do Until' loop statement. + /// + internal sealed partial class DoLoopStatement : BaseDoLoopStatement, IDoLoopStatement + { + public DoLoopStatement(DoLoopKind doLoopKind, IOperation condition, IOperation body, IOperation ignoredConditionOpt, ImmutableArray locals, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(doLoopKind, locals, semanticModel, syntax, type, constantValue, isImplicit) + { + ConditionImpl = condition; + BodyImpl = body; + IgnoredConditionImpl = ignoredConditionOpt; + } + protected override IOperation ConditionImpl { get; } + protected override IOperation BodyImpl { get; } + protected override IOperation IgnoredConditionImpl { get; } + } + + /// + /// Represents a C# 'do while' or VB 'Do While' or 'Do Until' loop statement. + /// + internal sealed partial class LazyDoLoopStatement : BaseDoLoopStatement, IDoLoopStatement + { + private readonly Lazy _lazyCondition; + private readonly Lazy _lazyBody; + private readonly Lazy _lazyIgnoredCondition; + + public LazyDoLoopStatement(DoLoopKind doLoopKind, Lazy condition, Lazy body, Lazy ignoredCondition, ImmutableArray locals, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(doLoopKind, locals, semanticModel, syntax, type, constantValue, isImplicit) + { + _lazyCondition = condition ?? throw new System.ArgumentNullException(nameof(condition)); + _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); + _lazyIgnoredCondition = ignoredCondition ?? throw new System.ArgumentNullException(nameof(ignoredCondition)); + } + protected override IOperation ConditionImpl => _lazyCondition.Value; + protected override IOperation BodyImpl => _lazyBody.Value; + protected override IOperation IgnoredConditionImpl => _lazyIgnoredCondition.Value; + } + + /// + /// Represents a C# 'while' or a VB 'While' loop statement. + /// + internal abstract partial class BaseWhileLoopStatement : LoopStatement, IWhileLoopStatement + { + public BaseWhileLoopStatement(ImmutableArray locals, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(LoopKind.While, locals, OperationKind.LoopStatement, semanticModel, syntax, type, constantValue, isImplicit) + { + } + protected abstract IOperation ConditionImpl { get; } public override IEnumerable Children { get @@ -4922,24 +5079,27 @@ public override IEnumerable Children yield return Body; } } - + /// + /// Condition of the loop. + /// + public IOperation Condition => Operation.SetParentOperation(ConditionImpl, this); public override void Accept(OperationVisitor visitor) { - visitor.VisitWhileUntilLoopStatement(this); + visitor.VisitWhileLoopStatement(this); } public override TResult Accept(OperationVisitor visitor, TArgument argument) { - return visitor.VisitWhileUntilLoopStatement(this, argument); + return visitor.VisitWhileLoopStatement(this, argument); } } /// - /// Represents a C# while or do statement, or a VB While or Do statement. + /// Represents a C# 'while' or a VB 'While' loop statement. /// - internal sealed partial class WhileUntilLoopStatement : BaseWhileUntilLoopStatement, IWhileUntilLoopStatement + internal sealed partial class WhileLoopStatement : BaseWhileLoopStatement, IWhileLoopStatement { - public WhileUntilLoopStatement(bool isTopTest, bool isWhile, IOperation condition, LoopKind loopKind, IOperation body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : - base(isTopTest, isWhile, loopKind, semanticModel, syntax, type, constantValue, isImplicit) + public WhileLoopStatement(IOperation condition, IOperation body, ImmutableArray locals, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(locals, semanticModel, syntax, type, constantValue, isImplicit) { ConditionImpl = condition; BodyImpl = body; @@ -4949,15 +5109,15 @@ internal sealed partial class WhileUntilLoopStatement : BaseWhileUntilLoopStatem } /// - /// Represents a C# while or do statement, or a VB While or Do statement. + /// Represents a C# 'while' or a VB 'While' loop statement. /// - internal sealed partial class LazyWhileUntilLoopStatement : BaseWhileUntilLoopStatement, IWhileUntilLoopStatement + internal sealed partial class LazyWhileLoopStatement : BaseWhileLoopStatement, IWhileLoopStatement { private readonly Lazy _lazyCondition; private readonly Lazy _lazyBody; - public LazyWhileUntilLoopStatement(bool isTopTest, bool isWhile, Lazy condition, LoopKind loopKind, Lazy body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : - base(isTopTest, isWhile, loopKind, semanticModel, syntax, type, constantValue, isImplicit) + public LazyWhileLoopStatement(Lazy condition, Lazy body, ImmutableArray locals, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(locals, semanticModel, syntax, type, constantValue, isImplicit) { _lazyCondition = condition ?? throw new System.ArgumentNullException(nameof(condition)); _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); diff --git a/src/Compilers/Core/Portable/Operations/IFixedStatement.cs b/src/Compilers/Core/Portable/Operations/IFixedStatement.cs index 958fca61bf56926181df97883a97634adb64c9b6..987f467c9c909d12649960a2a359ee1463ae1338 100644 --- a/src/Compilers/Core/Portable/Operations/IFixedStatement.cs +++ b/src/Compilers/Core/Portable/Operations/IFixedStatement.cs @@ -5,7 +5,7 @@ namespace Microsoft.CodeAnalysis.Semantics { /// - /// Represents a C# fixed staement. + /// Represents a C# fixed statement. /// /// /// This interface is reserved for implementation by its associated APIs. We reserve the right to diff --git a/src/Compilers/Core/Portable/Operations/ISyntheticLocalReferenceExpression.cs b/src/Compilers/Core/Portable/Operations/ISyntheticLocalReferenceExpression.cs deleted file mode 100644 index caf8d695aeb30e2b227895968594e92c5e58e45f..0000000000000000000000000000000000000000 --- a/src/Compilers/Core/Portable/Operations/ISyntheticLocalReferenceExpression.cs +++ /dev/null @@ -1,22 +0,0 @@ -// 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 -{ - /// - /// Represents a reference to a local variable synthesized by language analysis. - /// - /// - /// This interface is reserved for implementation by its associated APIs. We reserve the right to - /// change it in the future. - /// - public interface ISyntheticLocalReferenceExpression : IOperation - { - /// - /// Kind of the synthetic local. - /// - SyntheticLocalKind SyntheticLocalKind { get; } - } -} - diff --git a/src/Compilers/Core/Portable/Operations/IWhileUntilLoopStatement.cs b/src/Compilers/Core/Portable/Operations/IWhileUntilLoopStatement.cs deleted file mode 100644 index 6736014145a4ab6f82c8fcc4e2e0a01d8b846f02..0000000000000000000000000000000000000000 --- a/src/Compilers/Core/Portable/Operations/IWhileUntilLoopStatement.cs +++ /dev/null @@ -1,26 +0,0 @@ -// 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 -{ - /// - /// Represents a C# while or do statement, or a VB While or Do statement. - /// - /// - /// This interface is reserved for implementation by its associated APIs. We reserve the right to - /// change it in the future. - /// - public interface IWhileUntilLoopStatement : IForWhileUntilLoopStatement - { - /// - /// True if the loop test executes at the top of the loop; false if the loop test executes at the bottom of the loop. - /// - bool IsTopTest { get; } - /// - /// True if the loop is a while loop; false if the loop is an until loop. - /// - bool IsWhile { get; } - } -} - diff --git a/src/Compilers/Core/Portable/Operations/LoopKind.cs b/src/Compilers/Core/Portable/Operations/LoopKind.cs deleted file mode 100644 index 8d29fef952fd09218e1bb635c5da9f419209e152..0000000000000000000000000000000000000000 --- a/src/Compilers/Core/Portable/Operations/LoopKind.cs +++ /dev/null @@ -1,28 +0,0 @@ -// 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 -{ - /// - /// Kinds of loops. - /// - public enum LoopKind - { - None = 0x0, - - /// - /// Indicates a C# while or do loop, or a VB While or Do loop. - /// - WhileUntil = 0x1, - /// - /// Indicates a C# for loop or a VB For loop. - /// - For = 0x2, - /// - /// Indicates a C# foreach loop or a VB For Each loop. - /// - ForEach = 0x3 - } -} - diff --git a/src/Compilers/Core/Portable/Operations/Loops/DoLoopKind.cs b/src/Compilers/Core/Portable/Operations/Loops/DoLoopKind.cs new file mode 100644 index 0000000000000000000000000000000000000000..856ad0e1091a79cabacc86d497a12edeabd21303 --- /dev/null +++ b/src/Compilers/Core/Portable/Operations/Loops/DoLoopKind.cs @@ -0,0 +1,42 @@ +// 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 +{ + /// + /// Represents different kinds of do loop statements. + /// + public enum DoLoopKind + { + None = 0x0, + + /// + /// 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 true. + /// + DoWhileBottomLoop = 0x1, + + /// + /// 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 true. + /// + DoWhileTopLoop = 0x2, + + /// + /// 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 false. + /// + DoUntilBottomLoop = 0x3, + + /// + /// 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 false. + /// + DoUntilTopLoop = 0x4, + + /// + /// 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. + /// + Invalid = 0xf, + } +} + diff --git a/src/Compilers/Core/Portable/Operations/Loops/IDoLoopStatement.cs b/src/Compilers/Core/Portable/Operations/Loops/IDoLoopStatement.cs new file mode 100644 index 0000000000000000000000000000000000000000..0d7818dc686457b865401e687f4ddebec54c833d --- /dev/null +++ b/src/Compilers/Core/Portable/Operations/Loops/IDoLoopStatement.cs @@ -0,0 +1,33 @@ +// 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 +{ + /// + /// Represents a C# 'do while' or VB 'Do While' or 'Do Until' loop statement. + /// + /// + /// This interface is reserved for implementation by its associated APIs. We reserve the right to + /// change it in the future. + /// + public interface IDoLoopStatement : ILoopStatement + { + /// + /// Condition of the loop. + /// + IOperation Condition { get; } + + /// + /// Represents kind of do loop statement. + /// + DoLoopKind DoLoopKind { get; } + + /// + /// Additional conditional supplied for loop in error cases, which is ignored by the compiler. + /// For example, for VB 'Do While' or 'Do Until' loop with syntax errors where both the top and bottom conditions are provided. + /// The top condition is preferred and exposed as and the bottom condition is ignored and exposed by this property. + /// This property should be null for all non-error cases. + /// + IOperation IgnoredCondition { get; } + } +} + diff --git a/src/Compilers/Core/Portable/Operations/IForEachLoopStatement.cs b/src/Compilers/Core/Portable/Operations/Loops/IForEachLoopStatement.cs similarity index 60% rename from src/Compilers/Core/Portable/Operations/IForEachLoopStatement.cs rename to src/Compilers/Core/Portable/Operations/Loops/IForEachLoopStatement.cs index 1031711baab88d8461ec4b0ffff658df80196a23..752853a5f71672ec41d49a48a4acb9b5ab8102bc 100644 --- a/src/Compilers/Core/Portable/Operations/IForEachLoopStatement.cs +++ b/src/Compilers/Core/Portable/Operations/Loops/IForEachLoopStatement.cs @@ -5,7 +5,7 @@ namespace Microsoft.CodeAnalysis.Semantics { /// - /// Represents a C# foreach statement or a VB For Each staement. + /// Represents a C# 'foreach' statement or a VB 'For Each' statement. /// /// /// This interface is reserved for implementation by its associated APIs. We reserve the right to @@ -14,13 +14,20 @@ namespace Microsoft.CodeAnalysis.Semantics public interface IForEachLoopStatement : ILoopStatement { /// - /// Iteration variable of the loop. + /// Refers to the operation for declaring a new local variable or reference an existing variable or an expression. /// - ILocalSymbol IterationVariable { get; } + IOperation LoopControlVariable { get; } + /// /// Collection value over which the loop iterates. /// IOperation Collection { get; } + + /// + /// Optional list of comma separated next variables at loop bottom in VB. + /// This list is always empty for C#. + /// + ImmutableArray NextVariables { get; } } } diff --git a/src/Compilers/Core/Portable/Operations/IForLoopStatement.cs b/src/Compilers/Core/Portable/Operations/Loops/IForLoopStatement.cs similarity index 54% rename from src/Compilers/Core/Portable/Operations/IForLoopStatement.cs rename to src/Compilers/Core/Portable/Operations/Loops/IForLoopStatement.cs index 6c33d390e1cb4b9e0b7d497eb0d23c8d3537736e..f589d267387ce9ee7b2d1d3df430ae2c806210ff 100644 --- a/src/Compilers/Core/Portable/Operations/IForLoopStatement.cs +++ b/src/Compilers/Core/Portable/Operations/Loops/IForLoopStatement.cs @@ -5,26 +5,28 @@ namespace Microsoft.CodeAnalysis.Semantics { /// - /// Represents a C# for statement or a VB For statement. + /// Represents a C# 'for' loop statement. /// /// /// This interface is reserved for implementation by its associated APIs. We reserve the right to /// change it in the future. /// - public interface IForLoopStatement : IForWhileUntilLoopStatement + public interface IForLoopStatement : ILoopStatement { /// - /// Statements to execute before entry to the loop. For C# these come from the first clause of the for statement. For VB these initialize the index variable of the For statement. + /// List of operations to execute before entry to the loop. This comes from the first clause of the for statement. /// ImmutableArray Before { get; } + /// - /// Statements to execute at the bottom of the loop. For C# these come from the third clause of the for statement. For VB these increment the index variable of the For statement. + /// Condition of the loop. This comes from the second clause of the for statement. /// - ImmutableArray AtLoopBottom { get; } + IOperation Condition { get; } + /// - /// Declarations local to the loop. + /// List of operations to execute at the bottom of the loop. This comes from the third clause of the for statement. /// - ImmutableArray Locals { get; } + ImmutableArray AtLoopBottom { get; } } } diff --git a/src/Compilers/Core/Portable/Operations/Loops/IForToLoopStatement.cs b/src/Compilers/Core/Portable/Operations/Loops/IForToLoopStatement.cs new file mode 100644 index 0000000000000000000000000000000000000000..4a00eb6b4b51f6372e9ee4ebca817f800f6b06d3 --- /dev/null +++ b/src/Compilers/Core/Portable/Operations/Loops/IForToLoopStatement.cs @@ -0,0 +1,41 @@ +// 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 +{ + /// + /// Represents a VB 'For To' loop statement. + /// + /// + /// This interface is reserved for implementation by its associated APIs. We reserve the right to + /// change it in the future. + /// + public interface IForToLoopStatement : ILoopStatement + { + /// + /// Refers to the operation for declaring a new local variable or reference an existing variable or an expression. + /// + IOperation LoopControlVariable { get; } + + /// + /// Operation for setting the initial value of the loop control variable. This comes from the expression between the 'For' and 'To' keywords. + /// + IOperation InitialValue { get; } + + /// + /// Operation for the limit value of the loop control variable. This comes from the expression after the 'To' keyword. + /// + IOperation LimitValue { get; } + + /// + /// Optional operation for the step value of the loop control variable. This comes from the expression after the 'Step' keyword. + /// + IOperation StepValue { get; } + + /// + /// Optional list of comma separated next variables at loop bottom. + /// + ImmutableArray NextVariables { get; } + } +} diff --git a/src/Compilers/Core/Portable/Operations/ILoopStatement.cs b/src/Compilers/Core/Portable/Operations/Loops/ILoopStatement.cs similarity index 86% rename from src/Compilers/Core/Portable/Operations/ILoopStatement.cs rename to src/Compilers/Core/Portable/Operations/Loops/ILoopStatement.cs index 0824aa699100a74362e03bcf0d762e26bf3c2e30..d8a0e6515f1d14dd10b54b5816d2d2ea5b046238 100644 --- a/src/Compilers/Core/Portable/Operations/ILoopStatement.cs +++ b/src/Compilers/Core/Portable/Operations/Loops/ILoopStatement.cs @@ -21,6 +21,10 @@ public interface ILoopStatement : IOperation /// Body of the loop. /// IOperation Body { get; } + /// + /// Declared locals. + /// + ImmutableArray Locals { get; } } } diff --git a/src/Compilers/Core/Portable/Operations/IForWhileUntilLoopStatement.cs b/src/Compilers/Core/Portable/Operations/Loops/IWhileLoopStatement.cs similarity index 74% rename from src/Compilers/Core/Portable/Operations/IForWhileUntilLoopStatement.cs rename to src/Compilers/Core/Portable/Operations/Loops/IWhileLoopStatement.cs index 72d457cf595a602158e364fbfca2dee2859ce331..9b426bb682030b23b2d1c2b2760c258d30a07bef 100644 --- a/src/Compilers/Core/Portable/Operations/IForWhileUntilLoopStatement.cs +++ b/src/Compilers/Core/Portable/Operations/Loops/IWhileLoopStatement.cs @@ -1,17 +1,15 @@ // 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 { /// - /// Represents a C# while, for, or do statement, or a VB While, For, or Do statement. + /// Represents a C# 'while' or a VB 'While' loop statement. /// /// /// This interface is reserved for implementation by its associated APIs. We reserve the right to /// change it in the future. /// - public interface IForWhileUntilLoopStatement : ILoopStatement + public interface IWhileLoopStatement : ILoopStatement { /// /// Condition of the loop. diff --git a/src/Compilers/Core/Portable/Operations/Loops/LoopKind.cs b/src/Compilers/Core/Portable/Operations/Loops/LoopKind.cs new file mode 100644 index 0000000000000000000000000000000000000000..2f635a153cba330e5a2ad68912d045bea0958593 --- /dev/null +++ b/src/Compilers/Core/Portable/Operations/Loops/LoopKind.cs @@ -0,0 +1,38 @@ +// 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 +{ + /// + /// Kinds of loop statements. + /// + public enum LoopKind + { + None = 0x0, + + /// + /// Represents a in C# or VB. + /// + Do = 0x1, + + /// + /// Represents a in C# or VB. + /// + While = 0x2, + + /// + /// Indicates a in C#. + /// + For = 0x3, + + /// + /// Indicates a in VB. + /// + ForTo = 0x4, + + /// + /// Indicates a in C# or VB. + /// + ForEach = 0x5 + } +} + diff --git a/src/Compilers/Core/Portable/Operations/OperationCloner.cs b/src/Compilers/Core/Portable/Operations/OperationCloner.cs index 38a4fb31a949ff697bc6aabb93ebf54937a2dd1b..8a6456e0ec88de16c0f311f4459fe1ce7107c3ea 100644 --- a/src/Compilers/Core/Portable/Operations/OperationCloner.cs +++ b/src/Compilers/Core/Portable/Operations/OperationCloner.cs @@ -84,19 +84,29 @@ public override IOperation VisitIfStatement(IIfStatement operation, object argum return new IfStatement(Visit(operation.Condition), Visit(operation.IfTrueStatement), Visit(operation.IfFalseStatement), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } - public override IOperation VisitWhileUntilLoopStatement(IWhileUntilLoopStatement operation, object argument) + public override IOperation VisitDoLoopStatement(IDoLoopStatement operation, object argument) { - return new WhileUntilLoopStatement(operation.IsTopTest, operation.IsWhile, Visit(operation.Condition), operation.LoopKind, Visit(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); + return new DoLoopStatement(operation.DoLoopKind, Visit(operation.Condition), Visit(operation.Body), Visit(operation.IgnoredCondition), operation.Locals, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); + } + + public override IOperation VisitWhileLoopStatement(IWhileLoopStatement operation, object argument) + { + return new WhileLoopStatement(Visit(operation.Condition), Visit(operation.Body), operation.Locals, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitForLoopStatement(IForLoopStatement operation, object argument) { - return new ForLoopStatement(VisitArray(operation.Before), VisitArray(operation.AtLoopBottom), operation.Locals, Visit(operation.Condition), operation.LoopKind, Visit(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); + return new ForLoopStatement(VisitArray(operation.Before), Visit(operation.Condition), VisitArray(operation.AtLoopBottom), operation.Locals, Visit(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); + } + + public override IOperation VisitForToLoopStatement(IForToLoopStatement operation, object argument) + { + return new ForToLoopStatement(operation.Locals, Visit(operation.LoopControlVariable), Visit(operation.InitialValue), Visit(operation.LimitValue), Visit(operation.StepValue), Visit(operation.Body), VisitArray(operation.NextVariables), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitForEachLoopStatement(IForEachLoopStatement operation, object argument) { - return new ForEachLoopStatement(operation.IterationVariable, Visit(operation.Collection), operation.LoopKind, Visit(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); + return new ForEachLoopStatement(operation.Locals, Visit(operation.LoopControlVariable), Visit(operation.Collection), VisitArray(operation.NextVariables), Visit(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitLabeledStatement(ILabeledStatement operation, object argument) @@ -200,11 +210,6 @@ public override IOperation VisitParameterReferenceExpression(IParameterReference return new ParameterReferenceExpression(operation.Parameter, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } - public override IOperation VisitSyntheticLocalReferenceExpression(ISyntheticLocalReferenceExpression operation, object argument) - { - return new SyntheticLocalReferenceExpression(operation.SyntheticLocalKind, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); - } - public override IOperation VisitInstanceReferenceExpression(IInstanceReferenceExpression operation, object argument) { return new InstanceReferenceExpression(((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); diff --git a/src/Compilers/Core/Portable/Operations/OperationKind.cs b/src/Compilers/Core/Portable/Operations/OperationKind.cs index b993835ae0cfa8137137de5cd72ec87dfef7533a..e39cee77e5e0f0d6495e193a333717d7a3b903f2 100644 --- a/src/Compilers/Core/Portable/Operations/OperationKind.cs +++ b/src/Compilers/Core/Portable/Operations/OperationKind.cs @@ -80,8 +80,7 @@ public enum OperationKind LocalReferenceExpression = 0x105, /// Indicates an . ParameterReferenceExpression = 0x106, - /// Indicates an . - SyntheticLocalReferenceExpression = 0x107, + // Unused 0x107 /// Indicates an . FieldReferenceExpression = 0x108, /// Indicates an . diff --git a/src/Compilers/Core/Portable/Operations/OperationVisitor.cs b/src/Compilers/Core/Portable/Operations/OperationVisitor.cs index fa759d731dc90460c4912fbfa76dcaa06513464a..03242b739242c2785f0a50907c7b2ba821bda694 100644 --- a/src/Compilers/Core/Portable/Operations/OperationVisitor.cs +++ b/src/Compilers/Core/Portable/Operations/OperationVisitor.cs @@ -75,7 +75,12 @@ public virtual void VisitIfStatement(IIfStatement operation) DefaultVisit(operation); } - public virtual void VisitWhileUntilLoopStatement(IWhileUntilLoopStatement operation) + public virtual void VisitDoLoopStatement(IDoLoopStatement operation) + { + DefaultVisit(operation); + } + + public virtual void VisitWhileLoopStatement(IWhileLoopStatement operation) { DefaultVisit(operation); } @@ -85,6 +90,11 @@ public virtual void VisitForLoopStatement(IForLoopStatement operation) DefaultVisit(operation); } + public virtual void VisitForToLoopStatement(IForToLoopStatement operation) + { + DefaultVisit(operation); + } + public virtual void VisitForEachLoopStatement(IForEachLoopStatement operation) { DefaultVisit(operation); @@ -198,11 +208,6 @@ public virtual void VisitParameterReferenceExpression(IParameterReferenceExpress DefaultVisit(operation); } - public virtual void VisitSyntheticLocalReferenceExpression(ISyntheticLocalReferenceExpression operation) - { - DefaultVisit(operation); - } - public virtual void VisitInstanceReferenceExpression(IInstanceReferenceExpression operation) { DefaultVisit(operation); @@ -543,7 +548,12 @@ public virtual TResult VisitIfStatement(IIfStatement operation, TArgument argume return DefaultVisit(operation, argument); } - public virtual TResult VisitWhileUntilLoopStatement(IWhileUntilLoopStatement operation, TArgument argument) + public virtual TResult VisitDoLoopStatement(IDoLoopStatement operation, TArgument argument) + { + return DefaultVisit(operation, argument); + } + + public virtual TResult VisitWhileLoopStatement(IWhileLoopStatement operation, TArgument argument) { return DefaultVisit(operation, argument); } @@ -553,6 +563,11 @@ public virtual TResult VisitForLoopStatement(IForLoopStatement operation, TArgum return DefaultVisit(operation, argument); } + public virtual TResult VisitForToLoopStatement(IForToLoopStatement operation, TArgument argument) + { + return DefaultVisit(operation, argument); + } + public virtual TResult VisitForEachLoopStatement(IForEachLoopStatement operation, TArgument argument) { return DefaultVisit(operation, argument); @@ -666,11 +681,6 @@ public virtual TResult VisitParameterReferenceExpression(IParameterReferenceExpr return DefaultVisit(operation, argument); } - public virtual TResult VisitSyntheticLocalReferenceExpression(ISyntheticLocalReferenceExpression operation, TArgument argument) - { - return DefaultVisit(operation, argument); - } - public virtual TResult VisitInstanceReferenceExpression(IInstanceReferenceExpression operation, TArgument argument) { return DefaultVisit(operation, argument); diff --git a/src/Compilers/Core/Portable/Operations/SyntheticLocalKind.cs b/src/Compilers/Core/Portable/Operations/SyntheticLocalKind.cs deleted file mode 100644 index 51387ed7a0d8e569fe7d59215947cc3cccf22479..0000000000000000000000000000000000000000 --- a/src/Compilers/Core/Portable/Operations/SyntheticLocalKind.cs +++ /dev/null @@ -1,24 +0,0 @@ -// 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 -{ - /// - /// Kinds of synthetic local references. - /// - public enum SyntheticLocalKind - { - None = 0x0, - - /// - /// Created to capture the step value of a VB for loop. - /// - ForLoopStepValue = 0x1, - /// - /// Created to capture the limit value of a VB for loop. - /// - ForLoopLimitValue = 0x2 - } -} - diff --git a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt index 79b227bda2de0a1ea91ed9dfb0661b3c7c1ab0af..644001ed3143355008e8de255f33c5503b20ea96 100644 --- a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt +++ b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt @@ -49,6 +49,7 @@ Microsoft.CodeAnalysis.IOperation.Syntax.get -> Microsoft.CodeAnalysis.SyntaxNod Microsoft.CodeAnalysis.IOperation.Type.get -> Microsoft.CodeAnalysis.ITypeSymbol Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.AddressOfExpression = 515 -> Microsoft.CodeAnalysis.OperationKind +Microsoft.CodeAnalysis.OperationKind.AnonymousFunctionExpression = 273 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.AnonymousObjectCreationExpression = 287 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.Argument = 1031 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.ArrayCreationExpression = 276 -> Microsoft.CodeAnalysis.OperationKind @@ -59,6 +60,7 @@ Microsoft.CodeAnalysis.OperationKind.BinaryOperatorExpression = 270 -> Microsoft Microsoft.CodeAnalysis.OperationKind.BlockStatement = 2 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.BranchStatement = 8 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.CatchClause = 1032 -> Microsoft.CodeAnalysis.OperationKind +Microsoft.CodeAnalysis.OperationKind.CoalesceExpression = 272 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.CollectionElementInitializerExpression = 290 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.CompoundAssignmentExpression = 281 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.ConditionalAccessExpression = 284 -> Microsoft.CodeAnalysis.OperationKind @@ -90,7 +92,6 @@ Microsoft.CodeAnalysis.OperationKind.InvocationExpression = 259 -> Microsoft.Cod Microsoft.CodeAnalysis.OperationKind.IsPatternExpression = 517 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.IsTypeExpression = 278 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.LabeledStatement = 7 -> Microsoft.CodeAnalysis.OperationKind -Microsoft.CodeAnalysis.OperationKind.AnonymousFunctionExpression = 273 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.LiteralExpression = 257 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.LocalFunctionStatement = 49 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.LocalReferenceExpression = 261 -> Microsoft.CodeAnalysis.OperationKind @@ -100,7 +101,6 @@ Microsoft.CodeAnalysis.OperationKind.MemberInitializerExpression = 289 -> Micros Microsoft.CodeAnalysis.OperationKind.MethodBindingExpression = 265 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.NameOfExpression = 291 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.None = 0 -> Microsoft.CodeAnalysis.OperationKind -Microsoft.CodeAnalysis.OperationKind.CoalesceExpression = 272 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.ObjectCreationExpression = 274 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.ObjectOrCollectionInitializerExpression = 288 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.OmittedArgumentExpression = 768 -> Microsoft.CodeAnalysis.OperationKind @@ -120,7 +120,6 @@ Microsoft.CodeAnalysis.OperationKind.SizeOfExpression = 514 -> Microsoft.CodeAna Microsoft.CodeAnalysis.OperationKind.StopStatement = 80 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.SwitchCase = 1033 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.SwitchStatement = 4 -> Microsoft.CodeAnalysis.OperationKind -Microsoft.CodeAnalysis.OperationKind.SyntheticLocalReferenceExpression = 263 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.ThrowExpression = 519 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.TryStatement = 14 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.TupleExpression = 292 -> Microsoft.CodeAnalysis.OperationKind @@ -185,8 +184,18 @@ Microsoft.CodeAnalysis.Semantics.CommonConversion.IsNumeric.get -> bool Microsoft.CodeAnalysis.Semantics.CommonConversion.IsReference.get -> bool Microsoft.CodeAnalysis.Semantics.CommonConversion.IsUserDefined.get -> bool Microsoft.CodeAnalysis.Semantics.CommonConversion.MethodSymbol.get -> Microsoft.CodeAnalysis.IMethodSymbol +Microsoft.CodeAnalysis.Semantics.DoLoopKind +Microsoft.CodeAnalysis.Semantics.DoLoopKind.DoUntilBottomLoop = 3 -> Microsoft.CodeAnalysis.Semantics.DoLoopKind +Microsoft.CodeAnalysis.Semantics.DoLoopKind.DoUntilTopLoop = 4 -> Microsoft.CodeAnalysis.Semantics.DoLoopKind +Microsoft.CodeAnalysis.Semantics.DoLoopKind.DoWhileBottomLoop = 1 -> Microsoft.CodeAnalysis.Semantics.DoLoopKind +Microsoft.CodeAnalysis.Semantics.DoLoopKind.DoWhileTopLoop = 2 -> Microsoft.CodeAnalysis.Semantics.DoLoopKind +Microsoft.CodeAnalysis.Semantics.DoLoopKind.Invalid = 15 -> Microsoft.CodeAnalysis.Semantics.DoLoopKind +Microsoft.CodeAnalysis.Semantics.DoLoopKind.None = 0 -> Microsoft.CodeAnalysis.Semantics.DoLoopKind Microsoft.CodeAnalysis.Semantics.IAddressOfExpression Microsoft.CodeAnalysis.Semantics.IAddressOfExpression.Reference.get -> Microsoft.CodeAnalysis.IOperation +Microsoft.CodeAnalysis.Semantics.IAnonymousFunctionExpression +Microsoft.CodeAnalysis.Semantics.IAnonymousFunctionExpression.Body.get -> Microsoft.CodeAnalysis.Semantics.IBlockStatement +Microsoft.CodeAnalysis.Semantics.IAnonymousFunctionExpression.Symbol.get -> Microsoft.CodeAnalysis.IMethodSymbol Microsoft.CodeAnalysis.Semantics.IAnonymousObjectCreationExpression Microsoft.CodeAnalysis.Semantics.IAnonymousObjectCreationExpression.Initializers.get -> System.Collections.Immutable.ImmutableArray Microsoft.CodeAnalysis.Semantics.IArgument @@ -229,6 +238,9 @@ Microsoft.CodeAnalysis.Semantics.ICatchClause.CaughtType.get -> Microsoft.CodeAn Microsoft.CodeAnalysis.Semantics.ICatchClause.ExceptionLocal.get -> Microsoft.CodeAnalysis.ILocalSymbol Microsoft.CodeAnalysis.Semantics.ICatchClause.Filter.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.ICatchClause.Handler.get -> Microsoft.CodeAnalysis.Semantics.IBlockStatement +Microsoft.CodeAnalysis.Semantics.ICoalesceExpression +Microsoft.CodeAnalysis.Semantics.ICoalesceExpression.Expression.get -> Microsoft.CodeAnalysis.IOperation +Microsoft.CodeAnalysis.Semantics.ICoalesceExpression.WhenNull.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.ICollectionElementInitializerExpression Microsoft.CodeAnalysis.Semantics.ICollectionElementInitializerExpression.AddMethod.get -> Microsoft.CodeAnalysis.IMethodSymbol Microsoft.CodeAnalysis.Semantics.ICollectionElementInitializerExpression.Arguments.get -> System.Collections.Immutable.ImmutableArray @@ -257,6 +269,10 @@ Microsoft.CodeAnalysis.Semantics.IDeclarationPattern Microsoft.CodeAnalysis.Semantics.IDeclarationPattern.DeclaredSymbol.get -> Microsoft.CodeAnalysis.ISymbol Microsoft.CodeAnalysis.Semantics.IDefaultCaseClause Microsoft.CodeAnalysis.Semantics.IDefaultValueExpression +Microsoft.CodeAnalysis.Semantics.IDoLoopStatement +Microsoft.CodeAnalysis.Semantics.IDoLoopStatement.IgnoredCondition.get -> Microsoft.CodeAnalysis.IOperation +Microsoft.CodeAnalysis.Semantics.IDoLoopStatement.Condition.get -> Microsoft.CodeAnalysis.IOperation +Microsoft.CodeAnalysis.Semantics.IDoLoopStatement.DoLoopKind.get -> Microsoft.CodeAnalysis.Semantics.DoLoopKind Microsoft.CodeAnalysis.Semantics.IDynamicMemberReferenceExpression Microsoft.CodeAnalysis.Semantics.IDynamicMemberReferenceExpression.ContainingType.get -> Microsoft.CodeAnalysis.ITypeSymbol Microsoft.CodeAnalysis.Semantics.IDynamicMemberReferenceExpression.Instance.get -> Microsoft.CodeAnalysis.IOperation @@ -280,14 +296,19 @@ Microsoft.CodeAnalysis.Semantics.IFieldReferenceExpression Microsoft.CodeAnalysis.Semantics.IFieldReferenceExpression.Field.get -> Microsoft.CodeAnalysis.IFieldSymbol Microsoft.CodeAnalysis.Semantics.IFieldReferenceExpression.IsDeclaration.get -> bool Microsoft.CodeAnalysis.Semantics.IForEachLoopStatement +Microsoft.CodeAnalysis.Semantics.IForEachLoopStatement.NextVariables.get -> System.Collections.Immutable.ImmutableArray Microsoft.CodeAnalysis.Semantics.IForEachLoopStatement.Collection.get -> Microsoft.CodeAnalysis.IOperation -Microsoft.CodeAnalysis.Semantics.IForEachLoopStatement.IterationVariable.get -> Microsoft.CodeAnalysis.ILocalSymbol +Microsoft.CodeAnalysis.Semantics.IForEachLoopStatement.LoopControlVariable.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IForLoopStatement Microsoft.CodeAnalysis.Semantics.IForLoopStatement.AtLoopBottom.get -> System.Collections.Immutable.ImmutableArray Microsoft.CodeAnalysis.Semantics.IForLoopStatement.Before.get -> System.Collections.Immutable.ImmutableArray -Microsoft.CodeAnalysis.Semantics.IForLoopStatement.Locals.get -> System.Collections.Immutable.ImmutableArray -Microsoft.CodeAnalysis.Semantics.IForWhileUntilLoopStatement -Microsoft.CodeAnalysis.Semantics.IForWhileUntilLoopStatement.Condition.get -> Microsoft.CodeAnalysis.IOperation +Microsoft.CodeAnalysis.Semantics.IForLoopStatement.Condition.get -> Microsoft.CodeAnalysis.IOperation +Microsoft.CodeAnalysis.Semantics.IForToLoopStatement +Microsoft.CodeAnalysis.Semantics.IForToLoopStatement.NextVariables.get -> System.Collections.Immutable.ImmutableArray +Microsoft.CodeAnalysis.Semantics.IForToLoopStatement.InitialValue.get -> Microsoft.CodeAnalysis.IOperation +Microsoft.CodeAnalysis.Semantics.IForToLoopStatement.LimitValue.get -> Microsoft.CodeAnalysis.IOperation +Microsoft.CodeAnalysis.Semantics.IForToLoopStatement.LoopControlVariable.get -> Microsoft.CodeAnalysis.IOperation +Microsoft.CodeAnalysis.Semantics.IForToLoopStatement.StepValue.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IHasArgumentsExpression Microsoft.CodeAnalysis.Semantics.IHasArgumentsExpression.ArgumentsInEvaluationOrder.get -> System.Collections.Immutable.ImmutableArray Microsoft.CodeAnalysis.Semantics.IHasDynamicArgumentsExpression @@ -335,9 +356,6 @@ Microsoft.CodeAnalysis.Semantics.IIsTypeExpression.Operand.get -> Microsoft.Code Microsoft.CodeAnalysis.Semantics.ILabeledStatement Microsoft.CodeAnalysis.Semantics.ILabeledStatement.Label.get -> Microsoft.CodeAnalysis.ILabelSymbol Microsoft.CodeAnalysis.Semantics.ILabeledStatement.Statement.get -> Microsoft.CodeAnalysis.IOperation -Microsoft.CodeAnalysis.Semantics.IAnonymousFunctionExpression -Microsoft.CodeAnalysis.Semantics.IAnonymousFunctionExpression.Body.get -> Microsoft.CodeAnalysis.Semantics.IBlockStatement -Microsoft.CodeAnalysis.Semantics.IAnonymousFunctionExpression.Symbol.get -> Microsoft.CodeAnalysis.IMethodSymbol Microsoft.CodeAnalysis.Semantics.ILiteralExpression Microsoft.CodeAnalysis.Semantics.ILocalFunctionStatement Microsoft.CodeAnalysis.Semantics.ILocalFunctionStatement.Body.get -> Microsoft.CodeAnalysis.Semantics.IBlockStatement @@ -350,6 +368,7 @@ Microsoft.CodeAnalysis.Semantics.ILockStatement.Body.get -> Microsoft.CodeAnalys Microsoft.CodeAnalysis.Semantics.ILockStatement.Expression.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.ILoopStatement Microsoft.CodeAnalysis.Semantics.ILoopStatement.Body.get -> Microsoft.CodeAnalysis.IOperation +Microsoft.CodeAnalysis.Semantics.ILoopStatement.Locals.get -> System.Collections.Immutable.ImmutableArray Microsoft.CodeAnalysis.Semantics.ILoopStatement.LoopKind.get -> Microsoft.CodeAnalysis.Semantics.LoopKind Microsoft.CodeAnalysis.Semantics.IMemberInitializerExpression Microsoft.CodeAnalysis.Semantics.IMemberInitializerExpression.InitializedMember.get -> Microsoft.CodeAnalysis.Semantics.IMemberReferenceExpression @@ -362,9 +381,6 @@ Microsoft.CodeAnalysis.Semantics.IMethodBindingExpression.IsVirtual.get -> bool Microsoft.CodeAnalysis.Semantics.IMethodBindingExpression.Method.get -> Microsoft.CodeAnalysis.IMethodSymbol Microsoft.CodeAnalysis.Semantics.INameOfExpression Microsoft.CodeAnalysis.Semantics.INameOfExpression.Argument.get -> Microsoft.CodeAnalysis.IOperation -Microsoft.CodeAnalysis.Semantics.ICoalesceExpression -Microsoft.CodeAnalysis.Semantics.ICoalesceExpression.Expression.get -> Microsoft.CodeAnalysis.IOperation -Microsoft.CodeAnalysis.Semantics.ICoalesceExpression.WhenNull.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IObjectCreationExpression Microsoft.CodeAnalysis.Semantics.IObjectCreationExpression.Constructor.get -> Microsoft.CodeAnalysis.IMethodSymbol Microsoft.CodeAnalysis.Semantics.IObjectCreationExpression.Initializer.get -> Microsoft.CodeAnalysis.Semantics.IObjectOrCollectionInitializerExpression @@ -408,8 +424,6 @@ Microsoft.CodeAnalysis.Semantics.ISwitchStatement.Cases.get -> System.Collection Microsoft.CodeAnalysis.Semantics.ISwitchStatement.Value.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.ISymbolInitializer Microsoft.CodeAnalysis.Semantics.ISymbolInitializer.Value.get -> Microsoft.CodeAnalysis.IOperation -Microsoft.CodeAnalysis.Semantics.ISyntheticLocalReferenceExpression -Microsoft.CodeAnalysis.Semantics.ISyntheticLocalReferenceExpression.SyntheticLocalKind.get -> Microsoft.CodeAnalysis.Semantics.SyntheticLocalKind Microsoft.CodeAnalysis.Semantics.IThrowExpression Microsoft.CodeAnalysis.Semantics.IThrowExpression.Expression.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.ITryStatement @@ -437,17 +451,18 @@ Microsoft.CodeAnalysis.Semantics.IVariableDeclaration.Initializer.get -> Microso Microsoft.CodeAnalysis.Semantics.IVariableDeclaration.Variables.get -> System.Collections.Immutable.ImmutableArray Microsoft.CodeAnalysis.Semantics.IVariableDeclarationStatement Microsoft.CodeAnalysis.Semantics.IVariableDeclarationStatement.Declarations.get -> System.Collections.Immutable.ImmutableArray -Microsoft.CodeAnalysis.Semantics.IWhileUntilLoopStatement -Microsoft.CodeAnalysis.Semantics.IWhileUntilLoopStatement.IsTopTest.get -> bool -Microsoft.CodeAnalysis.Semantics.IWhileUntilLoopStatement.IsWhile.get -> bool +Microsoft.CodeAnalysis.Semantics.IWhileLoopStatement +Microsoft.CodeAnalysis.Semantics.IWhileLoopStatement.Condition.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IWithStatement Microsoft.CodeAnalysis.Semantics.IWithStatement.Body.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IWithStatement.Value.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.LoopKind -Microsoft.CodeAnalysis.Semantics.LoopKind.For = 2 -> Microsoft.CodeAnalysis.Semantics.LoopKind -Microsoft.CodeAnalysis.Semantics.LoopKind.ForEach = 3 -> Microsoft.CodeAnalysis.Semantics.LoopKind +Microsoft.CodeAnalysis.Semantics.LoopKind.Do = 1 -> Microsoft.CodeAnalysis.Semantics.LoopKind +Microsoft.CodeAnalysis.Semantics.LoopKind.For = 3 -> Microsoft.CodeAnalysis.Semantics.LoopKind +Microsoft.CodeAnalysis.Semantics.LoopKind.ForEach = 5 -> Microsoft.CodeAnalysis.Semantics.LoopKind +Microsoft.CodeAnalysis.Semantics.LoopKind.ForTo = 4 -> Microsoft.CodeAnalysis.Semantics.LoopKind Microsoft.CodeAnalysis.Semantics.LoopKind.None = 0 -> Microsoft.CodeAnalysis.Semantics.LoopKind -Microsoft.CodeAnalysis.Semantics.LoopKind.WhileUntil = 1 -> Microsoft.CodeAnalysis.Semantics.LoopKind +Microsoft.CodeAnalysis.Semantics.LoopKind.While = 2 -> Microsoft.CodeAnalysis.Semantics.LoopKind Microsoft.CodeAnalysis.Semantics.OperationExtensions Microsoft.CodeAnalysis.Semantics.OperationVisitor Microsoft.CodeAnalysis.Semantics.OperationVisitor.OperationVisitor() -> void @@ -455,10 +470,6 @@ Microsoft.CodeAnalysis.Semantics.OperationVisitor Microsoft.CodeAnalysis.Semantics.OperationVisitor.OperationVisitor() -> void Microsoft.CodeAnalysis.Semantics.OperationWalker Microsoft.CodeAnalysis.Semantics.OperationWalker.OperationWalker() -> void -Microsoft.CodeAnalysis.Semantics.SyntheticLocalKind -Microsoft.CodeAnalysis.Semantics.SyntheticLocalKind.ForLoopLimitValue = 2 -> Microsoft.CodeAnalysis.Semantics.SyntheticLocalKind -Microsoft.CodeAnalysis.Semantics.SyntheticLocalKind.ForLoopStepValue = 1 -> Microsoft.CodeAnalysis.Semantics.SyntheticLocalKind -Microsoft.CodeAnalysis.Semantics.SyntheticLocalKind.None = 0 -> Microsoft.CodeAnalysis.Semantics.SyntheticLocalKind Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.BitwiseNegation = 1 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.False = 6 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind @@ -499,6 +510,7 @@ virtual Microsoft.CodeAnalysis.Diagnostics.CompilationStartAnalysisContext.Regis virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.DefaultVisit(Microsoft.CodeAnalysis.IOperation operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.Visit(Microsoft.CodeAnalysis.IOperation operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitAddressOfExpression(Microsoft.CodeAnalysis.Semantics.IAddressOfExpression operation) -> void +virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitAnonymousFunctionExpression(Microsoft.CodeAnalysis.Semantics.IAnonymousFunctionExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitAnonymousObjectCreationExpression(Microsoft.CodeAnalysis.Semantics.IAnonymousObjectCreationExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitArgument(Microsoft.CodeAnalysis.Semantics.IArgument operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitArrayCreationExpression(Microsoft.CodeAnalysis.Semantics.IArrayCreationExpression operation) -> void @@ -509,6 +521,7 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitBinaryOperatorExp virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitBlockStatement(Microsoft.CodeAnalysis.Semantics.IBlockStatement operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitBranchStatement(Microsoft.CodeAnalysis.Semantics.IBranchStatement operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitCatchClause(Microsoft.CodeAnalysis.Semantics.ICatchClause operation) -> void +virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitCoalesceExpression(Microsoft.CodeAnalysis.Semantics.ICoalesceExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitCollectionElementInitializerExpression(Microsoft.CodeAnalysis.Semantics.ICollectionElementInitializerExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitCompoundAssignmentExpression(Microsoft.CodeAnalysis.Semantics.ICompoundAssignmentExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitConditionalAccessExpression(Microsoft.CodeAnalysis.Semantics.IConditionalAccessExpression operation) -> void @@ -519,6 +532,7 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitConversionExpress virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitDeclarationPattern(Microsoft.CodeAnalysis.Semantics.IDeclarationPattern operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitDefaultCaseClause(Microsoft.CodeAnalysis.Semantics.IDefaultCaseClause operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitDefaultValueExpression(Microsoft.CodeAnalysis.Semantics.IDefaultValueExpression operation) -> void +virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitDoLoopStatement(Microsoft.CodeAnalysis.Semantics.IDoLoopStatement operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitDynamicMemberReferenceExpression(Microsoft.CodeAnalysis.Semantics.IDynamicMemberReferenceExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitDynamicObjectCreationExpression(Microsoft.CodeAnalysis.Semantics.IDynamicObjectCreationExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitEmptyStatement(Microsoft.CodeAnalysis.Semantics.IEmptyStatement operation) -> void @@ -530,6 +544,7 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitFieldInitializer( virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitFieldReferenceExpression(Microsoft.CodeAnalysis.Semantics.IFieldReferenceExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitForEachLoopStatement(Microsoft.CodeAnalysis.Semantics.IForEachLoopStatement operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitForLoopStatement(Microsoft.CodeAnalysis.Semantics.IForLoopStatement operation) -> void +virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitForToLoopStatement(Microsoft.CodeAnalysis.Semantics.IForToLoopStatement operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitIfStatement(Microsoft.CodeAnalysis.Semantics.IIfStatement operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitIncrementExpression(Microsoft.CodeAnalysis.Semantics.IIncrementExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitInstanceReferenceExpression(Microsoft.CodeAnalysis.Semantics.IInstanceReferenceExpression operation) -> void @@ -542,7 +557,6 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitInvocationExpress virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitIsPatternExpression(Microsoft.CodeAnalysis.Semantics.IIsPatternExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitIsTypeExpression(Microsoft.CodeAnalysis.Semantics.IIsTypeExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitLabeledStatement(Microsoft.CodeAnalysis.Semantics.ILabeledStatement operation) -> void -virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitAnonymousFunctionExpression(Microsoft.CodeAnalysis.Semantics.IAnonymousFunctionExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitLiteralExpression(Microsoft.CodeAnalysis.Semantics.ILiteralExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitLocalFunctionStatement(Microsoft.CodeAnalysis.Semantics.ILocalFunctionStatement operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitLocalReferenceExpression(Microsoft.CodeAnalysis.Semantics.ILocalReferenceExpression operation) -> void @@ -550,7 +564,6 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitLockStatement(Mic virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitMemberInitializerExpression(Microsoft.CodeAnalysis.Semantics.IMemberInitializerExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitMethodBindingExpression(Microsoft.CodeAnalysis.Semantics.IMethodBindingExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitNameOfExpression(Microsoft.CodeAnalysis.Semantics.INameOfExpression operation) -> void -virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitCoalesceExpression(Microsoft.CodeAnalysis.Semantics.ICoalesceExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitObjectCreationExpression(Microsoft.CodeAnalysis.Semantics.IObjectCreationExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitObjectOrCollectionInitializerExpression(Microsoft.CodeAnalysis.Semantics.IObjectOrCollectionInitializerExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitOmittedArgumentExpression(Microsoft.CodeAnalysis.Semantics.IOmittedArgumentExpression operation) -> void @@ -570,7 +583,6 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitSizeOfExpression( virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitStopStatement(Microsoft.CodeAnalysis.Semantics.IStopStatement operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitSwitchCase(Microsoft.CodeAnalysis.Semantics.ISwitchCase operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitSwitchStatement(Microsoft.CodeAnalysis.Semantics.ISwitchStatement operation) -> void -virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitSyntheticLocalReferenceExpression(Microsoft.CodeAnalysis.Semantics.ISyntheticLocalReferenceExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitThrowExpression(Microsoft.CodeAnalysis.Semantics.IThrowExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitTryStatement(Microsoft.CodeAnalysis.Semantics.ITryStatement operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitTupleExpression(Microsoft.CodeAnalysis.Semantics.ITupleExpression operation) -> void @@ -580,12 +592,13 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitUnaryOperatorExpr virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitUsingStatement(Microsoft.CodeAnalysis.Semantics.IUsingStatement operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitVariableDeclaration(Microsoft.CodeAnalysis.Semantics.IVariableDeclaration operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitVariableDeclarationStatement(Microsoft.CodeAnalysis.Semantics.IVariableDeclarationStatement operation) -> void -virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitWhileUntilLoopStatement(Microsoft.CodeAnalysis.Semantics.IWhileUntilLoopStatement operation) -> void +virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitWhileLoopStatement(Microsoft.CodeAnalysis.Semantics.IWhileLoopStatement operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitWithStatement(Microsoft.CodeAnalysis.Semantics.IWithStatement operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitYieldBreakStatement(Microsoft.CodeAnalysis.Semantics.IReturnStatement operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.DefaultVisit(Microsoft.CodeAnalysis.IOperation operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.Visit(Microsoft.CodeAnalysis.IOperation operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitAddressOfExpression(Microsoft.CodeAnalysis.Semantics.IAddressOfExpression operation, TArgument argument) -> TResult +virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitAnonymousFunctionExpression(Microsoft.CodeAnalysis.Semantics.IAnonymousFunctionExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitAnonymousObjectCreationExpression(Microsoft.CodeAnalysis.Semantics.IAnonymousObjectCreationExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitArgument(Microsoft.CodeAnalysis.Semantics.IArgument operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitArrayCreationExpression(Microsoft.CodeAnalysis.Semantics.IArrayCreationExpression operation, TArgument argument) -> TResult @@ -596,6 +609,7 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.Vi virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitBlockStatement(Microsoft.CodeAnalysis.Semantics.IBlockStatement operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitBranchStatement(Microsoft.CodeAnalysis.Semantics.IBranchStatement operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitCatchClause(Microsoft.CodeAnalysis.Semantics.ICatchClause operation, TArgument argument) -> TResult +virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitCoalesceExpression(Microsoft.CodeAnalysis.Semantics.ICoalesceExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitCollectionElementInitializerExpression(Microsoft.CodeAnalysis.Semantics.ICollectionElementInitializerExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitCompoundAssignmentExpression(Microsoft.CodeAnalysis.Semantics.ICompoundAssignmentExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitConditionalAccessExpression(Microsoft.CodeAnalysis.Semantics.IConditionalAccessExpression operation, TArgument argument) -> TResult @@ -606,6 +620,7 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.Vi virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitDeclarationPattern(Microsoft.CodeAnalysis.Semantics.IDeclarationPattern operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitDefaultCaseClause(Microsoft.CodeAnalysis.Semantics.IDefaultCaseClause operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitDefaultValueExpression(Microsoft.CodeAnalysis.Semantics.IDefaultValueExpression operation, TArgument argument) -> TResult +virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitDoLoopStatement(Microsoft.CodeAnalysis.Semantics.IDoLoopStatement operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitDynamicMemberReferenceExpression(Microsoft.CodeAnalysis.Semantics.IDynamicMemberReferenceExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitDynamicObjectCreationExpression(Microsoft.CodeAnalysis.Semantics.IDynamicObjectCreationExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitEmptyStatement(Microsoft.CodeAnalysis.Semantics.IEmptyStatement operation, TArgument argument) -> TResult @@ -617,6 +632,7 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.Vi virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitFieldReferenceExpression(Microsoft.CodeAnalysis.Semantics.IFieldReferenceExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitForEachLoopStatement(Microsoft.CodeAnalysis.Semantics.IForEachLoopStatement operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitForLoopStatement(Microsoft.CodeAnalysis.Semantics.IForLoopStatement operation, TArgument argument) -> TResult +virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitForToLoopStatement(Microsoft.CodeAnalysis.Semantics.IForToLoopStatement operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitIfStatement(Microsoft.CodeAnalysis.Semantics.IIfStatement operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitIncrementExpression(Microsoft.CodeAnalysis.Semantics.IIncrementExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitInstanceReferenceExpression(Microsoft.CodeAnalysis.Semantics.IInstanceReferenceExpression operation, TArgument argument) -> TResult @@ -629,7 +645,6 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.Vi virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitIsPatternExpression(Microsoft.CodeAnalysis.Semantics.IIsPatternExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitIsTypeExpression(Microsoft.CodeAnalysis.Semantics.IIsTypeExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitLabeledStatement(Microsoft.CodeAnalysis.Semantics.ILabeledStatement operation, TArgument argument) -> TResult -virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitAnonymousFunctionExpression(Microsoft.CodeAnalysis.Semantics.IAnonymousFunctionExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitLiteralExpression(Microsoft.CodeAnalysis.Semantics.ILiteralExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitLocalFunctionStatement(Microsoft.CodeAnalysis.Semantics.ILocalFunctionStatement operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitLocalReferenceExpression(Microsoft.CodeAnalysis.Semantics.ILocalReferenceExpression operation, TArgument argument) -> TResult @@ -637,7 +652,6 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.Vi virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitMemberInitializerExpression(Microsoft.CodeAnalysis.Semantics.IMemberInitializerExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitMethodBindingExpression(Microsoft.CodeAnalysis.Semantics.IMethodBindingExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitNameOfExpression(Microsoft.CodeAnalysis.Semantics.INameOfExpression operation, TArgument argument) -> TResult -virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitCoalesceExpression(Microsoft.CodeAnalysis.Semantics.ICoalesceExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitObjectCreationExpression(Microsoft.CodeAnalysis.Semantics.IObjectCreationExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitObjectOrCollectionInitializerExpression(Microsoft.CodeAnalysis.Semantics.IObjectOrCollectionInitializerExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitOmittedArgumentExpression(Microsoft.CodeAnalysis.Semantics.IOmittedArgumentExpression operation, TArgument argument) -> TResult @@ -657,7 +671,6 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.Vi virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitStopStatement(Microsoft.CodeAnalysis.Semantics.IStopStatement operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitSwitchCase(Microsoft.CodeAnalysis.Semantics.ISwitchCase operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitSwitchStatement(Microsoft.CodeAnalysis.Semantics.ISwitchStatement operation, TArgument argument) -> TResult -virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitSyntheticLocalReferenceExpression(Microsoft.CodeAnalysis.Semantics.ISyntheticLocalReferenceExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitThrowExpression(Microsoft.CodeAnalysis.Semantics.IThrowExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitTryStatement(Microsoft.CodeAnalysis.Semantics.ITryStatement operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitTupleExpression(Microsoft.CodeAnalysis.Semantics.ITupleExpression operation, TArgument argument) -> TResult @@ -667,6 +680,6 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.Vi virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitUsingStatement(Microsoft.CodeAnalysis.Semantics.IUsingStatement operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitVariableDeclaration(Microsoft.CodeAnalysis.Semantics.IVariableDeclaration operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitVariableDeclarationStatement(Microsoft.CodeAnalysis.Semantics.IVariableDeclarationStatement operation, TArgument argument) -> TResult -virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitWhileUntilLoopStatement(Microsoft.CodeAnalysis.Semantics.IWhileUntilLoopStatement operation, TArgument argument) -> TResult +virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitWhileLoopStatement(Microsoft.CodeAnalysis.Semantics.IWhileLoopStatement operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitWithStatement(Microsoft.CodeAnalysis.Semantics.IWithStatement operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitYieldBreakStatement(Microsoft.CodeAnalysis.Semantics.IReturnStatement operation, TArgument argument) -> TResult diff --git a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb index d9e7972d36c34bf0022bd12286c3f8f95cad3c26..140047d4376e88a8c23ed4f0bfebf96086b24a02 100644 --- a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb +++ b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb @@ -920,63 +920,89 @@ Namespace Microsoft.CodeAnalysis.Semantics Return New LazyRelationalCaseClause(value, relation, CaseKind, _semanticModel, syntax, type, constantValue, isImplicit) End Function - Private Function CreateBoundDoLoopStatementOperation(boundDoLoopStatement As BoundDoLoopStatement) As IWhileUntilLoopStatement - Dim isTopTest As Boolean = boundDoLoopStatement.ConditionIsTop - Dim isWhile As Boolean = Not boundDoLoopStatement.ConditionIsUntil + Private Function CreateBoundDoLoopStatementOperation(boundDoLoopStatement As BoundDoLoopStatement) As IDoLoopStatement + Dim doLoopKind As DoLoopKind = GetDoLoopKind(boundDoLoopStatement) Dim condition As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundDoLoopStatement.ConditionOpt)) - Dim LoopKind As LoopKind = LoopKind.WhileUntil Dim body As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundDoLoopStatement.Body)) + Dim ignoredConditionOpt As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() + If doLoopKind = DoLoopKind.Invalid Then + Debug.Assert(boundDoLoopStatement.TopConditionOpt IsNot Nothing) + Debug.Assert(boundDoLoopStatement.BottomConditionOpt IsNot Nothing) + Debug.Assert(boundDoLoopStatement.ConditionOpt Is boundDoLoopStatement.TopConditionOpt) + Return Create(boundDoLoopStatement.BottomConditionOpt) + Else + Debug.Assert(boundDoLoopStatement.TopConditionOpt Is Nothing OrElse boundDoLoopStatement.BottomConditionOpt Is Nothing) + Return Nothing + End If + End Function) + Dim locals As ImmutableArray(Of ILocalSymbol) = ImmutableArray(Of ILocalSymbol).Empty Dim syntax As SyntaxNode = boundDoLoopStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() Dim isImplicit As Boolean = boundDoLoopStatement.WasCompilerGenerated - Return New LazyWhileUntilLoopStatement(isTopTest, isWhile, condition, LoopKind, body, _semanticModel, syntax, type, constantValue, isImplicit) + Return New LazyDoLoopStatement(doLoopKind, condition, body, ignoredConditionOpt, locals, _semanticModel, syntax, type, constantValue, isImplicit) End Function - Private Function CreateBoundForToStatementOperation(boundForToStatement As BoundForToStatement) As IForLoopStatement - Dim before As Lazy(Of ImmutableArray(Of IOperation)) = New Lazy(Of ImmutableArray(Of IOperation))( - Function() - Return GetForLoopStatementBefore( - boundForToStatement.ControlVariable, - boundForToStatement.InitialValue, - _semanticModel.CloneOperation(Create(boundForToStatement.LimitValue)), - _semanticModel.CloneOperation(Create(boundForToStatement.StepValue))) - End Function) - Dim atLoopBottom As Lazy(Of ImmutableArray(Of IOperation)) = New Lazy(Of ImmutableArray(Of IOperation))( - Function() - Return GetForLoopStatementAtLoopBottom( - _semanticModel.CloneOperation(Create(boundForToStatement.ControlVariable)), - boundForToStatement.StepValue, - boundForToStatement.OperatorsOpt) - End Function) - Dim locals As ImmutableArray(Of ILocalSymbol) = ImmutableArray(Of ILocalSymbol).Empty - Dim condition As Lazy(Of IOperation) = New Lazy(Of IOperation)( + Private Shared Function GetDoLoopKind(boundDoLoopStatement As BoundDoLoopStatement) As DoLoopKind + If boundDoLoopStatement.TopConditionOpt IsNot Nothing AndAlso boundDoLoopStatement.BottomConditionOpt IsNot Nothing Then + Return DoLoopKind.Invalid + End If + + If boundDoLoopStatement.ConditionIsTop Then + If boundDoLoopStatement.ConditionIsUntil Then + Return DoLoopKind.DoUntilTopLoop + Else + Return DoLoopKind.DoWhileTopLoop + End If + Else + If boundDoLoopStatement.ConditionIsUntil Then + Return DoLoopKind.DoUntilBottomLoop + Else + Return DoLoopKind.DoWhileBottomLoop + End If + End If + End Function + + Private Function CreateBoundForToStatementOperation(boundForToStatement As BoundForToStatement) As IForToLoopStatement + Dim locals As ImmutableArray(Of ILocalSymbol) = If(boundForToStatement.DeclaredOrInferredLocalOpt IsNot Nothing, + ImmutableArray.Create(Of ILocalSymbol)(boundForToStatement.DeclaredOrInferredLocalOpt), + ImmutableArray(Of ILocalSymbol).Empty) + Dim loopControlVariable As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundForToStatement.ControlVariable)) + Dim initialValue As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundForToStatement.InitialValue)) + Dim limitValue As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundForToStatement.LimitValue)) + Dim stepValue As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundForToStatement.StepValue)) + Dim body As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundForToStatement.Body)) + Dim nextVariables As Lazy(Of ImmutableArray(Of IOperation)) = New Lazy(Of ImmutableArray(Of IOperation))( Function() - Return GetForWhileUntilLoopStatementCondition( - boundForToStatement.ControlVariable, - boundForToStatement.LimitValue, - boundForToStatement.StepValue, - boundForToStatement.OperatorsOpt) + Return If(boundForToStatement.NextVariablesOpt.IsDefault, + ImmutableArray(Of IOperation).Empty, + boundForToStatement.NextVariablesOpt.SelectAsArray(Function(n) Create(n))) End Function) - Dim LoopKind As LoopKind = LoopKind.For - Dim body As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundForToStatement.Body)) Dim syntax As SyntaxNode = boundForToStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() Dim isImplicit As Boolean = boundForToStatement.WasCompilerGenerated - Return New LazyForLoopStatement(before, atLoopBottom, locals, condition, LoopKind, body, _semanticModel, syntax, type, constantValue, isImplicit) + Return New LazyForToLoopStatement(locals, loopControlVariable, initialValue, limitValue, stepValue, body, nextVariables, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundForEachStatementOperation(boundForEachStatement As BoundForEachStatement) As IForEachLoopStatement - Dim iterationVariable As ILocalSymbol = Nothing ' Manual + Dim locals As ImmutableArray(Of ILocalSymbol) = If(boundForEachStatement.DeclaredOrInferredLocalOpt IsNot Nothing, + ImmutableArray.Create(Of ILocalSymbol)(boundForEachStatement.DeclaredOrInferredLocalOpt), + ImmutableArray(Of ILocalSymbol).Empty) + Dim loopControlVariable As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundForEachStatement.ControlVariable)) Dim collection As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundForEachStatement.Collection)) - Dim LoopKind As LoopKind = LoopKind.ForEach Dim body As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundForEachStatement.Body)) + Dim nextVariables As Lazy(Of ImmutableArray(Of IOperation)) = New Lazy(Of ImmutableArray(Of IOperation))( + Function() + Return If(boundForEachStatement.NextVariablesOpt.IsDefault, + ImmutableArray(Of IOperation).Empty, + boundForEachStatement.NextVariablesOpt.SelectAsArray(Function(n) Create(n))) + End Function) Dim syntax As SyntaxNode = boundForEachStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() Dim isImplicit As Boolean = boundForEachStatement.WasCompilerGenerated - Return New LazyForEachLoopStatement(iterationVariable, collection, LoopKind, body, _semanticModel, syntax, type, constantValue, isImplicit) + Return New LazyForEachLoopStatement(locals, loopControlVariable, collection, nextVariables, body, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundTryStatementOperation(boundTryStatement As BoundTryStatement) As ITryStatement @@ -1057,17 +1083,15 @@ Namespace Microsoft.CodeAnalysis.Semantics Return New ExpressionStatement(throwExpression, _semanticModel, syntax, statementType, constantValue, isImplicit) End Function - Private Function CreateBoundWhileStatementOperation(boundWhileStatement As BoundWhileStatement) As IWhileUntilLoopStatement - Dim isTopTest As Boolean = True - Dim isWhile As Boolean = True + Private Function CreateBoundWhileStatementOperation(boundWhileStatement As BoundWhileStatement) As IWhileLoopStatement Dim condition As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundWhileStatement.Condition)) - Dim LoopKind As LoopKind = LoopKind.WhileUntil Dim body As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundWhileStatement.Body)) + Dim locals As ImmutableArray(Of ILocalSymbol) = ImmutableArray(Of ILocalSymbol).Empty Dim syntax As SyntaxNode = boundWhileStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() Dim isImplicit As Boolean = boundWhileStatement.WasCompilerGenerated - Return New LazyWhileUntilLoopStatement(isTopTest, isWhile, condition, LoopKind, body, _semanticModel, syntax, type, constantValue, isImplicit) + Return New LazyWhileLoopStatement(condition, body, locals, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundDimStatementOperation(boundDimStatement As BoundDimStatement) As IVariableDeclarationStatement diff --git a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory_Methods.vb b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory_Methods.vb index c913ca12c4076d269ca8cfef49d14d9938f0bda6..338fda4b5941b5a6a1529cb4f4c2e980ce581fe2 100644 --- a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory_Methods.vb +++ b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory_Methods.vb @@ -240,155 +240,6 @@ Namespace Microsoft.CodeAnalysis.Semantics Return Nothing End Function - Private Function GetForLoopStatementBefore( - controlVariable As BoundExpression, - initialValue As BoundExpression, - limitValue As IOperation, - stepValue As IOperation) As ImmutableArray(Of IOperation) - Dim statements As ArrayBuilder(Of IOperation) = ArrayBuilder(Of IOperation).GetInstance() - - ' ControlVariable = InitialValue - If controlVariable IsNot Nothing Then - statements.Add(OperationFactory.CreateSimpleAssignmentExpressionStatement(Create(controlVariable), Create(initialValue), _semanticModel, initialValue.Syntax, isImplicit:=controlVariable.WasCompilerGenerated)) - End If - - ' T0 = LimitValue - If Not limitValue.ConstantValue.HasValue Then - statements.Add( - OperationFactory.CreateSimpleAssignmentExpressionStatement( - New SyntheticLocalReferenceExpression( - SyntheticLocalKind.ForLoopLimitValue, - _semanticModel, - limitValue.Syntax, - limitValue.Type, - constantValue:=Nothing, - isImplicit:=limitValue.IsImplicit), limitValue, _semanticModel, limitValue.Syntax, limitValue.IsImplicit)) - End If - - ' T1 = StepValue - If stepValue IsNot Nothing AndAlso Not stepValue.ConstantValue.HasValue Then - statements.Add( - OperationFactory.CreateSimpleAssignmentExpressionStatement( - New SyntheticLocalReferenceExpression( - SyntheticLocalKind.ForLoopStepValue, - _semanticModel, - stepValue.Syntax, - stepValue.Type, - constantValue:=Nothing, - isImplicit:=stepValue.IsImplicit), stepValue, _semanticModel, stepValue.Syntax, stepValue.IsImplicit)) - End If - - Return statements.ToImmutableAndFree() - End Function - - Private Function GetForLoopStatementAtLoopBottom( - controlVariable As IOperation, - stepValue As BoundExpression, - operatorsOpt As BoundForToUserDefinedOperators) As ImmutableArray(Of IOperation) - Dim statements As ArrayBuilder(Of IOperation) = ArrayBuilder(Of IOperation).GetInstance() - If operatorsOpt IsNot Nothing Then - ' Use the operator methods. Figure out the precise rules first. - Else - If controlVariable IsNot Nothing Then - ' ControlVariable += StepValue - Dim controlType = DirectCast(controlVariable.Type, VisualBasic.Symbols.TypeSymbol) - Dim stepValueExpression As BoundExpression = If(stepValue, New BoundLiteral(Nothing, Semantics.Expression.SynthesizeNumeric(controlType, 1), controlType)) - - Dim value = Create(stepValueExpression) - Dim stepOperand As IOperation = - If(stepValueExpression.IsConstant, - value, - New SyntheticLocalReferenceExpression( - SyntheticLocalKind.ForLoopStepValue, - _semanticModel, - value.Syntax, - value.Type, - constantValue:=Nothing, - isImplicit:=value.IsImplicit)) - statements.Add(OperationFactory.CreateCompoundAssignmentExpressionStatement( - controlVariable, stepOperand, - BinaryOperatorKind.Add, controlType.IsNullableType(), False, - Nothing, _semanticModel, stepValueExpression.Syntax, value.IsImplicit)) - End If - End If - - Return statements.ToImmutableAndFree() - End Function - - Private Function GetForWhileUntilLoopStatementCondition( - controlVariable As BoundExpression, - limitValue As BoundExpression, - stepValue As BoundExpression, - operatorsOpt As BoundForToUserDefinedOperators) As IOperation - - Dim limitValueOperation = Create(limitValue) - Dim limitValueReference As IOperation = - If(limitValue.IsConstant, - limitValueOperation, - New SyntheticLocalReferenceExpression( - SyntheticLocalKind.ForLoopLimitValue, - _semanticModel, - limitValueOperation.Syntax, - limitValueOperation.Type, - constantValue:=Nothing, - isImplicit:=limitValueOperation.IsImplicit)) - - ' controlVariable can be a BoundBadExpression in case of error - Dim booleanType As ITypeSymbol = controlVariable.ExpressionSymbol?.DeclaringCompilation.GetSpecialType(SpecialType.System_Boolean) - - If operatorsOpt IsNot Nothing Then - ' Use the operator methods. Figure out the precise rules first. - Return Nothing - Else - ' We are comparing the control variable against the limit value. Using - ' either the default stepping constant, or a user supplied constant. - ' This will be a lifted comparison if either the control variable or - ' limit value is nullable itself. - Dim isLifted = controlVariable.Type.IsNullableType() OrElse - limitValue.Type.IsNullableType() - - If stepValue Is Nothing OrElse (stepValue.IsConstant AndAlso stepValue.ConstantValueOpt IsNot Nothing) Then - ' Either ControlVariable <= LimitValue or ControlVariable >= LimitValue, depending on whether the step value is negative. - - Dim relationalCode As BinaryOperatorKind = - If(stepValue IsNot Nothing AndAlso stepValue.ConstantValueOpt.IsNegativeNumeric, BinaryOperatorKind.GreaterThanOrEqual, BinaryOperatorKind.LessThanOrEqual) - Return OperationFactory.CreateBinaryOperatorExpression( - relationalCode, _semanticModel.CloneOperation(Create(controlVariable)), limitValueReference, booleanType, _semanticModel, limitValueReference.Syntax, isLifted, isChecked:=False, isCompareText:=False, isImplicit:=limitValueReference.IsImplicit) - Else - ' If(StepValue >= 0, ControlVariable <= LimitValue, ControlVariable >= LimitValue) - Dim value = Create(stepValue) - Dim stepValueReference As IOperation = New SyntheticLocalReferenceExpression( - SyntheticLocalKind.ForLoopStepValue, - _semanticModel, - value.Syntax, - value.Type, - constantValue:=Nothing, - isImplicit:=value.IsImplicit) - - Dim stepRelationalCode As BinaryOperatorKind = BinaryOperatorKind.GreaterThanOrEqual - Dim stepConditionIsLifted = stepValue.Type.IsNullableType() - Dim stepCondition As IOperation = OperationFactory.CreateBinaryOperatorExpression(stepRelationalCode, - stepValueReference, - OperationFactory.CreateLiteralExpression(Semantics.Expression.SynthesizeNumeric(stepValueReference.Type, 0), stepValue.Type, _semanticModel, stepValue.Syntax, stepValueReference.IsImplicit), - booleanType, - _semanticModel, - stepValue.Syntax, - stepConditionIsLifted, - isChecked:=False, - isCompareText:=False, - isImplicit:=stepValue.WasCompilerGenerated) - - Dim positiveStepRelationalCode As BinaryOperatorKind = BinaryOperatorKind.LessThanOrEqual - Dim positiveStepCondition As IOperation = OperationFactory.CreateBinaryOperatorExpression(positiveStepRelationalCode, _semanticModel.CloneOperation(Create(controlVariable)), limitValueReference, booleanType, _semanticModel, limitValueReference.Syntax, isLifted, isChecked:=False, isCompareText:=False, isImplicit:=limitValueReference.IsImplicit) - - Dim negativeStepRelationalCode As BinaryOperatorKind = BinaryOperatorKind.GreaterThanOrEqual - Dim negativeStepCondition As IOperation = OperationFactory.CreateBinaryOperatorExpression(negativeStepRelationalCode, _semanticModel.CloneOperation(Create(controlVariable)), _semanticModel.CloneOperation(limitValueReference), booleanType, _semanticModel, limitValueReference.Syntax, isLifted, isChecked:=False, isCompareText:=False, isImplicit:=limitValueReference.IsImplicit) - - Return OperationFactory.CreateConditionalExpression(stepCondition, positiveStepCondition, negativeStepCondition, booleanType, _semanticModel, limitValueReference.Syntax, limitValueReference.IsImplicit) - End If - End If - End Function - Private Function GetVariableDeclarationStatementVariables(statement As BoundDimStatement) As ImmutableArray(Of IVariableDeclaration) Dim builder = ArrayBuilder(Of IVariableDeclaration).GetInstance() For Each base In statement.LocalDeclarations diff --git a/src/Compilers/VisualBasic/Test/Semantic/Diagnostics/OperationAnalyzerTests.vb b/src/Compilers/VisualBasic/Test/Semantic/Diagnostics/OperationAnalyzerTests.vb index 27a8e3199014d272fce04b4af5f1c6e8bf840469..37f5d29722d050f305241621348e61d99e22c841 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/Diagnostics/OperationAnalyzerTests.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/Diagnostics/OperationAnalyzerTests.vb @@ -138,31 +138,6 @@ End Class Diagnostic(BadStuffTestAnalyzer.IsInvalidDescriptor.Id, "").WithLocation(8, 13)) End Sub - - Public Sub BigForVisualBasic() - Dim source = - - - - - - Dim comp = CompilationUtils.CreateCompilationWithMscorlibAndVBRuntime(source, parseOptions:=TestOptions.RegularWithIOperationFeature) - comp.VerifyDiagnostics() - comp.VerifyAnalyzerDiagnostics({New BigForTestAnalyzer}, Nothing, Nothing, False, - Diagnostic(BigForTestAnalyzer.BigForDescriptor.Id, "For x = 1 To 2000000 : Next").WithLocation(5, 9), - Diagnostic(BigForTestAnalyzer.BigForDescriptor.Id, "For x = 3000000 To 0 Step -2 : Next").WithLocation(7, 9)) - End Sub - Public Sub SwitchVisualBasic() Dim source = diff --git a/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests.vb b/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests.vb index c675edfcd5ed8a9cf807603b5f77a9ddf2a6fce6..246680a24153d9b73ac5f923b5accc705d0bf40c 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests.vb @@ -268,22 +268,14 @@ Class C End Class]]>.Value Dim expectedOperationTree = .Value Dim expectedDiagnostics = String.Empty diff --git a/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IForEachLoopStatement.vb b/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IForEachLoopStatement.vb index 7e60408f58cd067d3ee3856a8d00a6794c07ba10..9abd6f0b85fd25197e4192446886e82e0d149ed8 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IForEachLoopStatement.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IForEachLoopStatement.vb @@ -28,7 +28,9 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForEachBlockSyntax)(source, expectedOperationTree) @@ -65,7 +68,9 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForEachBlockSyntax)(source, expectedOperationTree) @@ -102,8 +108,10 @@ End Class ]]>.Value -Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForEachBlockSyntax)(source, expectedOperationTree) @@ -145,13 +154,17 @@ End Class ]]>.Value -Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForEachBlockSyntax)(source, expectedOperationTree) @@ -196,7 +213,9 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForEachBlockSyntax)(source, expectedOperationTree) @@ -232,12 +252,16 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForEachBlockSyntax)(source, expectedOperationTree) @@ -280,7 +306,9 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForEachBlockSyntax)(source, expectedOperationTree) @@ -316,7 +345,9 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForEachBlockSyntax)(source, expectedOperationTree) @@ -354,7 +386,9 @@ End Structure ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForEachBlockSyntax)(source, expectedOperationTree) @@ -425,7 +460,9 @@ End Class ]]>.Value Dim expectedOperationTree = + LoopControlVariable: ILocalReferenceExpression: country (OperationKind.LocalReferenceExpression, Type: ) (Syntax: 'country') Collection: ILocalReferenceExpression: countries (OperationKind.LocalReferenceExpression, Type: System.Linq.IOrderedEnumerable(Of )) (Syntax: 'countries') Body: IBlockStatement (2 statements) (OperationKind.BlockStatement) (Syntax: 'For Each co ... Next') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Debug.Write ... ntry.Count)') @@ -444,7 +481,9 @@ IForEachLoopStatement (Iteration variable: null) (LoopKind.ForEach) (OperationKi Instance Receiver: ILocalReferenceExpression: country (OperationKind.LocalReferenceExpression, Type: ) (Syntax: 'country') InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) - IForEachLoopStatement (Iteration variable: null) (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'For Each cu ... Next') + IForEachLoopStatement (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'For Each cu ... Next') + Locals: Local_1: customer As Customer + LoopControlVariable: ILocalReferenceExpression: customer (OperationKind.LocalReferenceExpression, Type: Customer) (Syntax: 'customer') Collection: IPropertyReferenceExpression: ReadOnly Property .CustomersInCountry As System.Collections.Generic.IEnumerable(Of Customer) (OperationKind.PropertyReferenceExpression, Type: System.Collections.Generic.IEnumerable(Of Customer)) (Syntax: 'country.Cus ... rsInCountry') Instance Receiver: ILocalReferenceExpression: country (OperationKind.LocalReferenceExpression, Type: ) (Syntax: 'country') Body: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'For Each cu ... Next') @@ -464,6 +503,8 @@ IForEachLoopStatement (Iteration variable: null) (LoopKind.ForEach) (OperationKi Instance Receiver: ILocalReferenceExpression: customer (OperationKind.LocalReferenceExpression, Type: Customer) (Syntax: 'customer') InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) + NextVariables(0) + NextVariables(0) ]]>.Value Dim expectedDiagnostics = String.Empty @@ -499,7 +540,9 @@ End Module ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForEachBlockSyntax)(source, expectedOperationTree) @@ -562,7 +606,9 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForEachBlockSyntax)(source, expectedOperationTree) @@ -613,7 +660,9 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForEachBlockSyntax)(source, expectedOperationTree) @@ -669,7 +719,8 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForEachBlockSyntax)(source, expectedOperationTree) @@ -703,7 +756,9 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForEachBlockSyntax)(source, expectedOperationTree) @@ -739,8 +795,10 @@ Class C End Class ]]>.Value -Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForEachBlockSyntax)(source, expectedOperationTree) @@ -786,7 +845,9 @@ End Class ]]>.Value Dim expectedOperationTree = .Value + IfFalse: null + NextVariables(0) +]]>.Value VerifyOperationTreeForTest(Of ForEachBlockSyntax)(source, expectedOperationTree) End Sub + + + Public Sub IForEachLoopStatement_FieldAsIterationVariable() + Dim source = .Value + + Dim expectedOperationTree = .Value + + Dim expectedDiagnostics = String.Empty + + VerifyOperationTreeAndDiagnosticsForTest(Of ForEachBlockSyntax)(source, expectedOperationTree, expectedDiagnostics) + End Sub + + + + Public Sub IForEachLoopStatement_FieldWithExplicitReceiverAsIterationVariable() + Dim source = .Value + + Dim expectedOperationTree = .Value + + Dim expectedDiagnostics = String.Empty + + VerifyOperationTreeAndDiagnosticsForTest(Of ForEachBlockSyntax)(source, expectedOperationTree, expectedDiagnostics) + End Sub + End Class End Namespace diff --git a/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IForLoopStatement.vb b/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IForLoopStatement.vb index 1d7eda297c6f6f33997e7eddabc833922f5587de..376df5135be7fc3be838a0192fcfcf3a703fb252 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IForLoopStatement.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IForLoopStatement.vb @@ -24,29 +24,17 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -86,39 +75,16 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -154,37 +121,16 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -221,35 +168,11 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -286,74 +210,50 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -380,39 +280,23 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -451,41 +337,25 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -520,41 +392,26 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -588,25 +446,18 @@ End Enum ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -636,35 +487,28 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -688,26 +532,19 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -727,23 +564,16 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -762,28 +592,18 @@ Public Class MyClass1 Next End Sub End Class - - ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -812,23 +632,16 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -857,22 +670,14 @@ End Class ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -908,26 +714,16 @@ End Module ]]>.Value Dim expectedOperationTree = .Value Dim expectedDiagnostics = String.Empty @@ -955,24 +751,14 @@ End Module ]]>.Value Dim expectedOperationTree = .Value Dim expectedDiagnostics = .Value Dim expectedOperationTree = .Value Dim expectedDiagnostics = String.Empty @@ -1055,27 +829,15 @@ End Structure ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -1096,42 +858,19 @@ End Structure ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -1152,29 +891,17 @@ End Structure ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -1195,40 +922,17 @@ End Structure ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -1250,38 +954,15 @@ End Structure ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -1303,40 +984,17 @@ End Structure ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -1358,40 +1016,17 @@ End Structure ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) @@ -1413,41 +1048,90 @@ End Structure ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of ForBlockSyntax)(source, expectedOperationTree) + End Sub + + + + Public Sub VerifyForToLoop_FieldAsIterationVariable() + Dim source = .Value + + Dim expectedOperationTree = .Value + + Dim expectedDiagnostics = String.Empty + + VerifyOperationTreeAndDiagnosticsForTest(Of ForBlockSyntax)(source, expectedOperationTree, expectedDiagnostics) + End Sub + + + + Public Sub VerifyForToLoop_FieldWithExplicitReceiverAsIterationVariable() + Dim source = .Value + + Dim expectedOperationTree = .Value + + Dim expectedDiagnostics = String.Empty + + VerifyOperationTreeAndDiagnosticsForTest(Of ForBlockSyntax)(source, expectedOperationTree, expectedDiagnostics) End Sub End Class End Namespace diff --git a/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IWhileUntilLoopStatement.vb b/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IWhileUntilLoopStatement.vb index 312387fee2d57d886121e21579a890272809efbb..8ba1ea367f441c13cbfac2c51445b938b4fd145a 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IWhileUntilLoopStatement.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IWhileUntilLoopStatement.vb @@ -1,4 +1,4 @@ -' 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.Semantics Imports Microsoft.CodeAnalysis.Test.Utilities @@ -30,10 +30,11 @@ End Class ]]>.Value Dim expectedOperationTree = + + Public Sub IWhileUntilLoopStatement_DoUntilLoopTest() + Dim source = .Value + + Dim expectedOperationTree = .Value + + Dim expectedDiagnostics = String.Empty + + VerifyOperationTreeAndDiagnosticsForTest(Of DoLoopBlockSyntax)(source, expectedOperationTree, expectedDiagnostics) + End Sub + Public Sub IWhileUntilLoopStatement_WhileConditionTrue() @@ -70,7 +107,7 @@ End Class ]]>.Value Dim expectedOperationTree = .Value Dim expectedOperationTree = .Value Dim expectedOperationTree = .Value Dim expectedOperationTree = .Value Dim expectedOperationTree = = 0') Left: IParenthesizedExpression (OperationKind.ParenthesizedExpression, Type: System.Int32) (Syntax: '(InlineAssi ... (i, value))') Operand: IInvocationExpression (Function Program.InlineAssignHelper(Of System.Int32)(ByRef target As System.Int32, value As System.Int32) As System.Int32) (OperationKind.InvocationExpression, Type: System.Int32) (Syntax: 'InlineAssig ... r(i, value)') @@ -341,7 +378,7 @@ End Class ]]>.Value Dim expectedOperationTree = .Value Dim expectedOperationTree = .Value + Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1') +]]>.Value VerifyOperationTreeForTest(Of WhileBlockSyntax)(source, expectedOperationTree) End Sub @@ -416,7 +454,7 @@ End Class ]]>.Value Dim expectedOperationTree = .Value + ReturnedValue: IParameterReferenceExpression: number (OperationKind.ParameterReferenceExpression, Type: System.Int32) (Syntax: 'number') +]]>.Value VerifyOperationTreeForTest(Of WhileBlockSyntax)(source, expectedOperationTree) End Sub @@ -460,7 +499,7 @@ End Class ]]>.Value Dim expectedOperationTree = .Value Dim expectedOperationTree = .Value Dim expectedOperationTree = .Value Dim expectedOperationTree = .Value Dim expectedOperationTree = .Value Dim expectedOperationTree = .Value Dim expectedOperationTree = .Value Dim expectedOperationTree = 0 ... End While') +IWhileLoopStatement (LoopKind.While) (OperationKind.LoopStatement) (Syntax: 'While i > 0 ... End While') Condition: IBinaryOperatorExpression (BinaryOperatorKind.GreaterThan, Checked) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i > 0') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 0) (Syntax: '0') @@ -834,7 +873,7 @@ End Class ]]>.Value Dim expectedOperationTree = .Value Dim expectedOperationTree = 0') Conversion: CommonConversion (Exists: False, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) Operand: IBinaryOperatorExpression (BinaryOperatorKind.GreaterThan, Checked) (OperationKind.BinaryOperatorExpression, Type: ?, IsInvalid) (Syntax: 'System.Math ... x + 1) > 0') @@ -930,10 +969,11 @@ End Class ]]>.Value Dim expectedOperationTree = .Value Dim expectedOperationTree = + + Public Sub IWhileUntilLoopStatement_DoLoopUntilStatement() + Dim source = .Value + + Dim expectedOperationTree = .Value + + Dim expectedDiagnostics = String.Empty + + VerifyOperationTreeAndDiagnosticsForTest(Of DoLoopBlockSyntax)(source, expectedOperationTree, expectedDiagnostics) + End Sub + Public Sub IWhileUntilLoopStatement_WhileWithNot() @@ -1007,7 +1084,7 @@ End Module ]]>.Value Dim expectedOperationTree = .Value VerifyOperationTreeForTest(Of WhileBlockSyntax)(source, expectedOperationTree) End Sub + + + + Public Sub IWhileUntilLoopStatement_DoWhileWithTopAndBottomCondition() + Dim source = 0'BIND:"Do While i > 0" + i = i + 1 + Loop Until i <= 0 + + End Sub +End Class]]>.Value + + Dim expectedOperationTree = 0') + Left: IParameterReferenceExpression: i (OperationKind.ParameterReferenceExpression, Type: System.Int32) (Syntax: 'i') + Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 0) (Syntax: '0') + IgnoredCondition: IBinaryOperatorExpression (BinaryOperatorKind.LessThanOrEqual, Checked) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'i <= 0') + Left: IParameterReferenceExpression: i (OperationKind.ParameterReferenceExpression, Type: System.Int32) (Syntax: 'i') + Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 0) (Syntax: '0') + Body: IBlockStatement (1 statements) (OperationKind.BlockStatement, IsInvalid) (Syntax: 'Do While i ... ntil i <= 0') + IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'i = i + 1') + Expression: ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'i = i + 1') + Left: IParameterReferenceExpression: i (OperationKind.ParameterReferenceExpression, Type: System.Int32) (Syntax: 'i') + Right: IBinaryOperatorExpression (BinaryOperatorKind.Add, Checked) (OperationKind.BinaryOperatorExpression, Type: System.Int32) (Syntax: 'i + 1') + Left: IParameterReferenceExpression: i (OperationKind.ParameterReferenceExpression, Type: System.Int32) (Syntax: 'i') + Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1') +]]>.Value + + Dim expectedDiagnostics = .Value + + VerifyOperationTreeAndDiagnosticsForTest(Of DoLoopBlockSyntax)(source, expectedOperationTree, expectedDiagnostics) + End Sub End Class End Namespace diff --git a/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_InvalidStatement.vb b/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_InvalidStatement.vb index f17d031303bce5a429442c69516ee3da32dabf34..49db210696a945b71d956908cdc564ff2ecb42a0 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_InvalidStatement.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_InvalidStatement.vb @@ -1,4 +1,4 @@ -' 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.Semantics Imports Microsoft.CodeAnalysis.Test.Utilities @@ -205,29 +205,19 @@ Module Program End Module ]]>.Value -Dim expectedOperationTree = .Value Dim expectedDiagnostics = .Value -Dim expectedOperationTree = .Value Dim expectedDiagnostics = .Value Dim expectedOperationTree = .Value Dim expectedDiagnostics = GetOperationsUptoInvalidOperation(IOperat operation.Kind != OperationKind.None && operation.Kind != OperationKind.InvalidExpression && operation.Kind != OperationKind.InvalidStatement && - operation.Kind != OperationKind.PlaceholderExpression) + operation.Kind != OperationKind.PlaceholderExpression && + (operation.Kind != OperationKind.TupleExpression || !(semanticModel.GetOperationInternal(node.Parent)?.Kind == OperationKind.LoopStatement))) // https://github.com/dotnet/roslyn/issues/20798 { Assert.True(set.Contains(operation)); } @@ -724,45 +725,49 @@ private static bool IsIgnoredNode(SyntaxNode node) } } - var vbNode = (VisualBasic.VisualBasicSyntaxNode)node; - switch (vbNode.Kind()) - { - case VisualBasic.SyntaxKind.SimpleArgument: - return vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.ArgumentList || - vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.TupleExpression; - case VisualBasic.SyntaxKind.VariableDeclarator: - return vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.LocalDeclarationStatement || - vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.FieldDeclaration; - case VisualBasic.SyntaxKind.EqualsValue: - return vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.VariableDeclarator; - case VisualBasic.SyntaxKind.NamedFieldInitializer: - return vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.ObjectMemberInitializer; - case VisualBasic.SyntaxKind.ObjectMemberInitializer: - return vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.AnonymousObjectCreationExpression; - case VisualBasic.SyntaxKind.SelectStatement: - return vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.SelectBlock; - case VisualBasic.SyntaxKind.CollectionInitializer: - case VisualBasic.SyntaxKind.ModifiedIdentifier: - case VisualBasic.SyntaxKind.CaseBlock: - case VisualBasic.SyntaxKind.CaseElseBlock: - case VisualBasic.SyntaxKind.CaseStatement: - case VisualBasic.SyntaxKind.CaseElseStatement: - case VisualBasic.SyntaxKind.WhileClause: - case VisualBasic.SyntaxKind.ArgumentList: - case VisualBasic.SyntaxKind.FromClause: - case VisualBasic.SyntaxKind.ExpressionRangeVariable: - case VisualBasic.SyntaxKind.LetClause: - case VisualBasic.SyntaxKind.JoinCondition: - case VisualBasic.SyntaxKind.AsNewClause: - case VisualBasic.SyntaxKind.ForStepClause: - case VisualBasic.SyntaxKind.UntilClause: - case VisualBasic.SyntaxKind.InterpolationAlignmentClause: - return true; - default: - return vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.AddHandlerStatement || - vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.RemoveHandlerStatement || - vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.RaiseEventStatement; + if (node is VisualBasic.VisualBasicSyntaxNode vbNode) + { + switch (vbNode.Kind()) + { + case VisualBasic.SyntaxKind.SimpleArgument: + return vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.ArgumentList || + vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.TupleExpression; + case VisualBasic.SyntaxKind.VariableDeclarator: + return vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.LocalDeclarationStatement || + vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.FieldDeclaration; + case VisualBasic.SyntaxKind.EqualsValue: + return vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.VariableDeclarator; + case VisualBasic.SyntaxKind.NamedFieldInitializer: + return vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.ObjectMemberInitializer; + case VisualBasic.SyntaxKind.ObjectMemberInitializer: + return vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.AnonymousObjectCreationExpression; + case VisualBasic.SyntaxKind.SelectStatement: + return vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.SelectBlock; + case VisualBasic.SyntaxKind.CollectionInitializer: + case VisualBasic.SyntaxKind.ModifiedIdentifier: + case VisualBasic.SyntaxKind.CaseBlock: + case VisualBasic.SyntaxKind.CaseElseBlock: + case VisualBasic.SyntaxKind.CaseStatement: + case VisualBasic.SyntaxKind.CaseElseStatement: + case VisualBasic.SyntaxKind.WhileClause: + case VisualBasic.SyntaxKind.ArgumentList: + case VisualBasic.SyntaxKind.FromClause: + case VisualBasic.SyntaxKind.ExpressionRangeVariable: + case VisualBasic.SyntaxKind.LetClause: + case VisualBasic.SyntaxKind.JoinCondition: + case VisualBasic.SyntaxKind.AsNewClause: + case VisualBasic.SyntaxKind.ForStepClause: + case VisualBasic.SyntaxKind.UntilClause: + case VisualBasic.SyntaxKind.InterpolationAlignmentClause: + return true; + default: + return vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.AddHandlerStatement || + vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.RemoveHandlerStatement || + vbNode.Parent?.Kind() == VisualBasic.SyntaxKind.RaiseEventStatement; + } } + + throw ExceptionUtilities.Unreachable; } #endregion } diff --git a/src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs b/src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs index cf07efb8435a266dda402761d35541e7820db1d6..deeb7c2e25bcfd17acb4c1c265a889625f320469 100644 --- a/src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs +++ b/src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs @@ -406,11 +406,21 @@ public override void VisitSwitchCase(ISwitchCase operation) Unindent(); } - public override void VisitWhileUntilLoopStatement(IWhileUntilLoopStatement operation) + public override void VisitDoLoopStatement(IDoLoopStatement operation) { - LogString(nameof(IWhileUntilLoopStatement)); + LogString(nameof(IDoLoopStatement)); - LogString($" (IsTopTest: {operation.IsTopTest}, IsWhile: {operation.IsWhile})"); + LogString($" (DoLoopKind: {operation.DoLoopKind})"); + LogLoopStatementHeader(operation); + + Visit(operation.Condition, "Condition"); + Visit(operation.IgnoredCondition, "IgnoredCondition"); + Visit(operation.Body, "Body"); + } + + public override void VisitWhileLoopStatement(IWhileLoopStatement operation) + { + LogString(nameof(IWhileLoopStatement)); LogLoopStatementHeader(operation); Visit(operation.Condition, "Condition"); @@ -423,12 +433,24 @@ public override void VisitForLoopStatement(IForLoopStatement operation) LogLoopStatementHeader(operation); Visit(operation.Condition, "Condition"); - LogLocals(operation.Locals); VisitArray(operation.Before, "Before", logElementCount: false); VisitArray(operation.AtLoopBottom, "AtLoopBottom", logElementCount: false); Visit(operation.Body, "Body"); } + public override void VisitForToLoopStatement(IForToLoopStatement operation) + { + LogString(nameof(IForToLoopStatement)); + LogLoopStatementHeader(operation); + + Visit(operation.LoopControlVariable, "LoopControlVariable"); + Visit(operation.InitialValue, "InitialValue"); + Visit(operation.LimitValue, "LimitValue"); + Visit(operation.StepValue, "StepValue"); + Visit(operation.Body, "Body"); + VisitArray(operation.NextVariables, "NextVariables", logElementCount: true); + } + private void LogLocals(IEnumerable locals, string header = "Locals") { if (!locals.Any()) @@ -457,17 +479,19 @@ private void LogLoopStatementHeader(ILoopStatement operation) var kindStr = $"{nameof(LoopKind)}.{operation.LoopKind}"; LogString($" ({kindStr})"); LogCommonPropertiesAndNewLine(operation); + + LogLocals(operation.Locals); } public override void VisitForEachLoopStatement(IForEachLoopStatement operation) { LogString(nameof(IForEachLoopStatement)); - LogSymbol(operation.IterationVariable, " (Iteration variable"); - LogString(")"); - LogLoopStatementHeader(operation); + + Visit(operation.LoopControlVariable, "LoopControlVariable"); Visit(operation.Collection, "Collection"); Visit(operation.Body, "Body"); + VisitArray(operation.NextVariables, "NextVariables", logElementCount: true); } public override void VisitLabeledStatement(ILabeledStatement operation) @@ -683,16 +707,6 @@ public override void VisitParameterReferenceExpression(IParameterReferenceExpres LogCommonPropertiesAndNewLine(operation); } - public override void VisitSyntheticLocalReferenceExpression(ISyntheticLocalReferenceExpression operation) - { - LogString(nameof(ISyntheticLocalReferenceExpression)); - var kindStr = $"{nameof(SynthesizedLocalKind)}.{operation.SyntheticLocalKind}"; - LogString($" ({kindStr})"); - LogCommonPropertiesAndNewLine(operation); - - base.VisitSyntheticLocalReferenceExpression(operation); - } - public override void VisitInstanceReferenceExpression(IInstanceReferenceExpression operation) { LogString(nameof(IInstanceReferenceExpression)); diff --git a/src/Test/Utilities/Portable/Compilation/TestOperationWalker.cs b/src/Test/Utilities/Portable/Compilation/TestOperationWalker.cs index 3953139e6872fe728412b1893485ce7310d0d495..4dd444241d417600a10c038578605819639c4955 100644 --- a/src/Test/Utilities/Portable/Compilation/TestOperationWalker.cs +++ b/src/Test/Utilities/Portable/Compilation/TestOperationWalker.cs @@ -100,30 +100,47 @@ public override void VisitDefaultCaseClause(IDefaultCaseClause operation) base.VisitDefaultCaseClause(operation); } - public override void VisitWhileUntilLoopStatement(IWhileUntilLoopStatement operation) + private void WalkLoopStatement(ILoopStatement operation) { var loopKind = operation.LoopKind; - var isTopTest = operation.IsTopTest; - var isWhile = operation.IsWhile; + foreach (var local in operation.Locals) + { + // empty loop body, just want to make sure it won't crash. + } + } + + public override void VisitDoLoopStatement(IDoLoopStatement operation) + { + var doLoopKind = operation.DoLoopKind; + WalkLoopStatement(operation); - base.VisitWhileUntilLoopStatement(operation); + base.VisitDoLoopStatement(operation); + } + + public override void VisitWhileLoopStatement(IWhileLoopStatement operation) + { + WalkLoopStatement(operation); + + base.VisitWhileLoopStatement(operation); } public override void VisitForLoopStatement(IForLoopStatement operation) { - var loopKind = operation.LoopKind; - foreach (var local in operation.Locals) - { - // empty loop body, just want to make sure it won't crash. - } + WalkLoopStatement(operation); base.VisitForLoopStatement(operation); } + public override void VisitForToLoopStatement(IForToLoopStatement operation) + { + WalkLoopStatement(operation); + + base.VisitForToLoopStatement(operation); + } + public override void VisitForEachLoopStatement(IForEachLoopStatement operation) { - var loopKind = operation.LoopKind; - var iteraionVariable = operation.IterationVariable; + WalkLoopStatement(operation); base.VisitForEachLoopStatement(operation); } @@ -253,13 +270,6 @@ public override void VisitParameterReferenceExpression(IParameterReferenceExpres base.VisitParameterReferenceExpression(operation); } - public override void VisitSyntheticLocalReferenceExpression(ISyntheticLocalReferenceExpression operation) - { - var syntheticLocalKind = operation.SyntheticLocalKind; - - base.VisitSyntheticLocalReferenceExpression(operation); - } - public override void VisitInstanceReferenceExpression(IInstanceReferenceExpression operation) { base.VisitInstanceReferenceExpression(operation); diff --git a/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs b/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs index 19dbb9fa851c77c90c888cd86e6c9593cf7e7804..7431193b49162a40de4d8e71f1fc02cffb18f489 100644 --- a/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs +++ b/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs @@ -1942,15 +1942,15 @@ public sealed override void Initialize(AnalysisContext context) (operationContext) => { ILoopStatement loop = (ILoopStatement)operationContext.Operation; - if (loop.LoopKind == LoopKind.For) + if (loop.LoopKind == LoopKind.ForTo) { - IForLoopStatement forLoop = (IForLoopStatement)loop; - var forCondition = forLoop.Condition; + var forLoop = (IForToLoopStatement)loop; + var forCondition = forLoop.LimitValue; if (forCondition.HasErrors(operationContext.Compilation, operationContext.CancellationToken)) { // Generate a warning to prove we didn't crash - operationContext.ReportDiagnostic(Diagnostic.Create(ForLoopConditionCrashDescriptor, forLoop.Condition.Syntax.GetLocation())); + operationContext.ReportDiagnostic(Diagnostic.Create(ForLoopConditionCrashDescriptor, forLoop.LimitValue.Syntax.GetLocation())); } } },