65 lines
2.3 KiB
C#
65 lines
2.3 KiB
C#
using System.Diagnostics;
|
|||
|
|
using Microsoft.CodeAnalysis.CSharp.Symbols;
|
||
|
|
|
||
|
|
namespace Microsoft.CodeAnalysis.CSharp;
|
||
|
|
|
||
|
|
internal sealed class BoundConditionalOperator : BoundExpression
|
||
|
|
{
|
||
|
|
public bool IsDynamic
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if (Condition.Kind == BoundKind.UnaryOperator)
|
||
|
|
{
|
||
|
|
return ((BoundUnaryOperator)Condition).OperatorKind.IsDynamic();
|
||
|
|
}
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public new TypeSymbol Type => base.Type;
|
||
|
|
|
||
|
|
public bool IsRef { get; }
|
||
|
|
|
||
|
|
public BoundExpression Condition { get; }
|
||
|
|
|
||
|
|
public BoundExpression Consequence { get; }
|
||
|
|
|
||
|
|
public BoundExpression Alternative { get; }
|
||
|
|
|
||
|
|
public override ConstantValue? ConstantValueOpt { get; }
|
||
|
|
|
||
|
|
public TypeSymbol? NaturalTypeOpt { get; }
|
||
|
|
|
||
|
|
public bool WasTargetTyped { get; }
|
||
|
|
|
||
|
|
public BoundConditionalOperator(SyntaxNode syntax, bool isRef, BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue? constantValueOpt, TypeSymbol? naturalTypeOpt, bool wasTargetTyped, TypeSymbol type, bool hasErrors = false)
|
||
|
|
: base(BoundKind.ConditionalOperator, syntax, type, hasErrors || condition.HasErrors() || consequence.HasErrors() || alternative.HasErrors())
|
||
|
|
{
|
||
|
|
IsRef = isRef;
|
||
|
|
Condition = condition;
|
||
|
|
Consequence = consequence;
|
||
|
|
Alternative = alternative;
|
||
|
|
ConstantValueOpt = constantValueOpt;
|
||
|
|
NaturalTypeOpt = naturalTypeOpt;
|
||
|
|
WasTargetTyped = wasTargetTyped;
|
||
|
|
}
|
||
|
|
|
||
|
|
[DebuggerStepThrough]
|
||
|
|
public override BoundNode? Accept(BoundTreeVisitor visitor)
|
||
|
|
{
|
||
|
|
return visitor.VisitConditionalOperator(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
public BoundConditionalOperator Update(bool isRef, BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue? constantValueOpt, TypeSymbol? naturalTypeOpt, bool wasTargetTyped, TypeSymbol type)
|
||
|
|
{
|
||
|
|
if (isRef != IsRef || condition != Condition || consequence != Consequence || alternative != Alternative || constantValueOpt != ConstantValueOpt || !TypeSymbol.Equals(naturalTypeOpt, NaturalTypeOpt, (TypeCompareKind)0) || wasTargetTyped != WasTargetTyped || !TypeSymbol.Equals(type, Type, (TypeCompareKind)0))
|
||
|
|
{
|
||
|
|
BoundConditionalOperator boundConditionalOperator = new BoundConditionalOperator(Syntax, isRef, condition, consequence, alternative, constantValueOpt, naturalTypeOpt, wasTargetTyped, type, base.HasErrors);
|
||
|
|
boundConditionalOperator.CopyAttributes(this);
|
||
|
|
return boundConditionalOperator;
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
}
|