Debug.Assert(resultType.Equals(sourceType,ignoreCustomModifiersAndArraySizesAndLowerBounds:false,ignoreDynamic:true));// Same custom modifiers as source type.
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
usingSystem.Collections.Generic;
usingRoslyn.Utilities;
usingMicrosoft.CodeAnalysis.Semantics;
namespaceMicrosoft.CodeAnalysis.Semantics
namespaceMicrosoft.CodeAnalysis
{
/// <summary>
/// Root type for representing the abstract semantics of C# and VB statements and expressions.
...
...
@@ -25,6 +24,16 @@ public interface IOperation
/// </summary>
SyntaxNodeSyntax{get;}
/// <summary>
/// Result type of the operation, or null if the operation does not produce a result.
/// </summary>
ITypeSymbolType{get;}
/// <summary>
/// If the operation is an expression that evaluates to a constant value, <see cref="Optional{Object}.HasValue"/> is true and <see cref="Optional{Object}.Value"/> is the value of the expression. Otherwise, <see cref="Optional{Object}.HasValue"/> is false.
@@ -49,28 +42,28 @@ public interface IVariable : IOperation
/// <summary>
/// Initializer of the variable.
/// </summary>
IExpressionInitialValue{get;}
IOperationInitialValue{get;}
}
/// <summary>
/// Represents a C# switch or VB Select Case statement.
/// </summary>
publicinterfaceISwitchStatement:IStatement
publicinterfaceISwitchStatement:IOperation
{
/// <summary>
/// Value to be switched upon.
/// </summary>
IExpressionValue{get;}
IOperationValue{get;}
/// <summary>
/// Cases of the switch.
/// </summary>
ImmutableArray<ICase>Cases{get;}
ImmutableArray<ISwitchCase>Cases{get;}
}
/// <summary>
/// Represents a C# case or VB Case statement.
/// </summary>
publicinterfaceICase:IOperation
publicinterfaceISwitchCase:IOperation
{
/// <summary>
/// Clauses of the case. For C# there is one clause per case, but for VB there can be multiple.
...
...
@@ -79,7 +72,7 @@ public interface ICase : IOperation
/// <summary>
/// Statements of the case.
/// </summary>
ImmutableArray<IStatement>Body{get;}
ImmutableArray<IOperation>Body{get;}
}
/// <summary>
...
...
@@ -98,22 +91,24 @@ public interface ICaseClause : IOperation
/// </summary>
publicenumCaseKind
{
None=0x0,
/// <summary>
/// Indicates case x in C# or Case x in VB.
/// </summary>
SingleValue,
SingleValue=0x1,
/// <summary>
/// Indicates Case Is op x in VB.
/// </summary>
Relational,
Relational=0x2,
/// <summary>
/// Indicates Case x To Y in VB.
/// </summary>
Range,
Range=0x3,
/// <summary>
/// Indicates default in C# or Case Else in VB.
/// </summary>
Default
Default=0x4
}
/// <summary>
...
...
@@ -124,7 +119,7 @@ public interface ISingleValueCaseClause : ICaseClause
/// <summary>
/// Case value.
/// </summary>
IExpressionValue{get;}
IOperationValue{get;}
/// <summary>
/// Relational operator used to compare the switch value with the case value.
/// </summary>
...
...
@@ -139,7 +134,7 @@ public interface IRelationalCaseClause : ICaseClause
/// <summary>
/// Case value.
/// </summary>
IExpressionValue{get;}
IOperationValue{get;}
/// <summary>
/// Relational operator used to compare the switch value with the case value.
/// </summary>
...
...
@@ -154,36 +149,36 @@ public interface IRangeCaseClause : ICaseClause
/// <summary>
/// Minimum value of the case range.
/// </summary>
IExpressionMinimumValue{get;}
IOperationMinimumValue{get;}
/// <summary>
/// Maximum value of the case range.
/// </summary>
IExpressionMaximumValue{get;}
IOperationMaximumValue{get;}
}
/// <summary>
/// Represents an if statement in C# or an If statement in VB.
/// </summary>
publicinterfaceIIfStatement:IStatement
publicinterfaceIIfStatement:IOperation
{
/// <summary>
/// Condition of the if statement. For C# there is naturally one clause per if, but for VB If statements with multiple clauses are rewritten to have only one.
/// </summary>
IExpressionCondition{get;}
IOperationCondition{get;}
/// <summary>
/// Statement executed if the condition is true.
/// </summary>
IStatementIfTrue{get;}
IOperationIfTrueStatement{get;}
/// <summary>
/// Statement executed if the condition is false.
/// </summary>
IStatementIfFalse{get;}
IOperationIfFalseStatement{get;}
}
/// <summary>
/// Represents a C# while, for, foreach, or do statement, or a VB While, For, For Each, or Do statement.
/// </summary>
publicinterfaceILoopStatement:IStatement
publicinterfaceILoopStatement:IOperation
{
/// <summary>
/// Kind of the loop.
...
...
@@ -192,7 +187,7 @@ public interface ILoopStatement : IStatement
/// <summary>
/// Body of the loop.
/// </summary>
IStatementBody{get;}
IOperationBody{get;}
}
/// <summary>
...
...
@@ -200,18 +195,20 @@ public interface ILoopStatement : IStatement
/// </summary>
publicenumLoopKind
{
None=0x0,
/// <summary>
/// Indicates a C# while or do loop, or a VB While or Do loop.
/// </summary>
WhileUntil,
WhileUntil=0x1,
/// <summary>
/// Indicates a C# for loop or a VB For loop.
/// </summary>
For,
For=0x2,
/// <summary>
/// Indicates a C# foreach loop or a VB For Each loop.
/// </summary>
ForEach
ForEach=0x3
}
/// <summary>
...
...
@@ -222,7 +219,7 @@ public interface IForWhileUntilLoopStatement : ILoopStatement
/// <summary>
/// Condition of the loop.
/// </summary>
IExpressionCondition{get;}
IOperationCondition{get;}
}
/// <summary>
...
...
@@ -248,11 +245,11 @@ public interface IForLoopStatement : IForWhileUntilLoopStatement
/// <summary>
/// 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.
/// </summary>
ImmutableArray<IStatement>Before{get;}
ImmutableArray<IOperation>Before{get;}
/// <summary>
/// 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.
/// </summary>
ImmutableArray<IStatement>AtLoopBottom{get;}
ImmutableArray<IOperation>AtLoopBottom{get;}
/// <summary>
/// Declarations local to the loop.
/// </summary>
...
...
@@ -271,75 +268,88 @@ public interface IForEachLoopStatement : ILoopStatement
/// <summary>
/// Collection value over which the loop iterates.
/// </summary>
IExpressionCollection{get;}
IOperationCollection{get;}
}
/// <summary>
/// Represents a C# or VB label statement.
/// </summary>
publicinterfaceILabelStatement:IStatement
publicinterfaceILabelStatement:IOperation
{
// Label that can be the target of branches.
/// <summary>
/// Label that can be the target of branches.
/// </summary>
ILabelSymbolLabel{get;}
/// <summary>
/// Statement that has been labeled.
/// </summary>
IOperationLabeledStatement{get;}
}
/// <summary>
/// Represents a C# label statement.
/// Represents a C# goto, break, or continue statement, or a VB GoTo, Exit ***, or Continue *** statement
/// </summary>
publicinterfaceILabeledStatement:ILabelStatement
publicinterfaceIBranchStatement:IOperation
{
// Statement that has been labeled.
IStatementLabeled{get;}
/// <summary>
/// Label that is the target of the branch.
/// </summary>
ILabelSymbolTarget{get;}
/// <summary>
/// Kind of the branch.
/// </summary>
BranchKindBranchKind{get;}
}
/// <summary>
/// Represents a C# goto, break, or continue statement, or a VB GoTo, Exit ***, or Continue *** statement
/// </summary>
publicinterfaceIBranchStatement:IStatement
publicenumBranchKind
{
// Label that is the target of the branch.
ILabelSymbolTarget{get;}
None=0x0,
Continue=0x1,
Break=0x2,
GoTo=0x3
}
/// <summary>
/// Represents a C# throw or a VB Throw statement.
/// </summary>
publicinterfaceIThrowStatement:IStatement
publicinterfaceIThrowStatement:IOperation
{
// Thrown expression.
IExpressionThrown{get;}
/// <summary>
/// Value to be thrown.
/// </summary>
IOperationThrownObject{get;}
}
/// <summary>
/// Represents a C# return or a VB Return statement.
/// </summary>
publicinterfaceIReturnStatement:IStatement
publicinterfaceIReturnStatement:IOperation
{
/// <summary>
/// Value to be returned.
/// </summary>
IExpressionReturned{get;}
IOperationReturnedValue{get;}
}
/// <summary>
/// Represents a C# lock or a VB SyncLock statement.
/// </summary>
publicinterfaceILockStatement:IStatement
publicinterfaceILockStatement:IOperation
{
/// <summary>
/// Value to be locked.
/// </summary>
IExpressionLocked{get;}
IOperationLockedObject{get;}
/// <summary>
/// Body of the lock, to be executed while holding the lock.
/// </summary>
IStatementBody{get;}
IOperationBody{get;}
}
/// <summary>
/// Represents a C# try or a VB Try statement.
/// </summary>
publicinterfaceITryStatement:IStatement
publicinterfaceITryStatement:IOperation
{
/// <summary>
/// Body of the try, over which the handlers are active.
...
...
@@ -348,7 +358,7 @@ public interface ITryStatement : IStatement
/// <summary>
/// Catch clauses of the try.
/// </summary>
ImmutableArray<ICatch>Catches{get;}
ImmutableArray<ICatchClause>Catches{get;}
/// <summary>
/// Finally handler of the try.
/// </summary>
...
...
@@ -358,7 +368,7 @@ public interface ITryStatement : IStatement
/// <summary>
/// Represents a C# catch or VB Catch clause.
/// </summary>
publicinterfaceICatch:IOperation
publicinterfaceICatchClause:IOperation
{
/// <summary>
/// Body of the exception handler.
...
...
@@ -371,7 +381,7 @@ public interface ICatch : IOperation
/// <summary>
/// Filter expression to be executed to determine whether to handle the exception.
/// </summary>
IExpressionFilter{get;}
IOperationFilter{get;}
/// <summary>
/// Symbol for the local catch variable bound to the caught exception.
/// </summary>
...
...
@@ -381,12 +391,12 @@ public interface ICatch : IOperation
/// <summary>
/// Represents a C# using or VB Using statement.
/// </summary>
publicinterfaceIUsingStatement:IStatement
publicinterfaceIUsingStatement:IOperation
{
/// <summary>
/// Body of the using, over which the resources of the using are maintained.
/// </summary>
IStatementBody{get;}
IOperationBody{get;}
}
/// <summary>
...
...
@@ -395,9 +405,9 @@ public interface IUsingStatement : IStatement