Binder\Binder_Conversions.cs (27)
322ConstantValue? constantValue = this.FoldConstantConversion(syntax, source, conversion, destination, diagnostics);
2471var constantValue = FoldConditionalOperator(condition, trueExpr, falseExpr);
2546constantValueOpt: ConstantValue.NotAvailable,
2636constantValueOpt: ConstantValue.NotAvailable,
2681constantValueOpt: ConstantValue.NotAvailable,
2736constantValueOpt: ConstantValue.NotAvailable,
2813constantValueOpt: ConstantValue.NotAvailable,
2871constantValueOpt: ConstantValue.NotAvailable, type: delegateType, hasErrors: true)
2923constantValueOpt: ConstantValue.NotAvailable,
2950return new BoundConversion(syntax, group, conversion, @checked: false, explicitCastInCode: isCast, conversionGroup, inConversionGroupFlags, constantValueOpt: ConstantValue.NotAvailable, type: destination, hasErrors: hasErrors) { WasCompilerGenerated = group.WasCompilerGenerated };
3023DefaultValueFromAttributes: ConstantValue.NotAvailable
3059var delegateParamDefault = delegateParameter.HasExplicitDefaultValue ? delegateParameter.ExplicitDefaultConstantValue : null;
3216constantValueOpt: ConstantValue.NotAvailable,
3233constantValueOpt: ConstantValue.NotAvailable,
3798public ConstantValue? FoldConstantConversion(
3833var sourceConstantValue = source.ConstantValueOpt;
3864return ConstantValue.Create(sourceConstantValue.SingleValue);
3866return ConstantValue.Create(sourceConstantValue.DoubleValue);
3900private ConstantValue? FoldConstantNumericConversion(
3902ConstantValue sourceValue,
3933return ConstantValue.Bad;
3941return ConstantValue.Bad;
3957return ConstantValue.Bad;
3970return ConstantValue.Create(DoUncheckedConversion(destinationType, sourceValue), destinationType);
3973private static object DoUncheckedConversion(SpecialType destinationType, ConstantValue value)
4276public static bool CheckConstantBounds(SpecialType destinationType, ConstantValue value, out bool maySucceedAtRuntime)
4353private static object CanonicalizeConstant(ConstantValue value)
Binder\Binder_InterpolatedString.cs (10)
42ConstantValue? resultConstant = null;
47resultConstant = ConstantValue.Create(string.Empty);
102var alignmentConstant = alignment.ConstantValueOpt;
137format = new BoundLiteral(interpolation.FormatClause, ConstantValue.Create(text), stringType, hasErrors);
167var constantValue = ConstantValue.Create(text, SpecialType.System_String);
414expressions[0] = new BoundLiteral(syntax, ConstantValue.Create(formatString.ToStringAndFree()), GetSpecialType(Microsoft.CodeAnalysis.SpecialType.System_String, diagnostics, syntax)) { WasCompilerGenerated = true };
820argumentsBuilder.Add(new BoundLiteral(syntax, ConstantValue.Create(baseStringLength), intType) { WasCompilerGenerated = true });
822argumentsBuilder.Add(new BoundLiteral(syntax, ConstantValue.Create(numFormatHoles), intType) { WasCompilerGenerated = true });
955argumentsBuilder.Add(boundLiteral.Update(ConstantValue.Create(literalText), boundLiteral.Type));
Binder\Binder_Invocation.cs (12)
1504defaultValue = new BoundFieldAccess(syntax, null, fieldSymbol, ConstantValue.NotAvailable) { WasCompilerGenerated = true };
1700var parameterDefaultValue = parameter.ExplicitDefaultConstantValue;
1707var defaultConstantValue = parameterDefaultValue switch
1710{ IsBad: true } => ConstantValue.Null,
1713Debug.Assert((object?)defaultConstantValue != ConstantValue.Unset);
1721defaultValue = new BoundLiteral(syntax, ConstantValue.Create(line), Compilation.GetSpecialType(SpecialType.System_Int32)) { WasCompilerGenerated = true };
1726defaultValue = new BoundLiteral(syntax, ConstantValue.Create(path), Compilation.GetSpecialType(SpecialType.System_String)) { WasCompilerGenerated = true };
1731defaultValue = new BoundLiteral(syntax, ConstantValue.Create(memberName), Compilation.GetSpecialType(SpecialType.System_String)) { WasCompilerGenerated = true };
1739defaultValue = new BoundLiteral(syntax, ConstantValue.Create(argument.Syntax.ToString()), Compilation.GetSpecialType(SpecialType.System_String)) { WasCompilerGenerated = true };
1741else if (defaultConstantValue == ConstantValue.NotAvailable)
1869BoundExpression arraySize = new BoundLiteral(node, ConstantValue.Create(collectionArgs.Length), int32Type) { WasCompilerGenerated = true };
2459return new BoundNameOfOperator(node, boundArgument, ConstantValue.Create(name), Compilation.GetSpecialType(SpecialType.System_String));
Binder\Binder_Operators.cs (114)
848constantValueOpt: ConstantValue.NotAvailable,
949return new BoundBinaryOperator(node, kind, ConstantValue.NotAvailable, methodOpt: null, constrainedToTypeOpt: null, LookupResultKind.Empty, left, right, GetBinaryOperatorErrorType(kind, diagnostics, node), true);
973return new BoundLiteral(node, ConstantValue.Create(kind == BinaryOperatorKind.Equal), GetSpecialType(SpecialType.System_Boolean, diagnostics, node));
989var stringConstant = FoldBinaryOperator(node, BinaryOperatorKind.StringConcatenation, left, right, right.Type, diagnostics);
1069ConstantValue resultConstant = null;
1444var constantValue = FoldBinaryOperator(node, kind | BinaryOperatorKind.Bool, left, right, left.Type, diagnostics);
1457return new BoundBinaryOperator(node, kind, ConstantValue.NotAvailable, methodOpt: null, constrainedToTypeOpt: null,
1573ConstantValue.NotAvailable,
1584return new BoundBinaryOperator(node, kind, left, right, ConstantValue.NotAvailable, methodOpt: null, constrainedToTypeOpt: null, lookupResult, originalUserDefinedOperators, CreateErrorType(), true);
2458private static object FoldDecimalBinaryOperators(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
2489private static object FoldNativeIntegerOverflowingBinaryOperator(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
2532private static object FoldUncheckedIntegralBinaryOperator(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
2588private static object FoldCheckedIntegralBinaryOperator(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
2678private ConstantValue? FoldEnumBinaryOperator(
2739var constantValue = FoldBinaryOperator(syntax, newKind, newLeftOperand, newRightOperand, resultTypeSymbol, diagnostics);
2753private ConstantValue? FoldBinaryOperator(
2770ConstantValue? nullableEqualityResult = TryFoldingNullableEquality(kind, left, right);
2776var valueLeft = left.ConstantValueOpt;
2777var valueRight = right.ConstantValueOpt;
2785return ConstantValue.Bad;
2797return ConstantValue.Bad;
2812return ConstantValue.Create(newValue, resultType);
2815ConstantValue? concatResult = FoldStringConcatenation(kind, valueLeft, valueRight);
2836return ConstantValue.Bad;
2841return ConstantValue.Create(newValue, resultType);
2860return ConstantValue.Create(newValue, resultType);
2872return ConstantValue.Bad;
2882return ConstantValue.Create(newValue, resultType);
2910private static ConstantValue? TryFoldingNullableEquality(BinaryOperatorKind kind, BoundExpression left, BoundExpression right)
2921ConstantValue? leftConstant = leftConv.Operand.ConstantValueOpt;
2922ConstantValue? rightConstant = rightConv.Operand.ConstantValueOpt;
2932return (leftIsNull == rightIsNull) == (op == BinaryOperatorKind.Equal) ? ConstantValue.True : ConstantValue.False;
2943private static object? FoldNeverOverflowBinaryOperators(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
3198private static ConstantValue? FoldStringConcatenation(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
3209return (newLength > int.MaxValue) ? ConstantValue.Bad : ConstantValue.CreateFromRope(Rope.Concat(leftValue, rightValue));
4362return new BoundUnaryOperator(node, kind, operand, ConstantValue.NotAvailable,
4383constantValueOpt: ConstantValue.NotAvailable,
4404ConstantValue.NotAvailable,
4419var resultConstant = FoldUnaryOperator(node, resultOperatorKind, resultOperand, resultType, diagnostics);
4435private ConstantValue? FoldEnumUnaryOperator(
4456var constantValue = FoldUnaryOperator(syntax, newKind, operand, upconvertType, diagnostics);
4470private ConstantValue? FoldUnaryOperator(
4485var value = operand.ConstantValueOpt;
4500return ConstantValue.Create(newValue, resultType);
4519return ConstantValue.Create(newValue, resultType);
4531return ConstantValue.Bad;
4541return ConstantValue.Create(newValue, resultType);
4547private static object? FoldNeverOverflowUnaryOperator(UnaryOperatorKind kind, ConstantValue value)
4587private static object? FoldUncheckedIntegralUnaryOperator(UnaryOperatorKind kind, ConstantValue value)
4603private static object? FoldCheckedIntegralUnaryOperator(UnaryOperatorKind kind, ConstantValue value)
4619private static object? FoldNativeIntegerOverflowingUnaryOperator(UnaryOperatorKind kind, ConstantValue value)
4708return new BoundLiteral(node, ConstantValue.Create((int)-2147483648), GetSpecialType(SpecialType.System_Int32, diagnostics, node));
4723return new BoundLiteral(node, ConstantValue.Create(-9223372036854775808), GetSpecialType(SpecialType.System_Int64, diagnostics, node));
4729private static bool IsDivisionByZero(BinaryOperatorKind kind, ConstantValue valueRight)
4898if (operand.ConstantValueOpt == ConstantValue.Null ||
4981var convertedExpression = BindExpressionForPattern(unionType, inputType, node.Right, ref hasErrors, diagnostics, out var constantValueOpt, out var wasExpression, patternExpressionConversion: out _, out BoundExpression originalExpression);
5009constantValueOpt ?? ConstantValue.Bad,
5033ConstantValue operandConstantValue)
5041ConstantValue constantValue = GetIsOperatorConstantResult(operandType, targetType, conversionKind, operandConstantValue, ref useSiteInfo);
5052Debug.Assert(constantValue == ConstantValue.True || constantValue == ConstantValue.False);
5054ErrorCode errorCode = constantValue == ConstantValue.True ? ErrorCode.WRN_IsAlwaysTrue : ErrorCode.WRN_IsAlwaysFalse;
5062/// - <see cref="ConstantValue.False"/>
5063/// - <see cref="ConstantValue.True"/>
5064/// - <see cref="ConstantValue.Bad"/> - compiler doesn't support the type check, i.e. cannot perform it, even at runtime
5067internal static ConstantValue GetIsOperatorConstantResult(
5071ConstantValue operandConstantValue,
5111if (operandConstantValue == ConstantValue.Null)
5113return ConstantValue.False;
5121(operandConstantValue == null || operandConstantValue == ConstantValue.Null); // a non-null constant is never null
5186return ConstantValue.False;
5196return ConstantValue.False;
5217return ConstantValue.False;
5225return ConstantValue.False;
5230return ConstantValue.Bad;
5241return ConstantValue.False;
5283return ConstantValue.False;
5293return ConstantValue.False;
5309return ConstantValue.False;
5318return operandCouldBeNull ? null : ConstantValue.True;
5324return ConstantValue.False;
5327return operandCouldBeNull ? null : ConstantValue.True;
5342return operandCouldBeNull ? null : ConstantValue.True;
5359return operandCouldBeNull ? null : ConstantValue.True;
5371? ConstantValue.True : ConstantValue.False;
5496operand = new BoundDefaultExpression(operand.Syntax, targetType: null, constantValueOpt: ConstantValue.Null,
5554ConstantValue operandConstantValue)
5616ConstantValue operandConstantValue)
5624ConstantValue constantValue = GetAsOperatorConstantResult(operandType, targetType, conversionKind, operandConstantValue, ref useSiteInfo);
5643/// - <see cref="ConstantValue.Null"/>
5644/// - <see cref="ConstantValue.Bad"/> - compiler doesn't support the type check, i.e. cannot perform it, even at runtime
5647internal static ConstantValue GetAsOperatorConstantResult(TypeSymbol operandType, TypeSymbol targetType, ConversionKind conversionKind, ConstantValue operandConstantValue, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
5654ConstantValue isOperatorConstantResult = GetIsOperatorConstantResult(operandType, targetType, conversionKind, operandConstantValue, ref useSiteInfo);
5666return ConstantValue.Bad;
5669return ConstantValue.Null;
6007ConstantValue? constantValue = null;
6103private static ConstantValue FoldConditionalOperator(BoundExpression condition, BoundExpression trueExpr, BoundExpression falseExpr)
6105ConstantValue trueValue = trueExpr.ConstantValueOpt;
6111ConstantValue falseValue = falseExpr.ConstantValueOpt;
6117ConstantValue conditionValue = condition.ConstantValueOpt;
6122else if (conditionValue == ConstantValue.True)
6126else if (conditionValue == ConstantValue.False)
6132return ConstantValue.Bad;
Binder\Binder_Patterns.cs (32)
510ConstantValue? constantValueOpt;
552constantValueOpt ?? ConstantValue.Bad,
567internal static bool IsClassOrNullableValueTypeUnionNullPatternMatching([NotNullWhen(true)] NamedTypeSymbol? unionMatchingInputType, [NotNullWhen(true)] ConstantValue? constantValueOpt)
570return unionMatchingInputType is not null && constantValueOpt == ConstantValue.Null && (unionMatchingInputType.IsNullableType() || !unionMatchingInputType.IsValueType);
622out ConstantValue? constantValueOpt,
642out ConstantValue? constantValueOpt,
672if (convertedExpression.Type is null && constantValueOpt != ConstantValue.Null)
686out ConstantValue? constantValue,
702if (expression.ConstantValueOpt == ConstantValue.Null)
715ConstantValue match = ExpressionOfTypeMatchesPatternType(Conversions, inputType, expression.Type, ref useSiteInfo, out _, operandConstantValue: null);
716if (match == ConstantValue.False || match == ConstantValue.Bad)
766if (constantValue == ConstantValue.Null)
824constantValue: out var caseConstant,
850constantValue = ConstantValue.Bad;
915ConstantValue matchPossible = ExpressionOfTypeMatchesPatternType(
928private DiagnosticInfo? PatternTypeMatchErrorInfo(TypeSymbol inputType, TypeSymbol patternType, ConstantValue matchPossible, Conversion conversion)
930if (matchPossible != ConstantValue.False && matchPossible != ConstantValue.Bad)
963ConstantValue matchPossible = ExpressionOfTypeMatchesPatternType(
973if (PatternTypeMatchErrorInfo(unionType, patternType, matchPossible: ConstantValue.Bad, conversion: Conversion.NoConversion) is { } errorInfo)
985/// - <see cref="ConstantValue.True"/> if the matched type catches all of them
986/// - <see cref="ConstantValue.False"/> if it catches none of them
987/// - <see cref="ConstantValue.Bad"/> - compiler doesn't support the type check, i.e. cannot perform it, even at runtime
990internal static ConstantValue ExpressionOfTypeMatchesPatternType(
996ConstantValue? operandConstantValue = null,
1006return ConstantValue.True;
1016ConstantValue result = Binder.GetIsOperatorConstantResult(expressionType, patternType, conversion.Kind, operandConstantValue, ref useSiteInfo, operandCouldBeNull);
1019Debug.Assert((!conversion.IsUserDefined && !conversion.IsUnion) || result == ConstantValue.False || result == ConstantValue.Bad);
2056BoundExpression value = BindExpressionForPattern(unionType, inputType, node.Expression, ref hasErrors, diagnostics, out var constantValueOpt, out _, out Conversion patternConversion, originalExpression: out _);
2092constantValueOpt = ConstantValue.Bad;
Binder\Binder_Statements.cs (9)
2279Conversion conversion, TypeSymbol sourceType, TypeSymbol targetType, ConstantValue sourceConstantValueOpt = null)
2296else if (conversion.Kind == ConversionKind.ExplicitNumeric && sourceConstantValueOpt != null && sourceConstantValueOpt != ConstantValue.Bad &&
2297ConversionsBase.HasImplicitConstantExpressionConversion(new BoundLiteral(syntax, ConstantValue.Bad, sourceType), targetType))
2694return BoundConversion.Synthesized(node, BindToTypeForErrorRecovery(expr), Conversion.NoConversion, false, explicitCastInCode: false, conversionGroupOpt: null, InConversionGroupFlags.Unspecified, ConstantValue.NotAvailable, boolean, hasErrors: true);
2706ConstantValue.NotAvailable,
2762return BoundConversion.Synthesized(node, expr, Conversion.NoConversion, false, explicitCastInCode: false, conversionGroupOpt: null, InConversionGroupFlags.Unspecified, ConstantValue.NotAvailable, boolean, hasErrors: true);
2782return new BoundUnaryOperator(node, signature.Kind, resultOperand, ConstantValue.NotAvailable, signature.Method, signature.ConstrainedToTypeOpt, resultKind, originalUserDefinedOperators, signature.ReturnType)
3434exceptionSource = new BoundLocal(declaration, local, ConstantValue.NotAvailable, local.Type);
3446if (boundFilter.ConstantValueOpt != ConstantValue.NotAvailable)
Binder\DecisionDagBuilder.cs (28)
520tests.Add(new Tests.One(new BoundDagValueTest(syntax, ConstantValue.Create(patternLength), lengthTemp)));
760Tests test = MakeConstantTest(syntax, temp, sense ? ConstantValue.True : ConstantValue.False);
805Tests test = MakeConstantTest(syntax, boolResult, ConstantValue.True);
871if (constant.ConstantValue == ConstantValue.Null)
892ConstantValue constantValue = constant.ConstantValue;
918private static Tests MakeConstantTest(SyntaxNode syntax, BoundDagTemp input, ConstantValue constantValue)
1790resultForRelation(BinaryOperatorKind relation, ConstantValue value)
2066ConstantValue value,
2135ConstantValue? matches = ExpressionOfTypeMatchesPatternTypeForLearningFromSuccessfulTypeTest(_conversions, t1Type, t2Type, ref useSiteInfo);
2136if (matches == ConstantValue.False)
2142else if (matches == ConstantValue.True)
2152if (matches == ConstantValue.True)
2377Debug.Assert((hasValueTest.Value == ConstantValue.True || hasValueTest.Value == ConstantValue.False));
2378if (hasValueTest.Value == ConstantValue.True || hasValueTest.Value == ConstantValue.False)
2380sense = hasValueTest.Value == ConstantValue.True;
2395bool isTrue = tryGetValueTest.Value == ConstantValue.True;
2702internal static ConstantValue? ExpressionOfTypeMatchesPatternTypeForLearningFromSuccessfulTypeTest(
2708ConstantValue result = Binder.ExpressionOfTypeMatchesPatternType(conversions, expressionType, patternType, ref useSiteInfo, out Conversion conversion);
3192public bool IsFullyMatched => RemainingTests is Tests.True && (WhenClause is null || WhenClause.ConstantValueOpt == ConstantValue.True);
3551static Tests? knownResult(BinaryOperatorKind relation, ConstantValue constant, int offset)
3563static ConstantValue safeAdd(ConstantValue constant, int offset)
3570return ConstantValue.Create(offset > (int.MaxValue - value) ? int.MaxValue : value + offset);
3913condition = new Tests.One(new BoundDagValueTest(s2.Syntax, ConstantValue.Create(lengthValue), s1LengthTemp));
4150ConstantValue? sample = Values.Sample;
BoundTree\BoundObjectCreationExpression.cs (3)
13ImmutableArray<RefKind> argumentRefKindsOpt, bool expanded, ImmutableArray<int> argsToParamsOpt, BitVector defaultArguments, ConstantValue? constantValueOpt,
19ImmutableArray<int> argsToParamsOpt, BitVector defaultArguments, ConstantValue? constantValueOpt, BoundObjectInitializerExpressionBase? initializerExpressionOpt, TypeSymbol type)
26BitVector defaultArguments, ConstantValue? constantValueOpt, BoundObjectInitializerExpressionBase? initializerExpressionOpt, TypeSymbol type)
BoundTree\Constructors.cs (12)
18ConstantValue? constantValueOpt,
28ConstantValue? constantValueOpt,
40ConstantValue? constantValueOpt,
52ConstantValue? constantValueOpt,
335public static BoundConversion SynthesizedNonUserDefined(SyntaxNode syntax, BoundExpression operand, Conversion conversion, TypeSymbol type, ConstantValue? constantValueOpt = null)
364ConstantValue? constantValueOpt,
392ConstantValue? constantValueOpt,
417ConstantValue? constantValueOpt,
438ConstantValue? constantValueOpt,
451ConstantValue? constantValueOpt,
687ConstantValue? constantValueOpt,
699ConstantValue? constantValueOpt,
CodeGen\EmitStatement.cs (13)
1270dispatch.Cases.Select(p => new KeyValuePair<ConstantValue, object>(p.value, p.label)).ToArray(),
1277KeyValuePair<ConstantValue, object>[] switchCaseLabels,
1437lengthBasedSwitchInfo.LengthBasedJumpTable.LengthCaseLabels.Select(p => new KeyValuePair<ConstantValue, object>(ConstantValue.Create(p.value), p.label)).ToArray(),
1477charJumpTable.CharCaseLabels.Select(p => new KeyValuePair<ConstantValue, object>(ConstantValue.Create(p.value), p.label)).ToArray(),
1497stringJumpTable.StringCaseLabels.Select(p => new KeyValuePair<ConstantValue, object>(ConstantValue.Create(p.value), p.label)).ToArray(),
1513KeyValuePair<ConstantValue, object>[] switchCaseLabels,
1591if (stringConstant == ConstantValue.Null)
1717private void EmitStringCompareAndBranch(LocalOrParameter key, SyntaxNode syntaxNode, ConstantValue stringConstant, object targetLabel, Microsoft.Cci.IReference stringEqualityMethodRef)
1755private void EmitCharCompareAndBranch(LocalOrParameter key, SyntaxNode syntaxNode, ConstantValue stringConstant, object targetLabel, Cci.IReference sequenceEqualsRef, Cci.IReference asSpanRef)
2014var casesBuilder = ArrayBuilder<(ConstantValue, LabelSymbol)>.GetInstance();
Compiler\MethodBodySynthesizer.cs (8)
106ImmutableArray.Create<BoundExpression>(new BoundLiteral(syntax, ConstantValue.Create(slotIndex), intType) { WasCompilerGenerated = true }),
122new BoundFieldAccess(syntax, thisReference, hostObjectField, ConstantValue.NotAvailable) { WasCompilerGenerated = true },
126ImmutableArray.Create<BoundExpression>(new BoundLiteral(syntax, ConstantValue.Create(0), intType) { WasCompilerGenerated = true }),
133ConstantValue.NotAvailable,
151new BoundFieldAccess(syntax, thisReference, field, ConstantValue.NotAvailable) { WasCompilerGenerated = true },
155ImmutableArray.Create<BoundExpression>(new BoundLiteral(syntax, ConstantValue.Create(targetSubmissionIndex), intType) { WasCompilerGenerated = true }),
163ConstantValue.NotAvailable,
190var fieldAccess = new BoundFieldAccess(syntax, thisReference, field, ConstantValue.NotAvailable) { WasCompilerGenerated = true };
Generated\BoundNodes.xml.Generated.cs (56)
1204public BoundUnaryOperator(SyntaxNode syntax, UnaryOperatorKind operatorKind, BoundExpression operand, ConstantValue? constantValueOpt, MethodSymbol? methodOpt, TypeSymbol? constrainedToTypeOpt, LookupResultKind resultKind, ImmutableArray<MethodSymbol> originalUserDefinedOperatorsOpt, TypeSymbol type, bool hasErrors = false)
1223public override ConstantValue? ConstantValueOpt { get; }
1232public BoundUnaryOperator Update(UnaryOperatorKind operatorKind, BoundExpression operand, ConstantValue? constantValueOpt, MethodSymbol? methodOpt, TypeSymbol? constrainedToTypeOpt, LookupResultKind resultKind, ImmutableArray<MethodSymbol> originalUserDefinedOperatorsOpt, TypeSymbol type)
1999public BoundUnconvertedConditionalOperator(SyntaxNode syntax, BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue? constantValueOpt, ErrorCode noCommonTypeError, bool hasErrors = false)
2018public override ConstantValue? ConstantValueOpt { get; }
2024public BoundUnconvertedConditionalOperator Update(BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue? constantValueOpt, ErrorCode noCommonTypeError)
2038public BoundConditionalOperator(SyntaxNode syntax, bool isRef, BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue? constantValueOpt, TypeSymbol? naturalTypeOpt, bool wasTargetTyped, TypeSymbol type, bool hasErrors = false)
2061public override ConstantValue? ConstantValueOpt { get; }
2068public BoundConditionalOperator Update(bool isRef, BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue? constantValueOpt, TypeSymbol? naturalTypeOpt, bool wasTargetTyped, TypeSymbol type)
2863public BoundDefaultExpression(SyntaxNode syntax, BoundTypeExpression? targetType, ConstantValue? constantValueOpt, TypeSymbol type, bool hasErrors = false)
2875public override ConstantValue? ConstantValueOpt { get; }
2880public BoundDefaultExpression Update(BoundTypeExpression? targetType, ConstantValue? constantValueOpt, TypeSymbol type)
2966public BoundSizeOfOperator(SyntaxNode syntax, BoundTypeExpression sourceType, ConstantValue? constantValueOpt, TypeSymbol type, bool hasErrors = false)
2979public override ConstantValue? ConstantValueOpt { get; }
2984public BoundSizeOfOperator Update(BoundTypeExpression sourceType, ConstantValue? constantValueOpt, TypeSymbol type)
2998public BoundConversion(SyntaxNode syntax, BoundExpression operand, Conversion conversion, bool isBaseConversion, bool @checked, bool explicitCastInCode, ConstantValue? constantValueOpt, ConversionGroup? conversionGroupOpt, InConversionGroupFlags inConversionGroupFlags, TypeSymbol type, bool hasErrors = false)
3025public override ConstantValue? ConstantValueOpt { get; }
3032public BoundConversion Update(BoundExpression operand, Conversion conversion, bool isBaseConversion, bool @checked, bool explicitCastInCode, ConstantValue? constantValueOpt, ConversionGroup? conversionGroupOpt, InConversionGroupFlags inConversionGroupFlags, TypeSymbol type)
3856public BoundSwitchDispatch(SyntaxNode syntax, BoundExpression expression, ImmutableArray<(ConstantValue value, LabelSymbol label)> cases, LabelSymbol defaultLabel, LengthBasedStringSwitchData? lengthBasedStringSwitchDataOpt, bool hasErrors = false)
3871public ImmutableArray<(ConstantValue value, LabelSymbol label)> Cases { get; }
3878public BoundSwitchDispatch Update(BoundExpression expression, ImmutableArray<(ConstantValue value, LabelSymbol label)> cases, LabelSymbol defaultLabel, LengthBasedStringSwitchData? lengthBasedStringSwitchDataOpt)
4339public BoundLiteral(SyntaxNode syntax, ConstantValue? constantValueOpt, TypeSymbol? type, bool hasErrors)
4345public BoundLiteral(SyntaxNode syntax, ConstantValue? constantValueOpt, TypeSymbol? type)
4351public override ConstantValue? ConstantValueOpt { get; }
4356public BoundLiteral Update(ConstantValue? constantValueOpt, TypeSymbol? type)
4544public BoundLocal(SyntaxNode syntax, LocalSymbol localSymbol, BoundLocalDeclarationKind declarationKind, ConstantValue? constantValueOpt, bool isNullableUnknown, TypeSymbol type, bool hasErrors)
4557public BoundLocal(SyntaxNode syntax, LocalSymbol localSymbol, BoundLocalDeclarationKind declarationKind, ConstantValue? constantValueOpt, bool isNullableUnknown, TypeSymbol type)
4573public override ConstantValue? ConstantValueOpt { get; }
4579public BoundLocal Update(LocalSymbol localSymbol, BoundLocalDeclarationKind declarationKind, ConstantValue? constantValueOpt, bool isNullableUnknown, TypeSymbol type)
5355public BoundDagValueTest(SyntaxNode syntax, ConstantValue value, BoundDagTemp input, bool hasErrors = false)
5365public ConstantValue Value { get; }
5370public BoundDagValueTest Update(ConstantValue value, BoundDagTemp input)
5384public BoundDagRelationalTest(SyntaxNode syntax, BinaryOperatorKind operatorKind, ConstantValue value, BoundDagTemp input, bool hasErrors = false)
5396public ConstantValue Value { get; }
5401public BoundDagRelationalTest Update(BinaryOperatorKind operatorKind, ConstantValue value, BoundDagTemp input)
6416public BoundObjectCreationExpression(SyntaxNode syntax, MethodSymbol constructor, ImmutableArray<MethodSymbol> constructorsGroup, ImmutableArray<BoundExpression> arguments, ImmutableArray<string?> argumentNamesOpt, ImmutableArray<RefKind> argumentRefKindsOpt, bool expanded, ImmutableArray<int> argsToParamsOpt, BitVector defaultArguments, ConstantValue? constantValueOpt, BoundObjectInitializerExpressionBase? initializerExpressionOpt, bool wasTargetTyped, TypeSymbol type, bool hasErrors = false)
6446public override ConstantValue? ConstantValueOpt { get; }
6453public BoundObjectCreationExpression Update(MethodSymbol constructor, ImmutableArray<MethodSymbol> constructorsGroup, ImmutableArray<BoundExpression> arguments, ImmutableArray<string?> argumentNamesOpt, ImmutableArray<RefKind> argumentRefKindsOpt, bool expanded, ImmutableArray<int> argsToParamsOpt, BitVector defaultArguments, ConstantValue? constantValueOpt, BoundObjectInitializerExpressionBase? initializerExpressionOpt, bool wasTargetTyped, TypeSymbol type)
7374public BoundFieldAccess(SyntaxNode syntax, BoundExpression? receiverOpt, FieldSymbol fieldSymbol, ConstantValue? constantValueOpt, LookupResultKind resultKind, bool isByValue, bool isDeclaration, TypeSymbol type, bool hasErrors = false)
7392public override ConstantValue? ConstantValueOpt { get; }
7400public BoundFieldAccess Update(BoundExpression? receiverOpt, FieldSymbol fieldSymbol, ConstantValue? constantValueOpt, LookupResultKind resultKind, bool isByValue, bool isDeclaration, TypeSymbol type)
7860public BoundNameOfOperator(SyntaxNode syntax, BoundExpression argument, ConstantValue constantValueOpt, TypeSymbol type, bool hasErrors = false)
7878public override ConstantValue ConstantValueOpt { get; }
7883public BoundNameOfOperator Update(BoundExpression argument, ConstantValue constantValueOpt, TypeSymbol type)
7897protected BoundInterpolatedStringBase(BoundKind kind, SyntaxNode syntax, ImmutableArray<BoundExpression> parts, ConstantValue? constantValueOpt, TypeSymbol? type, bool hasErrors = false)
7908public override ConstantValue? ConstantValueOpt { get; }
7913public BoundUnconvertedInterpolatedString(SyntaxNode syntax, ImmutableArray<BoundExpression> parts, ConstantValue? constantValueOpt, TypeSymbol? type, bool hasErrors = false)
7925public BoundUnconvertedInterpolatedString Update(ImmutableArray<BoundExpression> parts, ConstantValue? constantValueOpt, TypeSymbol? type)
7939public BoundInterpolatedString(SyntaxNode syntax, InterpolatedStringHandlerData? interpolationData, ImmutableArray<BoundExpression> parts, ConstantValue? constantValueOpt, TypeSymbol? type, bool hasErrors = false)
7953public BoundInterpolatedString Update(InterpolatedStringHandlerData? interpolationData, ImmutableArray<BoundExpression> parts, ConstantValue? constantValueOpt, TypeSymbol? type)
8144public BoundConstantPattern(SyntaxNode syntax, BoundExpression value, ConstantValue constantValue, UnionMatchingMode unionMatchingMode, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
8163public ConstantValue ConstantValue { get; }
8169public BoundConstantPattern Update(BoundExpression value, ConstantValue constantValue, UnionMatchingMode unionMatchingMode, TypeSymbol inputType, TypeSymbol narrowedType)
8709public BoundRelationalPattern(SyntaxNode syntax, BinaryOperatorKind relation, BoundExpression value, ConstantValue constantValue, UnionMatchingMode unionMatchingMode, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
8730public ConstantValue ConstantValue { get; }
8736public BoundRelationalPattern Update(BinaryOperatorKind relation, BoundExpression value, ConstantValue constantValue, UnionMatchingMode unionMatchingMode, TypeSymbol inputType, TypeSymbol narrowedType)
Lowering\LocalRewriter\LocalRewriter_BinaryOperator.cs (49)
287if (loweredRight.ConstantValueOpt == ConstantValue.True) return loweredLeft;
288if (loweredLeft.ConstantValueOpt == ConstantValue.True) return loweredRight;
289if (loweredLeft.ConstantValueOpt == ConstantValue.False) return loweredLeft;
299if (loweredRight.ConstantValueOpt == ConstantValue.False) return loweredLeft;
300if (loweredLeft.ConstantValueOpt == ConstantValue.False) return loweredRight;
301if (loweredLeft.ConstantValueOpt == ConstantValue.True) return loweredLeft;
311if (loweredRight.ConstantValueOpt == ConstantValue.True) return loweredLeft;
312if (loweredLeft.ConstantValueOpt == ConstantValue.True) return loweredRight;
332if (loweredRight.ConstantValueOpt == ConstantValue.False) return loweredLeft;
333if (loweredLeft.ConstantValueOpt == ConstantValue.False) return loweredRight;
337if (loweredLeft.ConstantValueOpt == ConstantValue.True) return loweredRight;
338if (loweredRight.ConstantValueOpt == ConstantValue.True) return loweredLeft;
342if (loweredLeft.ConstantValueOpt == ConstantValue.False)
345if (loweredRight.ConstantValueOpt == ConstantValue.False)
351if (loweredLeft.ConstantValueOpt == ConstantValue.False) return loweredRight;
352if (loweredRight.ConstantValueOpt == ConstantValue.False) return loweredLeft;
356if (loweredLeft.ConstantValueOpt == ConstantValue.True)
359if (loweredRight.ConstantValueOpt == ConstantValue.True)
365if (loweredLeft.ConstantValueOpt == ConstantValue.False) return loweredRight;
366if (loweredRight.ConstantValueOpt == ConstantValue.False) return loweredLeft;
370if (loweredLeft.ConstantValueOpt == ConstantValue.True)
373if (loweredRight.ConstantValueOpt == ConstantValue.True)
633ConstantValue? constantLeft = loweredLeft.ConstantValueOpt ?? UnboxConstant(loweredLeft);
634if (testOperator == UnaryOperatorKind.DynamicFalse && constantLeft == ConstantValue.False ||
635testOperator == UnaryOperatorKind.DynamicTrue && constantLeft == ConstantValue.True)
677bool leftTestIsConstantFalse = testOperator == UnaryOperatorKind.DynamicFalse && constantLeft == ConstantValue.True ||
678testOperator == UnaryOperatorKind.DynamicTrue && constantLeft == ConstantValue.False;
719private static ConstantValue? UnboxConstant(BoundExpression expression)
757return new BoundUnaryOperator(syntax, UnaryOperatorKind.BoolLogicalNegation, converted, ConstantValue.NotAvailable, MethodSymbol.None, constrainedToTypeOpt: null, LookupResultKind.Viable, boolean)
835return MakeLiteral(syntax, ConstantValue.Create(kind.Operator() == BinaryOperatorKind.Equal), boolType);
862BoundExpression result = MakeLiteral(syntax, ConstantValue.Create(operatorKind == BinaryOperatorKind.NotEqual), boolType);
927return MakeLiteral(syntax, ConstantValue.Create(value), _compilation.GetSpecialType(SpecialType.System_Boolean));
1123[NotNullWhen(returnValue: true)] ConstantValue? constantValue)
1280rewrittenAlternative: MakeLiteral(syntax, ConstantValue.Create(operatorKind == BinaryOperatorKind.Equal), boolType),
1648ConstantValue.NotAvailable,
1970return MakeLiteral(syntax, ConstantValue.Create(kind == BinaryOperatorKind.NullableNullEqual), returnType);
2009new BoundUnaryOperator(syntax, UnaryOperatorKind.BoolLogicalNegation, call, ConstantValue.NotAvailable, null, constrainedToTypeOpt: null, LookupResultKind.Viable, returnType);
2016if (oldNode != null && (loweredLeft.ConstantValueOpt == ConstantValue.Null || loweredRight.ConstantValueOpt == ConstantValue.Null))
2110return MakeLiteral(syntax, ConstantValue.Create(rewrittenExpr.ConstantValueOpt.IsNull, ConstantValueTypeDiscriminator.Boolean), boolType);
2112return MakeLiteral(syntax, ConstantValue.Create(!rewrittenExpr.ConstantValueOpt.IsNull, ConstantValueTypeDiscriminator.Boolean), boolType);
2135MakeLiteral(syntax, ConstantValue.Null, objectType),
2155ConstantValue? rightConstantValue = loweredRight.ConstantValueOpt;
2168loweredRight = MakeLiteral(rightSyntax, ConstantValue.Create(shiftAmount), rightType);
2181MakeLiteral(rightSyntax, ConstantValue.Create(rightMask), rightType),
2227ConstantValue? rightConstantValue = loweredRight.ConstantValueOpt;
2301ConstantValue.NotAvailable,
2359var constVal = numericOperand.ConstantValueOpt;
2370var constVal = numericOperand.ConstantValueOpt;
Lowering\LocalRewriter\LocalRewriter_Conversion.cs (9)
267ConstantValue? constantValueOpt,
303ConstantValue? constantValueOpt,
862ConstantValue? constantValueOpt = null)
1395MakeConversionNode(null, syntax, conditional.Consequence, conversion, @checked, explicitCastInCode: false, constantValueOpt: ConstantValue.NotAvailable, rewrittenType: type),
1396MakeConversionNode(null, syntax, conditional.Alternative, conversion, @checked, explicitCastInCode: false, constantValueOpt: ConstantValue.NotAvailable, rewrittenType: type),
1397ConstantValue.NotAvailable,
1599ConstantValue? constantValueOpt,
1809private BoundExpression RewriteDecimalConversion(SyntaxNode syntax, BoundExpression operand, TypeSymbol fromType, TypeSymbol toType, bool @checked, bool isImplicit, ConstantValue? constantValueOpt)
1840private BoundExpression RewriteDecimalConversionCore(SyntaxNode syntax, BoundExpression operand, TypeSymbol fromType, TypeSymbol toType, bool isImplicit, ConstantValue? constantValueOpt)
Lowering\LocalRewriter\LocalRewriter_ForEachStatement.cs (6)
464right: MakeLiteral(forEachSyntax, constantValue: ConstantValue.Null, type: null),
645MakeLiteral(forEachSyntax, ConstantValue.Default(SpecialType.System_Int32), intType));
934MakeLiteral(forEachSyntax, ConstantValue.Default(SpecialType.System_Int32), intType));
1097constantValue: ConstantValue.Create(dimension, ConstantValueTypeDiscriminator.Int32),
1151constantValue: ConstantValue.Create(dimension, ConstantValueTypeDiscriminator.Int32),
1264constantValue: ConstantValue.Create(1),
Lowering\LocalRewriter\LocalRewriter_IsOperator.cs (6)
40return RewriteConstantIsOperator(receiver.Syntax, receiver, ConstantValue.False, rewrittenType);
44return MakeLiteral(syntax, ConstantValue.False, rewrittenType);
59ConstantValue constantValue = Binder.GetIsOperatorConstantResult(operandType, targetType, conversionKind, rewrittenOperand.ConstantValueOpt, ref useSiteInfo);
85ConstantValue constantValue,
88Debug.Assert(constantValue == ConstantValue.True || constantValue == ConstantValue.False);
Lowering\LocalRewriter\LocalRewriter_Literal.cs (14)
23private BoundExpression MakeLiteral(SyntaxNode syntax, ConstantValue constantValue, TypeSymbol? type, BoundLiteral? oldNodeOpt = null)
51private BoundExpression MakeDecimalLiteral(SyntaxNode syntax, ConstantValue constantValue)
100arguments.Add(new BoundLiteral(syntax, ConstantValue.Create((int)value), _compilation.GetSpecialType(SpecialType.System_Int32)));
106arguments.Add(new BoundLiteral(syntax, ConstantValue.Create((uint)value), _compilation.GetSpecialType(SpecialType.System_UInt32)));
112arguments.Add(new BoundLiteral(syntax, ConstantValue.Create((long)value), _compilation.GetSpecialType(SpecialType.System_Int64)));
118arguments.Add(new BoundLiteral(syntax, ConstantValue.Create((ulong)value), _compilation.GetSpecialType(SpecialType.System_UInt64)));
124arguments.Add(new BoundLiteral(syntax, ConstantValue.Create(low), _compilation.GetSpecialType(SpecialType.System_Int32)));
125arguments.Add(new BoundLiteral(syntax, ConstantValue.Create(mid), _compilation.GetSpecialType(SpecialType.System_Int32)));
126arguments.Add(new BoundLiteral(syntax, ConstantValue.Create(high), _compilation.GetSpecialType(SpecialType.System_Int32)));
127arguments.Add(new BoundLiteral(syntax, ConstantValue.Create(isNegative), _compilation.GetSpecialType(SpecialType.System_Boolean)));
128arguments.Add(new BoundLiteral(syntax, ConstantValue.Create(scale), _compilation.GetSpecialType(SpecialType.System_Byte)));
142private BoundExpression MakeDateTimeLiteral(SyntaxNode syntax, ConstantValue constantValue)
148arguments.Add(new BoundLiteral(syntax, ConstantValue.Create(constantValue.DateTimeValue.Ticks), _compilation.GetSpecialType(SpecialType.System_Int64)));
159constantValueOpt: ConstantValue.NotAvailable, initializerExpressionOpt: null, type: ctor.ContainingType);
Lowering\LocalRewriter\LocalRewriter_UnaryOperator.cs (17)
90var constant = UnboxConstant(loweredOperand);
91if (constant == ConstantValue.True || constant == ConstantValue.False)
343ConstantValue.NotAvailable,
900(TypeSymbol binaryOperandType, ConstantValue constantOne) = GetConstantOneForIncrement(_compilation, binaryOperatorKind);
1013return RewriteConditionalOperator(syntax, condition, consequence, alternative, ConstantValue.NotAvailable, operand.Type, isRef: false);
1245private static (TypeSymbol, ConstantValue) GetConstantOneForIncrement(
1249ConstantValue constantOne;
1254constantOne = ConstantValue.Create(1);
1257constantOne = ConstantValue.Create(1U);
1260constantOne = ConstantValue.Create(1L);
1263constantOne = ConstantValue.Create(1LU);
1266constantOne = ConstantValue.Create(1);
1269constantOne = ConstantValue.Create(1U);
1272constantOne = ConstantValue.Create(1f);
1275constantOne = ConstantValue.Create(1.0);
1278constantOne = ConstantValue.Create(1m);
Lowering\LocalRewriter\LocalRewriter.DecisionDagRewriter.cs (20)
589var cases = ArrayBuilder<(ConstantValue value, LabelSymbol label)>.GetInstance();
620ImmutableArray<(ConstantValue value, LabelSymbol label)> cases,
643(ImmutableArray<(ConstantValue value, LabelSymbol label)> whenTrueCases, ImmutableArray<(ConstantValue value, LabelSymbol label)> whenFalseCases)
644splitCases(ImmutableArray<(ConstantValue value, LabelSymbol label)> cases, BinaryOperatorKind op, ConstantValue value)
646var whenTrueBuilder = ArrayBuilder<(ConstantValue value, LabelSymbol label)>.GetInstance();
647var whenFalseBuilder = ArrayBuilder<(ConstantValue value, LabelSymbol label)>.GetInstance();
704private sealed class CasesComparer : IComparer<(ConstantValue value, LabelSymbol label)>
713int IComparer<(ConstantValue value, LabelSymbol label)>.Compare((ConstantValue value, LabelSymbol label) left, (ConstantValue value, LabelSymbol label) right)
715var x = left.value;
716var y = right.value;
736static bool isNaN(ConstantValue value) =>
787ImmutableArray<(ConstantValue value, LabelSymbol label)> cases;
797cases = node.Cases.SelectAsArray(p => (ConstantValue.Create((long)p.value.Int32Value), p.label));
807cases = node.Cases.SelectAsArray(p => (ConstantValue.Create((ulong)p.value.UInt32Value), p.label));
1017if (whenExpression is not null && whenExpression.ConstantValueOpt != ConstantValue.True)
1169if (whenClause.WhenExpression != null && whenClause.WhenExpression.ConstantValueOpt != ConstantValue.True)
Lowering\LocalRewriter\LocalRewriter.DecisionDagRewriter.ValueDispatchNode.cs (6)
38public readonly ImmutableArray<(ConstantValue value, LabelSymbol label)> Cases;
40public SwitchDispatch(SyntaxNode syntax, ImmutableArray<(ConstantValue value, LabelSymbol label)> dispatches, LabelSymbol otherwise) : base(syntax)
80public readonly ConstantValue Value;
86private RelationalDispatch(SyntaxNode syntax, ConstantValue value, BinaryOperatorKind op, ValueDispatchNode left, ValueDispatchNode right) : base(syntax)
133public static ValueDispatchNode CreateBalanced(SyntaxNode syntax, ConstantValue value, BinaryOperatorKind op, ValueDispatchNode whenTrue, ValueDispatchNode whenFalse)
140private static ValueDispatchNode CreateBalancedCore(SyntaxNode syntax, ConstantValue value, BinaryOperatorKind op, ValueDispatchNode left, ValueDispatchNode right)
Lowering\LocalRewriter\LocalRewriter.PatternLocalRewriter.cs (4)
408_factory.Convert(operandType, new BoundLiteral(syntax, ConstantValue.Null, objectType), Conversion.NullToPointer),
416protected BoundExpression MakeValueTest(SyntaxNode syntax, BoundExpression input, ConstantValue value)
430protected BoundExpression MakeRelationalTest(SyntaxNode syntax, BoundExpression input, BinaryOperatorKind operatorKind, ConstantValue value)
466private BoundExpression MakeSpanStringTest(BoundExpression input, ConstantValue value)
Lowering\SyntheticBoundNodeFactory.cs (21)
256return new BoundFieldAccess(Syntax, receiver, f, ConstantValue.NotAvailable, LookupResultKind.Viable, f.Type) { WasCompilerGenerated = true };
581expression = BoundConversion.Synthesized(Syntax, expression, conversion, false, explicitCastInCode: false, conversionGroupOpt: null, InConversionGroupFlags.Unspecified, ConstantValue.NotAvailable, CurrentFunction.ReturnType);
650return new BoundBinaryOperator(this.Syntax, kind, ConstantValue.NotAvailable, methodOpt: null, constrainedToTypeOpt: null, LookupResultKind.Viable, left, right, type) { WasCompilerGenerated = true };
744return new BoundLiteral(Syntax, ConstantValue.Create(value), SpecialType(Microsoft.CodeAnalysis.SpecialType.System_Byte)) { WasCompilerGenerated = true };
749return new BoundLiteral(Syntax, ConstantValue.Create(value), SpecialType(Microsoft.CodeAnalysis.SpecialType.System_Int32)) { WasCompilerGenerated = true };
757return new BoundLiteral(Syntax, ConstantValue.Create(value), SpecialType(Microsoft.CodeAnalysis.SpecialType.System_UInt32)) { WasCompilerGenerated = true };
760public BoundLiteral Literal(ConstantValue value, TypeSymbol type)
1115var caseBuilder = ArrayBuilder<(ConstantValue Value, LabelSymbol label)>.GetInstance();
1126caseBuilder.Add((ConstantValue.Create(value), sectionLabel));
1166return new BoundLiteral(Syntax, ConstantValue.Create(value), SpecialType(Microsoft.CodeAnalysis.SpecialType.System_Boolean)) { WasCompilerGenerated = true };
1171var stringConst = ConstantValue.Create(value);
1175public BoundLiteral StringLiteral(ConstantValue stringConst)
1183return StringLiteral(ConstantValue.Create(stringValue));
1186public BoundLiteral CharLiteral(ConstantValue charConst)
1194return CharLiteral(ConstantValue.Create(charValue));
1271BoundExpression nullLiteral = new BoundLiteral(syntax, ConstantValue.Null, type) { WasCompilerGenerated = true };
1782return Literal(ConstantValue.Create(rewrittenExpr.ConstantValueOpt.IsNull, ConstantValueTypeDiscriminator.Boolean), boolType);
1784return Literal(ConstantValue.Create(rewrittenExpr.ConstantValueOpt.IsNull, ConstantValueTypeDiscriminator.Boolean), boolType);
1804return RewriteNullableNullEquality(syntax, operatorKind, rewrittenExpr, Literal(ConstantValue.Null, objectType), boolType);
1889new BoundUnaryOperator(syntax, UnaryOperatorKind.BoolLogicalNegation, call, ConstantValue.NotAvailable, methodOpt: null, constrainedToTypeOpt: null, LookupResultKind.Viable, returnType);
Symbols\Source\SourceComplexParameterSymbol.cs (31)
40protected ConstantValue? _lazyDefaultSyntaxValue;
82_lazyDefaultSyntaxValue = ConstantValue.Unset;
94internal sealed override ConstantValue? ExplicitDefaultConstantValue
112internal sealed override ConstantValue? DefaultValueFromAttributes
117return (data != null && data.DefaultParameterValue != ConstantValue.Unset) ? data.DefaultParameterValue : null;
247private ConstantValue? DefaultSyntaxValue
255var previousValue = Interlocked.CompareExchange(
258ConstantValue.Unset);
259Debug.Assert(previousValue == ConstantValue.Unset);
279DefaultValueFromAttributes == ConstantValue.NotAvailable)
338var defaultValue = DefaultValueFromAttributes;
367private ConstantValue? MakeDefaultExpression(BindingDiagnosticBag diagnostics, out Binder? binder, out BoundParameterEqualsValue? parameterEqualsValue)
394return ConstantValue.Bad;
401return ConstantValue.Bad;
418var value = convertedExpression.ConstantValueOpt ?? ConstantValue.Null;
739ConstantValue value;
742value = ConstantValue.Bad;
751if (paramData.DefaultParameterValue == ConstantValue.Unset)
925var value = DecodeDefaultParameterValueAttribute(description, attribute, syntax, diagnose: true, diagnosticsOpt: diagnostics);
943private void VerifyParamDefaultValueMatchesAttributeIfAny(ConstantValue value, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
948var attrValue = data.DefaultParameterValue;
949if ((attrValue != ConstantValue.Unset) &&
958private ConstantValue DecodeDefaultParameterValueAttribute(AttributeDescription description, CSharpAttributeData attribute, AttributeSyntax node, bool diagnose, BindingDiagnosticBag diagnosticsOpt)
977private ConstantValue DecodeDefaultParameterValueAttribute(CSharpAttributeData attribute, AttributeSyntax node, bool diagnose, BindingDiagnosticBag diagnosticsOpt)
988return ConstantValue.Bad;
1009var constantValueDiscriminator = ConstantValue.GetDiscriminator(specialType);
1026return ConstantValue.Bad;
1036return ConstantValue.Bad;
1047return ConstantValue.Bad;
1055return ConstantValue.Create(arg.ValueInternal, constantValueDiscriminator);
Symbols\Source\SourceFieldSymbol.cs (21)
175private ConstantValue _lazyConstantEarlyDecodingValue = Microsoft.CodeAnalysis.ConstantValue.Unset;
176private ConstantValue _lazyConstantValue = Microsoft.CodeAnalysis.ConstantValue.Unset;
237internal sealed override ConstantValue GetConstantValue(ConstantFieldsInProgress inProgress, bool earlyDecodingWellKnownAttributes)
239var value = this.GetLazyConstantValue(earlyDecodingWellKnownAttributes);
240if (value != Microsoft.CodeAnalysis.ConstantValue.Unset)
251return Microsoft.CodeAnalysis.ConstantValue.Unset;
282var value = this.GetLazyConstantValue(earlyDecodingWellKnownAttributes);
283if (value != Microsoft.CodeAnalysis.ConstantValue.Unset)
302(value != Microsoft.CodeAnalysis.ConstantValue.Unset) &&
324if (this.GetLazyConstantValue(earlyDecodingWellKnownAttributes) != Microsoft.CodeAnalysis.ConstantValue.Unset)
336var value = MakeConstantValue(builder, earlyDecodingWellKnownAttributes, diagnostics);
346private ConstantValue GetLazyConstantValue(bool earlyDecodingWellKnownAttributes)
352ConstantValue value,
357Debug.Assert(value != Microsoft.CodeAnalysis.ConstantValue.Unset);
358Debug.Assert((GetLazyConstantValue(earlyDecodingWellKnownAttributes) == Microsoft.CodeAnalysis.ConstantValue.Unset) ||
363Interlocked.CompareExchange(ref _lazyConstantEarlyDecodingValue, value, Microsoft.CodeAnalysis.ConstantValue.Unset);
367if (Interlocked.CompareExchange(ref _lazyConstantValue, value, Microsoft.CodeAnalysis.ConstantValue.Unset) == Microsoft.CodeAnalysis.ConstantValue.Unset)
381protected abstract ConstantValue MakeConstantValue(HashSet<SourceFieldSymbolWithSyntaxReference> dependencies, bool earlyDecodingWellKnownAttributes, BindingDiagnosticBag diagnostics);