Binder\Binder_Conversions.cs (25)
277ConstantValue? constantValue = this.FoldConstantConversion(syntax, source, conversion, destination, diagnostics);
2393var constantValue = FoldConditionalOperator(condition, trueExpr, falseExpr);
2468constantValueOpt: ConstantValue.NotAvailable,
2558constantValueOpt: ConstantValue.NotAvailable,
2603constantValueOpt: ConstantValue.NotAvailable,
2664constantValueOpt: ConstantValue.NotAvailable, type: delegateType, hasErrors: true)
2716constantValueOpt: ConstantValue.NotAvailable,
2743return new BoundConversion(syntax, group, conversion, @checked: false, explicitCastInCode: isCast, conversionGroup, inConversionGroupFlags, constantValueOpt: ConstantValue.NotAvailable, type: destination, hasErrors: hasErrors) { WasCompilerGenerated = group.WasCompilerGenerated };
2816DefaultValueFromAttributes: ConstantValue.NotAvailable
2852var delegateParamDefault = delegateParameter.HasExplicitDefaultValue ? delegateParameter.ExplicitDefaultConstantValue : null;
3007constantValueOpt: ConstantValue.NotAvailable,
3024constantValueOpt: ConstantValue.NotAvailable,
3588public ConstantValue? FoldConstantConversion(
3623var sourceConstantValue = source.ConstantValueOpt;
3654return ConstantValue.Create(sourceConstantValue.SingleValue);
3656return ConstantValue.Create(sourceConstantValue.DoubleValue);
3690private ConstantValue? FoldConstantNumericConversion(
3692ConstantValue sourceValue,
3723return ConstantValue.Bad;
3731return ConstantValue.Bad;
3747return ConstantValue.Bad;
3760return ConstantValue.Create(DoUncheckedConversion(destinationType, sourceValue), destinationType);
3763private static object DoUncheckedConversion(SpecialType destinationType, ConstantValue value)
4066public static bool CheckConstantBounds(SpecialType destinationType, ConstantValue value, out bool maySucceedAtRuntime)
4143private 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)
1478defaultValue = new BoundFieldAccess(syntax, null, fieldSymbol, ConstantValue.NotAvailable) { WasCompilerGenerated = true };
1674var parameterDefaultValue = parameter.ExplicitDefaultConstantValue;
1681var defaultConstantValue = parameterDefaultValue switch
1684{ IsBad: true } => ConstantValue.Null,
1687Debug.Assert((object?)defaultConstantValue != ConstantValue.Unset);
1695defaultValue = new BoundLiteral(syntax, ConstantValue.Create(line), Compilation.GetSpecialType(SpecialType.System_Int32)) { WasCompilerGenerated = true };
1700defaultValue = new BoundLiteral(syntax, ConstantValue.Create(path), Compilation.GetSpecialType(SpecialType.System_String)) { WasCompilerGenerated = true };
1705defaultValue = new BoundLiteral(syntax, ConstantValue.Create(memberName), Compilation.GetSpecialType(SpecialType.System_String)) { WasCompilerGenerated = true };
1713defaultValue = new BoundLiteral(syntax, ConstantValue.Create(argument.Syntax.ToString()), Compilation.GetSpecialType(SpecialType.System_String)) { WasCompilerGenerated = true };
1715else if (defaultConstantValue == ConstantValue.NotAvailable)
1843BoundExpression arraySize = new BoundLiteral(node, ConstantValue.Create(collectionArgs.Length), int32Type) { WasCompilerGenerated = true };
2433return new BoundNameOfOperator(node, boundArgument, ConstantValue.Create(name), Compilation.GetSpecialType(SpecialType.System_String));
Binder\Binder_Operators.cs (113)
850constantValueOpt: ConstantValue.NotAvailable,
951return new BoundBinaryOperator(node, kind, ConstantValue.NotAvailable, methodOpt: null, constrainedToTypeOpt: null, LookupResultKind.Empty, left, right, GetBinaryOperatorErrorType(kind, diagnostics, node), true);
975return new BoundLiteral(node, ConstantValue.Create(kind == BinaryOperatorKind.Equal), GetSpecialType(SpecialType.System_Boolean, diagnostics, node));
991var stringConstant = FoldBinaryOperator(node, BinaryOperatorKind.StringConcatenation, left, right, right.Type, diagnostics);
1071ConstantValue resultConstant = null;
1450var constantValue = FoldBinaryOperator(node, kind | BinaryOperatorKind.Bool, left, right, left.Type, diagnostics);
1463return new BoundBinaryOperator(node, kind, ConstantValue.NotAvailable, methodOpt: null, constrainedToTypeOpt: null,
1583ConstantValue.NotAvailable,
1594return new BoundBinaryOperator(node, kind, left, right, ConstantValue.NotAvailable, methodOpt: null, constrainedToTypeOpt: null, lookupResult, originalUserDefinedOperators, CreateErrorType(), true);
2467private static object FoldDecimalBinaryOperators(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
2498private static object FoldNativeIntegerOverflowingBinaryOperator(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
2541private static object FoldUncheckedIntegralBinaryOperator(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
2597private static object FoldCheckedIntegralBinaryOperator(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
2687private ConstantValue? FoldEnumBinaryOperator(
2748var constantValue = FoldBinaryOperator(syntax, newKind, newLeftOperand, newRightOperand, resultTypeSymbol, diagnostics);
2762private ConstantValue? FoldBinaryOperator(
2779ConstantValue? nullableEqualityResult = TryFoldingNullableEquality(kind, left, right);
2785var valueLeft = left.ConstantValueOpt;
2786var valueRight = right.ConstantValueOpt;
2794return ConstantValue.Bad;
2806return ConstantValue.Bad;
2821return ConstantValue.Create(newValue, resultType);
2824ConstantValue? concatResult = FoldStringConcatenation(kind, valueLeft, valueRight);
2845return ConstantValue.Bad;
2850return ConstantValue.Create(newValue, resultType);
2869return ConstantValue.Create(newValue, resultType);
2881return ConstantValue.Bad;
2891return ConstantValue.Create(newValue, resultType);
2919private static ConstantValue? TryFoldingNullableEquality(BinaryOperatorKind kind, BoundExpression left, BoundExpression right)
2930ConstantValue? leftConstant = leftConv.Operand.ConstantValueOpt;
2931ConstantValue? rightConstant = rightConv.Operand.ConstantValueOpt;
2941return (leftIsNull == rightIsNull) == (op == BinaryOperatorKind.Equal) ? ConstantValue.True : ConstantValue.False;
2952private static object? FoldNeverOverflowBinaryOperators(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
3184private static ConstantValue? FoldStringConcatenation(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
3195return (newLength > int.MaxValue) ? ConstantValue.Bad : ConstantValue.CreateFromRope(Rope.Concat(leftValue, rightValue));
4338return new BoundUnaryOperator(node, kind, operand, ConstantValue.NotAvailable,
4359constantValueOpt: ConstantValue.NotAvailable,
4380ConstantValue.NotAvailable,
4395var resultConstant = FoldUnaryOperator(node, resultOperatorKind, resultOperand, resultType, diagnostics);
4411private ConstantValue? FoldEnumUnaryOperator(
4432var constantValue = FoldUnaryOperator(syntax, newKind, operand, upconvertType, diagnostics);
4446private ConstantValue? FoldUnaryOperator(
4461var value = operand.ConstantValueOpt;
4476return ConstantValue.Create(newValue, resultType);
4495return ConstantValue.Create(newValue, resultType);
4507return ConstantValue.Bad;
4517return ConstantValue.Create(newValue, resultType);
4523private static object? FoldNeverOverflowUnaryOperator(UnaryOperatorKind kind, ConstantValue value)
4563private static object? FoldUncheckedIntegralUnaryOperator(UnaryOperatorKind kind, ConstantValue value)
4579private static object? FoldCheckedIntegralUnaryOperator(UnaryOperatorKind kind, ConstantValue value)
4595private 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)
4846var convertedExpression = BindExpressionForPattern(operand.Type, node.Right, ref hasErrors, isPatternDiagnostics, out var constantValueOpt, out var wasExpression, out _);
4853node.Right, convertedExpression, constantValueOpt ?? ConstantValue.Bad, operand.Type, convertedExpression.Type ?? operand.Type, hasErrors)
4892if (operand.ConstantValueOpt == ConstantValue.Null ||
4958ConstantValue operandConstantValue)
4965ConstantValue constantValue = GetIsOperatorConstantResult(operandType, targetType, conversionKind, operandConstantValue);
4974Debug.Assert(constantValue == ConstantValue.True || constantValue == ConstantValue.False);
4976ErrorCode errorCode = constantValue == ConstantValue.True ? ErrorCode.WRN_IsAlwaysTrue : ErrorCode.WRN_IsAlwaysFalse;
4984/// - <see cref="ConstantValue.False"/>
4985/// - <see cref="ConstantValue.True"/>
4986/// - <see cref="ConstantValue.Bad"/> - compiler doesn't support the type check, i.e. cannot perform it, even at runtime
4989internal static ConstantValue GetIsOperatorConstantResult(
4993ConstantValue operandConstantValue,
5032if (operandConstantValue == ConstantValue.Null)
5034return ConstantValue.False;
5042(operandConstantValue == null || operandConstantValue == ConstantValue.Null); // a non-null constant is never null
5107return ConstantValue.False;
5117return ConstantValue.False;
5138return ConstantValue.False;
5146return ConstantValue.False;
5151return ConstantValue.Bad;
5185return ConstantValue.False;
5195return ConstantValue.False;
5211return ConstantValue.False;
5220return operandCouldBeNull ? null : ConstantValue.True;
5226return ConstantValue.False;
5229return operandCouldBeNull ? null : ConstantValue.True;
5244return operandCouldBeNull ? null : ConstantValue.True;
5261return operandCouldBeNull ? null : ConstantValue.True;
5273? ConstantValue.True : ConstantValue.False;
5397operand = new BoundDefaultExpression(operand.Syntax, targetType: null, constantValueOpt: ConstantValue.Null,
5455ConstantValue operandConstantValue)
5517ConstantValue operandConstantValue)
5524ConstantValue constantValue = GetAsOperatorConstantResult(operandType, targetType, conversionKind, operandConstantValue);
5541/// - <see cref="ConstantValue.Null"/>
5542/// - <see cref="ConstantValue.Bad"/> - compiler doesn't support the type check, i.e. cannot perform it, even at runtime
5545internal static ConstantValue GetAsOperatorConstantResult(TypeSymbol operandType, TypeSymbol targetType, ConversionKind conversionKind, ConstantValue operandConstantValue)
5552ConstantValue isOperatorConstantResult = GetIsOperatorConstantResult(operandType, targetType, conversionKind, operandConstantValue);
5564return ConstantValue.Bad;
5567return ConstantValue.Null;
5905ConstantValue? constantValue = null;
6001private static ConstantValue FoldConditionalOperator(BoundExpression condition, BoundExpression trueExpr, BoundExpression falseExpr)
6003ConstantValue trueValue = trueExpr.ConstantValueOpt;
6009ConstantValue falseValue = falseExpr.ConstantValueOpt;
6015ConstantValue conditionValue = condition.ConstantValueOpt;
6020else if (conditionValue == ConstantValue.True)
6024else if (conditionValue == ConstantValue.False)
6030return ConstantValue.Bad;
Binder\Binder_Patterns.cs (26)
436var convertedExpression = BindExpressionOrTypeForPattern(inputType, innerExpression, ref hasErrors, diagnostics, out var constantValueOpt, out bool wasExpression, out Conversion patternConversion);
452node, convertedExpression, constantValueOpt ?? ConstantValue.Bad, inputType, convertedType, hasErrors || constantValueOpt is null);
514out ConstantValue? constantValueOpt,
542out ConstantValue? constantValueOpt,
560out ConstantValue? constantValueOpt,
590if (convertedExpression.Type is null && constantValueOpt != ConstantValue.Null)
603out ConstantValue? constantValue,
619if (expression.ConstantValueOpt == ConstantValue.Null)
632ConstantValue match = ExpressionOfTypeMatchesPatternType(Conversions, inputType, expression.Type, ref useSiteInfo, out _, operandConstantValue: null);
633if (match == ConstantValue.False || match == ConstantValue.Bad)
683if (constantValue == ConstantValue.Null)
777ConstantValue matchPossible = ExpressionOfTypeMatchesPatternType(
780if (matchPossible != ConstantValue.False && matchPossible != ConstantValue.Bad)
809/// - <see cref="ConstantValue.True"/> if the matched type catches all of them
810/// - <see cref="ConstantValue.False"/> if it catches none of them
811/// - <see cref="ConstantValue.Bad"/> - compiler doesn't support the type check, i.e. cannot perform it, even at runtime
814internal static ConstantValue ExpressionOfTypeMatchesPatternType(
820ConstantValue? operandConstantValue = null,
830return ConstantValue.True;
840ConstantValue result = Binder.GetIsOperatorConstantResult(expressionType, patternType, conversion.Kind, operandConstantValue, operandCouldBeNull);
843Debug.Assert(!conversion.IsUserDefined || result == ConstantValue.False || result == ConstantValue.Bad);
1643BoundExpression value = BindExpressionForPattern(inputType, node.Expression, ref hasErrors, diagnostics, out var constantValueOpt, out _, out Conversion patternConversion);
1679constantValueOpt = ConstantValue.Bad;
Binder\Binder_Statements.cs (9)
2278Conversion conversion, TypeSymbol sourceType, TypeSymbol targetType, ConstantValue sourceConstantValueOpt = null)
2295else if (conversion.Kind == ConversionKind.ExplicitNumeric && sourceConstantValueOpt != null && sourceConstantValueOpt != ConstantValue.Bad &&
2296ConversionsBase.HasImplicitConstantExpressionConversion(new BoundLiteral(syntax, ConstantValue.Bad, sourceType), targetType))
2693return BoundConversion.Synthesized(node, BindToTypeForErrorRecovery(expr), Conversion.NoConversion, false, explicitCastInCode: false, conversionGroupOpt: null, InConversionGroupFlags.Unspecified, ConstantValue.NotAvailable, boolean, hasErrors: true);
2705ConstantValue.NotAvailable,
2761return BoundConversion.Synthesized(node, expr, Conversion.NoConversion, false, explicitCastInCode: false, conversionGroupOpt: null, InConversionGroupFlags.Unspecified, ConstantValue.NotAvailable, boolean, hasErrors: true);
2781return new BoundUnaryOperator(node, signature.Kind, resultOperand, ConstantValue.NotAvailable, signature.Method, signature.ConstrainedToTypeOpt, resultKind, originalUserDefinedOperators, signature.ReturnType)
3393exceptionSource = new BoundLocal(declaration, local, ConstantValue.NotAvailable, local.Type);
3405if (boundFilter.ConstantValueOpt != ConstantValue.NotAvailable)
Binder\DecisionDagBuilder.cs (16)
389tests.Add(new Tests.One(new BoundDagValueTest(syntax, ConstantValue.Create(patternLength), lengthTemp)));
533if (constant.ConstantValue == ConstantValue.Null)
1201resultForRelation(BinaryOperatorKind relation, ConstantValue value)
1349ConstantValue? matches = ExpressionOfTypeMatchesPatternTypeForLearningFromSuccessfulTypeTest(t1.Type, t2.Type, ref useSiteInfo);
1350if (matches == ConstantValue.False)
1356else if (matches == ConstantValue.True)
1366if (matches == ConstantValue.True)
1407ConstantValue value,
1546(conditions ??= ArrayBuilder<Tests>.GetInstance()).Add(new Tests.One(new BoundDagValueTest(syntax, ConstantValue.Create(lengthValue), s1LengthTemp)));
1583private ConstantValue? ExpressionOfTypeMatchesPatternTypeForLearningFromSuccessfulTypeTest(
1588ConstantValue result = Binder.ExpressionOfTypeMatchesPatternType(_conversions, expressionType, patternType, ref useSiteInfo, out Conversion conversion);
2056public bool IsFullyMatched => RemainingTests is Tests.True && (WhenClause is null || WhenClause.ConstantValueOpt == ConstantValue.True);
2296static Tests? knownResult(BinaryOperatorKind relation, ConstantValue constant, int offset)
2308static ConstantValue safeAdd(ConstantValue constant, int offset)
2315return ConstantValue.Create(offset > (int.MaxValue - value) ? int.MaxValue : value + offset);
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)
1207public BoundUnaryOperator(SyntaxNode syntax, UnaryOperatorKind operatorKind, BoundExpression operand, ConstantValue? constantValueOpt, MethodSymbol? methodOpt, TypeSymbol? constrainedToTypeOpt, LookupResultKind resultKind, ImmutableArray<MethodSymbol> originalUserDefinedOperatorsOpt, TypeSymbol type, bool hasErrors = false)
1226public override ConstantValue? ConstantValueOpt { get; }
1235public BoundUnaryOperator Update(UnaryOperatorKind operatorKind, BoundExpression operand, ConstantValue? constantValueOpt, MethodSymbol? methodOpt, TypeSymbol? constrainedToTypeOpt, LookupResultKind resultKind, ImmutableArray<MethodSymbol> originalUserDefinedOperatorsOpt, TypeSymbol type)
2002public BoundUnconvertedConditionalOperator(SyntaxNode syntax, BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue? constantValueOpt, ErrorCode noCommonTypeError, bool hasErrors = false)
2021public override ConstantValue? ConstantValueOpt { get; }
2027public BoundUnconvertedConditionalOperator Update(BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue? constantValueOpt, ErrorCode noCommonTypeError)
2041public BoundConditionalOperator(SyntaxNode syntax, bool isRef, BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue? constantValueOpt, TypeSymbol? naturalTypeOpt, bool wasTargetTyped, TypeSymbol type, bool hasErrors = false)
2064public override ConstantValue? ConstantValueOpt { get; }
2071public BoundConditionalOperator Update(bool isRef, BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue? constantValueOpt, TypeSymbol? naturalTypeOpt, bool wasTargetTyped, TypeSymbol type)
2865public BoundDefaultExpression(SyntaxNode syntax, BoundTypeExpression? targetType, ConstantValue? constantValueOpt, TypeSymbol type, bool hasErrors = false)
2877public override ConstantValue? ConstantValueOpt { get; }
2882public BoundDefaultExpression Update(BoundTypeExpression? targetType, ConstantValue? constantValueOpt, TypeSymbol type)
2968public BoundSizeOfOperator(SyntaxNode syntax, BoundTypeExpression sourceType, ConstantValue? constantValueOpt, TypeSymbol type, bool hasErrors = false)
2981public override ConstantValue? ConstantValueOpt { get; }
2986public BoundSizeOfOperator Update(BoundTypeExpression sourceType, ConstantValue? constantValueOpt, TypeSymbol type)
3000public BoundConversion(SyntaxNode syntax, BoundExpression operand, Conversion conversion, bool isBaseConversion, bool @checked, bool explicitCastInCode, ConstantValue? constantValueOpt, ConversionGroup? conversionGroupOpt, InConversionGroupFlags inConversionGroupFlags, TypeSymbol type, bool hasErrors = false)
3027public override ConstantValue? ConstantValueOpt { get; }
3034public BoundConversion Update(BoundExpression operand, Conversion conversion, bool isBaseConversion, bool @checked, bool explicitCastInCode, ConstantValue? constantValueOpt, ConversionGroup? conversionGroupOpt, InConversionGroupFlags inConversionGroupFlags, TypeSymbol type)
3872public BoundSwitchDispatch(SyntaxNode syntax, BoundExpression expression, ImmutableArray<(ConstantValue value, LabelSymbol label)> cases, LabelSymbol defaultLabel, LengthBasedStringSwitchData? lengthBasedStringSwitchDataOpt, bool hasErrors = false)
3887public ImmutableArray<(ConstantValue value, LabelSymbol label)> Cases { get; }
3894public BoundSwitchDispatch Update(BoundExpression expression, ImmutableArray<(ConstantValue value, LabelSymbol label)> cases, LabelSymbol defaultLabel, LengthBasedStringSwitchData? lengthBasedStringSwitchDataOpt)
4355public BoundLiteral(SyntaxNode syntax, ConstantValue? constantValueOpt, TypeSymbol? type, bool hasErrors)
4361public BoundLiteral(SyntaxNode syntax, ConstantValue? constantValueOpt, TypeSymbol? type)
4367public override ConstantValue? ConstantValueOpt { get; }
4372public BoundLiteral Update(ConstantValue? constantValueOpt, TypeSymbol? type)
4560public BoundLocal(SyntaxNode syntax, LocalSymbol localSymbol, BoundLocalDeclarationKind declarationKind, ConstantValue? constantValueOpt, bool isNullableUnknown, TypeSymbol type, bool hasErrors)
4573public BoundLocal(SyntaxNode syntax, LocalSymbol localSymbol, BoundLocalDeclarationKind declarationKind, ConstantValue? constantValueOpt, bool isNullableUnknown, TypeSymbol type)
4589public override ConstantValue? ConstantValueOpt { get; }
4595public BoundLocal Update(LocalSymbol localSymbol, BoundLocalDeclarationKind declarationKind, ConstantValue? constantValueOpt, bool isNullableUnknown, TypeSymbol type)
5367public BoundDagValueTest(SyntaxNode syntax, ConstantValue value, BoundDagTemp input, bool hasErrors = false)
5377public ConstantValue Value { get; }
5382public BoundDagValueTest Update(ConstantValue value, BoundDagTemp input)
5396public BoundDagRelationalTest(SyntaxNode syntax, BinaryOperatorKind operatorKind, ConstantValue value, BoundDagTemp input, bool hasErrors = false)
5408public ConstantValue Value { get; }
5413public BoundDagRelationalTest Update(BinaryOperatorKind operatorKind, ConstantValue value, BoundDagTemp input)
6400public 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)
6430public override ConstantValue? ConstantValueOpt { get; }
6437public 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)
7358public BoundFieldAccess(SyntaxNode syntax, BoundExpression? receiverOpt, FieldSymbol fieldSymbol, ConstantValue? constantValueOpt, LookupResultKind resultKind, bool isByValue, bool isDeclaration, TypeSymbol type, bool hasErrors = false)
7376public override ConstantValue? ConstantValueOpt { get; }
7384public BoundFieldAccess Update(BoundExpression? receiverOpt, FieldSymbol fieldSymbol, ConstantValue? constantValueOpt, LookupResultKind resultKind, bool isByValue, bool isDeclaration, TypeSymbol type)
7844public BoundNameOfOperator(SyntaxNode syntax, BoundExpression argument, ConstantValue constantValueOpt, TypeSymbol type, bool hasErrors = false)
7862public override ConstantValue ConstantValueOpt { get; }
7867public BoundNameOfOperator Update(BoundExpression argument, ConstantValue constantValueOpt, TypeSymbol type)
7881protected BoundInterpolatedStringBase(BoundKind kind, SyntaxNode syntax, ImmutableArray<BoundExpression> parts, ConstantValue? constantValueOpt, TypeSymbol? type, bool hasErrors = false)
7892public override ConstantValue? ConstantValueOpt { get; }
7897public BoundUnconvertedInterpolatedString(SyntaxNode syntax, ImmutableArray<BoundExpression> parts, ConstantValue? constantValueOpt, TypeSymbol? type, bool hasErrors = false)
7909public BoundUnconvertedInterpolatedString Update(ImmutableArray<BoundExpression> parts, ConstantValue? constantValueOpt, TypeSymbol? type)
7923public BoundInterpolatedString(SyntaxNode syntax, InterpolatedStringHandlerData? interpolationData, ImmutableArray<BoundExpression> parts, ConstantValue? constantValueOpt, TypeSymbol? type, bool hasErrors = false)
7937public BoundInterpolatedString Update(InterpolatedStringHandlerData? interpolationData, ImmutableArray<BoundExpression> parts, ConstantValue? constantValueOpt, TypeSymbol? type)
8122public BoundConstantPattern(SyntaxNode syntax, BoundExpression value, ConstantValue constantValue, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
8140public ConstantValue ConstantValue { get; }
8145public BoundConstantPattern Update(BoundExpression value, ConstantValue constantValue, TypeSymbol inputType, TypeSymbol narrowedType)
8629public BoundRelationalPattern(SyntaxNode syntax, BinaryOperatorKind relation, BoundExpression value, ConstantValue constantValue, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
8649public ConstantValue ConstantValue { get; }
8654public BoundRelationalPattern Update(BinaryOperatorKind relation, BoundExpression value, ConstantValue constantValue, TypeSymbol inputType, TypeSymbol narrowedType)
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)
386_factory.Convert(operandType, new BoundLiteral(syntax, ConstantValue.Null, objectType), Conversion.NullToPointer),
394protected BoundExpression MakeValueTest(SyntaxNode syntax, BoundExpression input, ConstantValue value)
408protected BoundExpression MakeRelationalTest(SyntaxNode syntax, BoundExpression input, BinaryOperatorKind operatorKind, ConstantValue value)
444private BoundExpression MakeSpanStringTest(BoundExpression input, ConstantValue value)
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,
856ConstantValue? constantValueOpt = null)
1339MakeConversionNode(null, syntax, conditional.Consequence, conversion, @checked, explicitCastInCode: false, constantValueOpt: ConstantValue.NotAvailable, rewrittenType: type),
1340MakeConversionNode(null, syntax, conditional.Alternative, conversion, @checked, explicitCastInCode: false, constantValueOpt: ConstantValue.NotAvailable, rewrittenType: type),
1341ConstantValue.NotAvailable,
1504ConstantValue? constantValueOpt,
1714private BoundExpression RewriteDecimalConversion(SyntaxNode syntax, BoundExpression operand, TypeSymbol fromType, TypeSymbol toType, bool @checked, bool isImplicit, ConstantValue? constantValueOpt)
1745private BoundExpression RewriteDecimalConversionCore(SyntaxNode syntax, BoundExpression operand, TypeSymbol fromType, TypeSymbol toType, bool isImplicit, ConstantValue? constantValueOpt)
Lowering\LocalRewriter\LocalRewriter_ForEachStatement.cs (6)
458right: MakeLiteral(forEachSyntax, constantValue: ConstantValue.Null, type: null),
637MakeLiteral(forEachSyntax, ConstantValue.Default(SpecialType.System_Int32), intType));
926MakeLiteral(forEachSyntax, ConstantValue.Default(SpecialType.System_Int32), intType));
1089constantValue: ConstantValue.Create(dimension, ConstantValueTypeDiscriminator.Int32),
1143constantValue: ConstantValue.Create(dimension, ConstantValueTypeDiscriminator.Int32),
1256constantValue: ConstantValue.Create(1),
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,
898(TypeSymbol binaryOperandType, ConstantValue constantOne) = GetConstantOneForIncrement(_compilation, binaryOperatorKind);
1011return RewriteConditionalOperator(syntax, condition, consequence, alternative, ConstantValue.NotAvailable, operand.Type, isRef: false);
1243private static (TypeSymbol, ConstantValue) GetConstantOneForIncrement(
1247ConstantValue constantOne;
1252constantOne = ConstantValue.Create(1);
1255constantOne = ConstantValue.Create(1U);
1258constantOne = ConstantValue.Create(1L);
1261constantOne = ConstantValue.Create(1LU);
1264constantOne = ConstantValue.Create(1);
1267constantOne = ConstantValue.Create(1U);
1270constantOne = ConstantValue.Create(1f);
1273constantOne = ConstantValue.Create(1.0);
1276constantOne = ConstantValue.Create(1m);
Lowering\SyntheticBoundNodeFactory.cs (21)
251return new BoundFieldAccess(Syntax, receiver, f, ConstantValue.NotAvailable, LookupResultKind.Viable, f.Type) { WasCompilerGenerated = true };
576expression = BoundConversion.Synthesized(Syntax, expression, conversion, false, explicitCastInCode: false, conversionGroupOpt: null, InConversionGroupFlags.Unspecified, ConstantValue.NotAvailable, CurrentFunction.ReturnType);
645return new BoundBinaryOperator(this.Syntax, kind, ConstantValue.NotAvailable, methodOpt: null, constrainedToTypeOpt: null, LookupResultKind.Viable, left, right, type) { WasCompilerGenerated = true };
739return new BoundLiteral(Syntax, ConstantValue.Create(value), SpecialType(Microsoft.CodeAnalysis.SpecialType.System_Byte)) { WasCompilerGenerated = true };
744return new BoundLiteral(Syntax, ConstantValue.Create(value), SpecialType(Microsoft.CodeAnalysis.SpecialType.System_Int32)) { WasCompilerGenerated = true };
752return new BoundLiteral(Syntax, ConstantValue.Create(value), SpecialType(Microsoft.CodeAnalysis.SpecialType.System_UInt32)) { WasCompilerGenerated = true };
755public BoundLiteral Literal(ConstantValue value, TypeSymbol type)
1110var caseBuilder = ArrayBuilder<(ConstantValue Value, LabelSymbol label)>.GetInstance();
1121caseBuilder.Add((ConstantValue.Create(value), sectionLabel));
1161return new BoundLiteral(Syntax, ConstantValue.Create(value), SpecialType(Microsoft.CodeAnalysis.SpecialType.System_Boolean)) { WasCompilerGenerated = true };
1166var stringConst = ConstantValue.Create(value);
1170public BoundLiteral StringLiteral(ConstantValue stringConst)
1178return StringLiteral(ConstantValue.Create(stringValue));
1181public BoundLiteral CharLiteral(ConstantValue charConst)
1189return CharLiteral(ConstantValue.Create(charValue));
1266BoundExpression nullLiteral = new BoundLiteral(syntax, ConstantValue.Null, type) { WasCompilerGenerated = true };
1777return Literal(ConstantValue.Create(rewrittenExpr.ConstantValueOpt.IsNull, ConstantValueTypeDiscriminator.Boolean), boolType);
1779return Literal(ConstantValue.Create(rewrittenExpr.ConstantValueOpt.IsNull, ConstantValueTypeDiscriminator.Boolean), boolType);
1799return RewriteNullableNullEquality(syntax, operatorKind, rewrittenExpr, Literal(ConstantValue.Null, objectType), boolType);
1884new 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)
930var value = DecodeDefaultParameterValueAttribute(description, attribute, syntax, diagnose: true, diagnosticsOpt: diagnostics);
948private void VerifyParamDefaultValueMatchesAttributeIfAny(ConstantValue value, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
953var attrValue = data.DefaultParameterValue;
954if ((attrValue != ConstantValue.Unset) &&
963private ConstantValue DecodeDefaultParameterValueAttribute(AttributeDescription description, CSharpAttributeData attribute, AttributeSyntax node, bool diagnose, BindingDiagnosticBag diagnosticsOpt)
982private ConstantValue DecodeDefaultParameterValueAttribute(CSharpAttributeData attribute, AttributeSyntax node, bool diagnose, BindingDiagnosticBag diagnosticsOpt)
993return ConstantValue.Bad;
1014var constantValueDiscriminator = ConstantValue.GetDiscriminator(specialType);
1031return ConstantValue.Bad;
1041return ConstantValue.Bad;
1052return ConstantValue.Bad;
1060return 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);