6 types derived from ConstantValue
Microsoft.CodeAnalysis (6)
ConstantValueSpecialized.cs (6)
28private sealed class ConstantValueBad : ConstantValue 68private sealed class ConstantValueNull : ConstantValue 134private sealed class ConstantValueString : ConstantValue 229private sealed class ConstantValueDecimal : ConstantValue 270private sealed class ConstantValueDateTime : ConstantValue 313private abstract class ConstantValueDiscriminated : ConstantValue
2126 references to ConstantValue
Microsoft.CodeAnalysis (378)
CodeGen\ILBuilderEmit.cs (3)
230KeyValuePair<ConstantValue, object>[] caseLabels, 261KeyValuePair<ConstantValue, object>[] caseLabels, 566internal void EmitConstantValue(ConstantValue value)
CodeGen\SwitchIntegralJumpTableEmitter.cs (20)
40private readonly ImmutableArray<KeyValuePair<ConstantValue, object>> _sortedCaseLabels; 51KeyValuePair<ConstantValue, object>[] caseLabels, 109if (sortedCaseLabels[0].Key != ConstantValue.Null) 139private static int CompareIntegralSwitchLabels(KeyValuePair<ConstantValue, object> first, KeyValuePair<ConstantValue, object> second) 141ConstantValue firstConstant = first.Key; 142ConstantValue secondConstant = second.Key; 296ConstantValue pivotConstant = switchBuckets[mid - 1].EndConstant; 327ConstantValue constant = c.Key; 364ConstantValue startConstant = switchBucket.StartConstant; 386ConstantValue caseLabelConstant = switchBucket[nextCaseIndex].Key; 414private void EmitCondBranchForSwitch(ILOpCode branchCode, ConstantValue constant, object targetLabel) 430private void EmitEqBranchForSwitch(ConstantValue constant, object targetLabel) 451private void EmitRangeCheckedBranch(ConstantValue startConstant, ConstantValue endConstant, object targetLabel) 471int Int32Value(ConstantValue value) 514private void EmitNormalizedSwitchKey(ConstantValue startConstant, ConstantValue endConstant, object bucketFallThroughLabel) 535private void EmitRangeCheckIfNeeded(ConstantValue startConstant, ConstantValue endConstant, object bucketFallThroughLabel)
CodeGen\SwitchIntegralJumpTableEmitter.SwitchBucket.cs (21)
18private readonly ImmutableArray<KeyValuePair<ConstantValue, object>> _allLabels; 54internal SwitchBucket(ImmutableArray<KeyValuePair<ConstantValue, object>> allLabels, int index) 62private SwitchBucket(ImmutableArray<KeyValuePair<ConstantValue, object>> allLabels, int startIndex, int endIndex) 72internal SwitchBucket(ImmutableArray<KeyValuePair<ConstantValue, object>> allLabels, int startIndex, int endIndex, bool isDegenerate) 91internal KeyValuePair<ConstantValue, object> this[int i] 144var lastConst = this.StartConstant; 171private bool IsContiguous(ConstantValue lastConst, ConstantValue nextConst) 181private static ulong GetBucketSize(ConstantValue startConstant, ConstantValue endConstant) 203private static bool BucketOverflowUInt64Limit(ConstantValue startConstant, ConstantValue endConstant) 223private static bool BucketOverflow(ConstantValue startConstant, ConstantValue endConstant) 245internal ConstantValue StartConstant 253internal ConstantValue EndConstant 261private static bool IsValidSwitchBucketConstant(ConstantValue constant) 269private static bool IsValidSwitchBucketConstantPair(ConstantValue startConstant, ConstantValue endConstant) 284var startConstant = bucket1.StartConstant; 285var endConstant = bucket2.EndConstant;
CodeGen\SwitchStringJumpTableEmitter.cs (12)
16using HashBucket = List<KeyValuePair<ConstantValue, object>>; 30private readonly KeyValuePair<ConstantValue, object>[] _caseLabels; 43public delegate void EmitStringCompareAndBranch(LocalOrParameter key, ConstantValue stringConstant, object targetLabel); 69KeyValuePair<ConstantValue, object>[] caseLabels, 134var jumpTableLabels = new KeyValuePair<ConstantValue, object>[count]; 139ConstantValue hashConstant = ConstantValue.Create(hashValue); 142jumpTableLabels[i] = new KeyValuePair<ConstantValue, object>(hashConstant, hashBucketLabel); 161private void EmitNonHashTableSwitch(KeyValuePair<ConstantValue, object>[] labels) 172private void EmitCondBranchForStringSwitch(ConstantValue stringConstant, object targetLabel) 184KeyValuePair<ConstantValue, object>[] caseLabels, 192ConstantValue stringConstant = kvPair.Key;
Compilation\Compilation.cs (1)
1728internal abstract IConvertibleConversion ClassifyConvertibleConversion(IOperation source, ITypeSymbol destination, out ConstantValue? constantValue);
Compilation\Expression.cs (15)
9public static ConstantValue SynthesizeNumeric(ITypeSymbol type, int value) 14return ConstantValue.Create(value); 16return ConstantValue.Create((long)value); 18return ConstantValue.Create((uint)value); 20return ConstantValue.Create((ulong)value); 22return ConstantValue.Create((ushort)value); 24return ConstantValue.Create((short)value); 26return ConstantValue.Create((sbyte)value); 28return ConstantValue.Create((byte)value); 30return ConstantValue.Create((char)value); 32return ConstantValue.Create(value != 0); 34return ConstantValue.Create((float)value); 36return ConstantValue.Create((double)value); 38return ConstantValue.Create(1, ConstantValueTypeDiscriminator.Int32); 46return ConstantValue.Bad;
ConstantValue.cs (40)
38internal abstract partial class ConstantValue : IEquatable<ConstantValue?>, IFormattable 87public const ConstantValue NotAvailable = null; 89public static ConstantValue Bad { get { return ConstantValueBad.Instance; } } 90public static ConstantValue Null { get { return ConstantValueNull.Instance; } } 91public static ConstantValue Nothing { get { return Null; } } 94public static ConstantValue Unset { get { return ConstantValueNull.Uninitialized; } } 96public static ConstantValue True { get { return ConstantValueOne.Boolean; } } 97public static ConstantValue False { get { return ConstantValueDefault.Boolean; } } 99public static ConstantValue Create(string? value) 109internal static ConstantValue CreateFromRope(Rope value) 115public static ConstantValue Create(char value) 125public static ConstantValue Create(sbyte value) 139public static ConstantValue Create(byte value) 153public static ConstantValue Create(Int16 value) 167public static ConstantValue Create(UInt16 value) 181public static ConstantValue Create(Int32 value) 195public static ConstantValue Create(UInt32 value) 209public static ConstantValue Create(Int64 value) 223public static ConstantValue Create(UInt64 value) 237public static ConstantValue CreateNativeInt(Int32 value) 251public static ConstantValue CreateNativeUInt(UInt32 value) 265public static ConstantValue Create(bool value) 277public static ConstantValue Create(float value) 291public static ConstantValue CreateSingle(double value) 305public static ConstantValue Create(double value) 319public static ConstantValue Create(decimal value) 339public static ConstantValue Create(DateTime value) 349public static ConstantValue Create(object value, SpecialType st) 356public static ConstantValue CreateSizeOf(SpecialType st) 359return (size == 0) ? ConstantValue.NotAvailable : ConstantValue.Create(size); 362public static ConstantValue Create(object value, ConstantValueTypeDiscriminator discriminator) 395public static ConstantValue Default(SpecialType st) 402public static ConstantValue Default(ConstantValueTypeDiscriminator discriminator) 841public virtual bool Equals(ConstantValue? other) 856public static bool operator ==(ConstantValue? left, ConstantValue? right) 871public static bool operator !=(ConstantValue? left, ConstantValue? right) 883return this.Equals(obj as ConstantValue);
ConstantValueSpecialized.cs (18)
48public override bool Equals(ConstantValue? other) 105public override bool Equals(ConstantValue? other) 205public override bool Equals(ConstantValue? other) 264public override bool Equals(ConstantValue? other) 305public override bool Equals(ConstantValue? other) 426public override bool Equals(ConstantValue? other) 454public override bool Equals(ConstantValue? other) 477public override bool Equals(ConstantValue? other) 500public override bool Equals(ConstantValue? other) 635public override bool Equals(ConstantValue? other) 653public override bool Equals(ConstantValue? other) 706public override bool Equals(ConstantValue? other) 763public override bool Equals(ConstantValue? other) 806public override bool Equals(ConstantValue? other) 849public override bool Equals(ConstantValue? other) 893public override bool Equals(ConstantValue? other) 927public override bool Equals(ConstantValue? other) 973public override bool Equals(ConstantValue? other)
EnumConstantHelper.cs (11)
20internal static EnumOverflowKind OffsetValue(ConstantValue constantValue, uint offset, out ConstantValue offsetValue) 25offsetValue = ConstantValue.Bad; 36offsetValue = ConstantValue.Create((sbyte)(previous + offset)); 46offsetValue = ConstantValue.Create((byte)(previous + offset)); 56offsetValue = ConstantValue.Create((short)(previous + offset)); 66offsetValue = ConstantValue.Create((ushort)(previous + offset)); 76offsetValue = ConstantValue.Create((int)(previous + offset)); 86offsetValue = ConstantValue.Create((uint)(previous + offset)); 96offsetValue = ConstantValue.Create((long)(previous + offset)); 106offsetValue = ConstantValue.Create((ulong)(previous + offset));
Generated\Operations.Generated.cs (140)
3678internal override ConstantValue? OperationConstantValue => null; 3733internal override ConstantValue? OperationConstantValue => null; 3803internal override ConstantValue? OperationConstantValue => null; 3909internal override ConstantValue? OperationConstantValue => null; 4001internal override ConstantValue? OperationConstantValue => null; 4113internal override ConstantValue? OperationConstantValue => null; 4137internal override ConstantValue? OperationConstantValue => null; 4190internal override ConstantValue? OperationConstantValue => null; 4210internal override ConstantValue? OperationConstantValue => null; 4224internal override ConstantValue? OperationConstantValue => null; 4276internal override ConstantValue? OperationConstantValue => null; 4340internal override ConstantValue? OperationConstantValue => null; 4419internal override ConstantValue? OperationConstantValue => null; 4487internal override ConstantValue? OperationConstantValue => null; 4538internal override ConstantValue? OperationConstantValue => null; 4602internal override ConstantValue? OperationConstantValue => null; 4616internal override ConstantValue? OperationConstantValue => null; 4630internal override ConstantValue? OperationConstantValue => null; 4696internal override ConstantValue? OperationConstantValue => null; 4703internal LiteralOperation(SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 4714internal override ConstantValue? OperationConstantValue { get; } 4721internal ConversionOperation(IOperation operand, IConvertibleConversion conversion, bool isTryCast, bool isChecked, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 4774internal override ConstantValue? OperationConstantValue { get; } 4847internal override ConstantValue? OperationConstantValue => null; 4914internal override ConstantValue? OperationConstantValue => null; 4921internal LocalReferenceOperation(ILocalSymbol local, bool isDeclaration, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 4936internal override ConstantValue? OperationConstantValue { get; } 4955internal override ConstantValue? OperationConstantValue => null; 4972internal FieldReferenceOperation(IFieldSymbol field, bool isDeclaration, IOperation? instance, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 5020internal override ConstantValue? OperationConstantValue { get; } 5076internal override ConstantValue? OperationConstantValue => null; 5145internal override ConstantValue? OperationConstantValue => null; 5199internal override ConstantValue? OperationConstantValue => null; 5206internal UnaryOperation(UnaryOperatorKind operatorKind, IOperation operand, bool isLifted, bool isChecked, IMethodSymbol? operatorMethod, ITypeSymbol? constrainedToType, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 5262internal override ConstantValue? OperationConstantValue { get; } 5269internal BinaryOperation(BinaryOperatorKind operatorKind, IOperation leftOperand, IOperation rightOperand, bool isLifted, bool isChecked, bool isCompareText, IMethodSymbol? operatorMethod, ITypeSymbol? constrainedToType, IMethodSymbol? unaryOperatorMethod, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 5340internal override ConstantValue? OperationConstantValue { get; } 5347internal ConditionalOperation(IOperation condition, IOperation whenTrue, IOperation? whenFalse, bool isRef, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 5417internal override ConstantValue? OperationConstantValue { get; } 5424internal CoalesceOperation(IOperation value, IOperation whenNull, IConvertibleConversion valueConversion, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 5484internal override ConstantValue? OperationConstantValue { get; } 5537internal override ConstantValue? OperationConstantValue => null; 5544internal ObjectCreationOperation(IMethodSymbol? constructor, IObjectOrCollectionInitializerOperation? initializer, ImmutableArray<IArgumentOperation> arguments, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 5607internal override ConstantValue? OperationConstantValue { get; } 5659internal override ConstantValue? OperationConstantValue => null; 5726internal override ConstantValue? OperationConstantValue => null; 5745internal override ConstantValue? OperationConstantValue => null; 5801internal override ConstantValue? OperationConstantValue => null; 5853internal override ConstantValue? OperationConstantValue => null; 5871internal SimpleAssignmentOperation(bool isRef, IOperation target, IOperation value, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 5926internal override ConstantValue? OperationConstantValue { get; } 6001internal override ConstantValue? OperationConstantValue => null; 6008internal ParenthesizedOperation(IOperation operand, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 6054internal override ConstantValue? OperationConstantValue { get; } 6119internal override ConstantValue? OperationConstantValue => null; 6182internal override ConstantValue? OperationConstantValue => null; 6199internal override ConstantValue? OperationConstantValue => null; 6206internal InterpolatedStringOperation(ImmutableArray<IInterpolatedStringContentOperation> parts, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 6256internal override ConstantValue? OperationConstantValue { get; } 6312internal override ConstantValue? OperationConstantValue => null; 6368internal override ConstantValue? OperationConstantValue => null; 6431internal override ConstantValue? OperationConstantValue => null; 6438internal NameOfOperation(IOperation argument, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 6484internal override ConstantValue? OperationConstantValue { get; } 6542internal override ConstantValue? OperationConstantValue => null; 6600internal override ConstantValue? OperationConstantValue => null; 6652internal override ConstantValue? OperationConstantValue => null; 6704internal override ConstantValue? OperationConstantValue => null; 6711internal DefaultValueOperation(SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 6722internal override ConstantValue? OperationConstantValue { get; } 6741internal override ConstantValue? OperationConstantValue => null; 6748internal SizeOfOperation(ITypeSymbol typeOperand, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 6761internal override ConstantValue? OperationConstantValue { get; } 6813internal override ConstantValue? OperationConstantValue => null; 6876internal override ConstantValue? OperationConstantValue => null; 6939internal override ConstantValue? OperationConstantValue => null; 6991internal override ConstantValue? OperationConstantValue => null; 7050internal override ConstantValue? OperationConstantValue => null; 7102internal override ConstantValue? OperationConstantValue => null; 7119internal override ConstantValue? OperationConstantValue => null; 7181internal override ConstantValue? OperationConstantValue => null; 7228internal override ConstantValue? OperationConstantValue => null; 7279internal override ConstantValue? OperationConstantValue => null; 7330internal override ConstantValue? OperationConstantValue => null; 7385internal override ConstantValue? OperationConstantValue => null; 7453internal override ConstantValue? OperationConstantValue => null; 7534internal override ConstantValue? OperationConstantValue => null; 7595internal override ConstantValue? OperationConstantValue => null; 7672internal override ConstantValue? OperationConstantValue => null; 7746internal override ConstantValue? OperationConstantValue => null; 7770internal override ConstantValue? OperationConstantValue => null; 7833internal override ConstantValue? OperationConstantValue => null; 7895internal override ConstantValue? OperationConstantValue => null; 7948internal override ConstantValue? OperationConstantValue => null; 7999internal override ConstantValue? OperationConstantValue => null; 8055internal override ConstantValue? OperationConstantValue => null; 8128internal override ConstantValue? OperationConstantValue => null; 8190internal override ConstantValue? OperationConstantValue => null; 8212internal override ConstantValue? OperationConstantValue => null; 8277internal override ConstantValue? OperationConstantValue => null; 8344internal override ConstantValue? OperationConstantValue => null; 8415internal override ConstantValue? OperationConstantValue => null; 8434internal override ConstantValue? OperationConstantValue => null; 8487internal override ConstantValue? OperationConstantValue => null; 8494internal FlowCaptureReferenceOperation(CaptureId id, bool isInitialization, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 8509internal override ConstantValue? OperationConstantValue { get; } 8516internal IsNullOperation(IOperation operand, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 8562internal override ConstantValue? OperationConstantValue { get; } 8579internal override ConstantValue? OperationConstantValue => null; 8598internal override ConstantValue? OperationConstantValue => null; 8657internal override ConstantValue? OperationConstantValue => null; 8724internal override ConstantValue? OperationConstantValue => null; 8781internal override ConstantValue? OperationConstantValue => null; 8847internal override ConstantValue? OperationConstantValue => null; 8923internal override ConstantValue? OperationConstantValue => null; 8937internal override ConstantValue? OperationConstantValue => null; 9006internal override ConstantValue? OperationConstantValue => null; 9081internal override ConstantValue? OperationConstantValue => null; 9143internal override ConstantValue? OperationConstantValue => null; 9206internal override ConstantValue? OperationConstantValue => null; 9270internal override ConstantValue? OperationConstantValue => null; 9322internal override ConstantValue? OperationConstantValue => null; 9341internal override ConstantValue? OperationConstantValue => null; 9403internal override ConstantValue? OperationConstantValue => null; 9458internal override ConstantValue? OperationConstantValue => null; 9509internal override ConstantValue? OperationConstantValue => null; 9573internal override ConstantValue? OperationConstantValue => null; 9591internal override ConstantValue? OperationConstantValue => null; 9644internal override ConstantValue? OperationConstantValue => null; 9709internal override ConstantValue? OperationConstantValue => null; 9776internal override ConstantValue? OperationConstantValue => null; 9838internal override ConstantValue? OperationConstantValue => null; 9890internal override ConstantValue? OperationConstantValue => null; 9910internal override ConstantValue? OperationConstantValue => null; 9977internal override ConstantValue? OperationConstantValue => null; 10038internal override ConstantValue? OperationConstantValue => null; 10091internal override ConstantValue? OperationConstantValue => null; 10158internal override ConstantValue? OperationConstantValue => null; 10177internal override ConstantValue? OperationConstantValue => null; 10228internal override ConstantValue? OperationConstantValue => null;
MetadataReader\MetadataDecoder.cs (24)
987internal void DecodeLocalConstantBlobOrThrow(ref BlobReader sigReader, out TypeSymbol type, out ConstantValue value) 1012value = ConstantValue.Create(sigReader.ReadDecimal()); 1016value = ConstantValue.Create(sigReader.ReadDateTime()); 1022value = (type.IsReferenceType || type.TypeKind == TypeKind.Pointer || type.TypeKind == TypeKind.FunctionPointer) ? ConstantValue.Null : ConstantValue.Bad; 1026value = ConstantValue.Bad; 1057private static ConstantValue DecodePrimitiveConstantValue(ref BlobReader sigReader, SignatureTypeCode typeCode, out bool isEnumTypeCode) 1063return ConstantValue.Create(sigReader.ReadBoolean()); 1067return ConstantValue.Create(sigReader.ReadChar()); 1071return ConstantValue.Create(sigReader.ReadSByte()); 1075return ConstantValue.Create(sigReader.ReadByte()); 1079return ConstantValue.Create(sigReader.ReadInt16()); 1083return ConstantValue.Create(sigReader.ReadUInt16()); 1087return ConstantValue.Create(sigReader.ReadInt32()); 1091return ConstantValue.Create(sigReader.ReadUInt32()); 1095return ConstantValue.Create(sigReader.ReadInt64()); 1099return ConstantValue.Create(sigReader.ReadUInt64()); 1103return ConstantValue.Create(sigReader.ReadSingle()); 1107return ConstantValue.Create(sigReader.ReadDouble()); 1116return ConstantValue.Bad; 1119return ConstantValue.Null; 1124return ConstantValue.Bad; 1127return ConstantValue.Create(sigReader.ReadUTF16(sigReader.RemainingBytes)); 1132return ConstantValue.Null;
MetadataReader\PEModule.cs (27)
1372internal bool HasDateTimeConstantAttribute(EntityHandle token, out ConstantValue defaultValue) 1381defaultValue = ConstantValue.Bad; 1385defaultValue = ConstantValue.Create(new DateTime(value)); 1395internal bool HasDecimalConstantAttribute(EntityHandle token, out ConstantValue defaultValue) 1401defaultValue = ConstantValue.Create(value); 3304internal ConstantValue GetParamDefaultValue(ParameterHandle param) 3313return constantHandle.IsNil ? ConstantValue.Bad : GetConstantValueOrThrow(constantHandle); 3317return ConstantValue.Bad; 3321internal ConstantValue GetConstantFieldValue(FieldDefinitionHandle fieldDef) 3330return constantHandle.IsNil ? ConstantValue.Bad : GetConstantValueOrThrow(constantHandle); 3334return ConstantValue.Bad; 3425private ConstantValue GetConstantValueOrThrow(ConstantHandle handle) 3432return ConstantValue.Create(reader.ReadBoolean()); 3435return ConstantValue.Create(reader.ReadChar()); 3438return ConstantValue.Create(reader.ReadSByte()); 3441return ConstantValue.Create(reader.ReadInt16()); 3444return ConstantValue.Create(reader.ReadInt32()); 3447return ConstantValue.Create(reader.ReadInt64()); 3450return ConstantValue.Create(reader.ReadByte()); 3453return ConstantValue.Create(reader.ReadUInt16()); 3456return ConstantValue.Create(reader.ReadUInt32()); 3459return ConstantValue.Create(reader.ReadUInt64()); 3462return ConstantValue.Create(reader.ReadSingle()); 3465return ConstantValue.Create(reader.ReadDouble()); 3468return ConstantValue.Create(reader.ReadUTF16(reader.Length)); 3476return ConstantValue.Null; 3482return ConstantValue.Bad;
Operations\ControlFlowGraphBuilder.cs (12)
2416ConstantValue constantValue = ConstantValue.Create(!isAndAlso); 2441return new ConversionOperation(operand, _compilation.ClassifyConvertibleConversion(operand, type, out ConstantValue? constantValue), isTryCast: false, isChecked: false, 2675var constantValue = ConstantValue.Create(stopValue); 3298ConstantValue? constantValue = operand.GetConstantValue() is { IsNull: var isNull } 3299? ConstantValue.Create(isNull) 3442? ConstantValue.Null 4184return new ConversionOperation(operand, _compilation.ClassifyConvertibleConversion(operand, iDisposable, out var constantValue), isTryCast, isChecked: false, 4851isUp = new LiteralOperation(semanticModel: null, stepValue.Syntax, booleanType, constantValue: ConstantValue.Create(false), isImplicit: true); 4860constantValue: ConstantValue.Default(stepValueEnumUnderlyingTypeOrSelf.SpecialType), 5147constantValue: ConstantValue.Create(bits), isImplicit: true);
Operations\Operation.cs (1)
90internal abstract CodeAnalysis.ConstantValue? OperationConstantValue { get; }
Operations\OperationExtensions.cs (1)
388internal static ConstantValue? GetConstantValue(this IOperation operation)
Operations\OperationNodes.cs (10)
18public NoneOperation(ImmutableArray<IOperation> children, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) : 65internal override ConstantValue? OperationConstantValue { get; } 87public InvalidOperation(ImmutableArray<IOperation> children, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) : 136internal override ConstantValue? OperationConstantValue { get; } 170internal override ConstantValue? OperationConstantValue => null; 259internal override ConstantValue? OperationConstantValue => null; 401internal override ConstantValue? OperationConstantValue => null; 423internal override ConstantValue? OperationConstantValue => null; 641public FlowCaptureReferenceOperation(int id, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isInitialization = false) : 658public IsNullOperation(SyntaxNode syntax, IOperation operand, ITypeSymbol type, ConstantValue? constantValue) :
SwitchConstantValueHelper.cs (9)
17public static bool IsValidSwitchCaseLabelConstant(ConstantValue constant) 50public static int CompareSwitchCaseLabelConstants(ConstantValue first, ConstantValue second) 103var firstConstant = first as ConstantValue; 106var secondConstant = second as ConstantValue; 132var constant = obj as ConstantValue;
Symbols\Attributes\CommonAttributeData.cs (5)
189internal ConstantValue DecodeDecimalConstantValue() 232return ConstantValue.Create(new decimal(low, mid, high, isNegative, scale)); 235internal ConstantValue DecodeDateTimeConstantValue() 242return ConstantValue.Bad; 245return ConstantValue.Create(new DateTime(value));
Symbols\Attributes\CommonFieldWellKnownAttributeData.cs (4)
45private ConstantValue _constValue = ConstantValue.Unset; 47public ConstantValue ConstValue 56Debug.Assert(_constValue == ConstantValue.Unset);
Symbols\Attributes\CommonParameterEarlyWellKnownAttributeData.cs (4)
17private ConstantValue _defaultParameterValue = ConstantValue.Unset; 19public ConstantValue DefaultParameterValue 28Debug.Assert(_defaultParameterValue == ConstantValue.Unset);
Microsoft.CodeAnalysis.CSharp (882)
Binder\Binder_Attributes.cs (2)
556lvalue = new BoundFieldAccess(nameSyntax, null, fieldSymbol, ConstantValue.NotAvailable, resultKind, fieldSymbol.Type); 944ConstantValue? constantValue = node.ConstantValueOpt;
Binder\Binder_Await.cs (1)
369var receiver = new BoundLiteral(node, ConstantValue.Null, awaiterType);
Binder\Binder_Conversions.cs (25)
249ConstantValue? constantValue = this.FoldConstantConversion(syntax, source, conversion, destination, diagnostics); 431var constantValue = FoldConditionalOperator(condition, trueExpr, falseExpr); 503constantValueOpt: ConstantValue.NotAvailable, 585constantValueOpt: ConstantValue.NotAvailable, 622constantValueOpt: ConstantValue.NotAvailable, 672expr = new BoundConversion(syntax, source, conversion, @checked: false, explicitCastInCode: isCast, conversionGroup, constantValueOpt: ConstantValue.NotAvailable, type: delegateType, hasErrors: true) { WasCompilerGenerated = source.WasCompilerGenerated }; 715constantValueOpt: ConstantValue.NotAvailable, 736return new BoundConversion(syntax, group, conversion, @checked: false, explicitCastInCode: isCast, conversionGroup, constantValueOpt: ConstantValue.NotAvailable, type: destination, hasErrors: hasErrors) { WasCompilerGenerated = group.WasCompilerGenerated }; 799DefaultValueFromAttributes: ConstantValue.NotAvailable 835var delegateParamDefault = delegateParameter.HasExplicitDefaultValue ? delegateParameter.ExplicitDefaultConstantValue : null; 979constantValueOpt: ConstantValue.NotAvailable, 994constantValueOpt: ConstantValue.NotAvailable, 1530public ConstantValue? FoldConstantConversion( 1565var sourceConstantValue = source.ConstantValueOpt; 1596return ConstantValue.Create(sourceConstantValue.SingleValue); 1598return ConstantValue.Create(sourceConstantValue.DoubleValue); 1632private ConstantValue? FoldConstantNumericConversion( 1634ConstantValue sourceValue, 1665return ConstantValue.Bad; 1673return ConstantValue.Bad; 1689return ConstantValue.Bad; 1702return ConstantValue.Create(DoUncheckedConversion(destinationType, sourceValue), destinationType); 1705private static object DoUncheckedConversion(SpecialType destinationType, ConstantValue value) 2008public static bool CheckConstantBounds(SpecialType destinationType, ConstantValue value, out bool maySucceedAtRuntime) 2085private static object CanonicalizeConstant(ConstantValue value)
Binder\Binder_Expressions.cs (20)
1396ConstantValue constantValue = GetConstantSizeOf(type); 1437internal static ConstantValue GetConstantSizeOf(TypeSymbol type) 1439return ConstantValue.CreateSizeOf((type.GetEnumUnderlyingType() ?? type).SpecialType); 1906var constantValueOpt = localSymbol.IsConst && !IsInsideNameof && !type.IsErrorType() 3764ConstantValue.Create(knownSizes[i] ?? 0), 3989ConstantValue.Create(boundInitExprOpt.Length), 4009var constantValue = expression.ConstantValueOpt; 4028var constantValue = expression.ConstantValueOpt; 5725ConstantValue constantValueOpt = (initializerSyntaxOpt == null && method.IsDefaultValueTypeConstructor()) ? 6178private static ConstantValue FoldParameterlessValueTypeConstructor(NamedTypeSymbol type) 6211return ConstantValue.Default(specialType); 6240ConstantValue cv; 6245cv = ConstantValue.Null; 6261cv = ConstantValue.Create(value, specialType); 6651if (boundLeft.Kind == BoundKind.Literal && ((BoundLiteral)boundLeft).ConstantValueOpt == ConstantValue.Null) 6808if ((boundLeft is BoundDefaultLiteral || boundLeft is BoundDefaultExpression) && boundLeft.ConstantValueOpt == ConstantValue.Null && 7495ConstantValue constantValueOpt = null; 7500if (constantValueOpt == ConstantValue.Unset) 7504constantValueOpt = ConstantValue.Bad; 8016ConstantValue constant = index.ConstantValueOpt;
Binder\Binder_InterpolatedString.cs (9)
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); 674argumentsBuilder.Add(new BoundLiteral(syntax, ConstantValue.Create(baseStringLength), intType) { WasCompilerGenerated = true }); 676argumentsBuilder.Add(new BoundLiteral(syntax, ConstantValue.Create(numFormatHoles), intType) { WasCompilerGenerated = true }); 787argumentsBuilder.Add(boundLiteral.Update(ConstantValue.Create(literalText), boundLiteral.Type));
Binder\Binder_Invocation.cs (11)
1215defaultValue = new BoundFieldAccess(syntax, null, fieldSymbol, ConstantValue.NotAvailable) { WasCompilerGenerated = true }; 1356var parameterDefaultValue = parameter.ExplicitDefaultConstantValue; 1363var defaultConstantValue = parameterDefaultValue switch 1366{ IsBad: true } => ConstantValue.Null, 1369Debug.Assert((object?)defaultConstantValue != ConstantValue.Unset); 1377defaultValue = new BoundLiteral(syntax, ConstantValue.Create(line), Compilation.GetSpecialType(SpecialType.System_Int32)) { WasCompilerGenerated = true }; 1382defaultValue = new BoundLiteral(syntax, ConstantValue.Create(path), Compilation.GetSpecialType(SpecialType.System_String)) { WasCompilerGenerated = true }; 1387defaultValue = new BoundLiteral(syntax, ConstantValue.Create(memberName), Compilation.GetSpecialType(SpecialType.System_String)) { WasCompilerGenerated = true }; 1396defaultValue = new BoundLiteral(syntax, ConstantValue.Create(argument.Syntax.ToString()), Compilation.GetSpecialType(SpecialType.System_String)) { WasCompilerGenerated = true }; 1398else if (defaultConstantValue == ConstantValue.NotAvailable) 1911return new BoundNameOfOperator(node, boundArgument, ConstantValue.Create(name), Compilation.GetSpecialType(SpecialType.System_String));
Binder\Binder_Operators.cs (110)
415constantValueOpt: ConstantValue.NotAvailable, 518return new BoundBinaryOperator(node, kind, ConstantValue.NotAvailable, methodOpt: null, constrainedToTypeOpt: null, LookupResultKind.Empty, left, right, GetBinaryOperatorErrorType(kind, diagnostics, node), true); 542return new BoundLiteral(node, ConstantValue.Create(kind == BinaryOperatorKind.Equal), GetSpecialType(SpecialType.System_Boolean, diagnostics, node)); 558var stringConstant = FoldBinaryOperator(node, BinaryOperatorKind.StringConcatenation, left, right, right.Type, diagnostics); 633ConstantValue resultConstant = null; 908var constantValue = FoldBinaryOperator(node, kind | BinaryOperatorKind.Bool, left, right, left.Type, diagnostics); 921return new BoundBinaryOperator(node, kind, ConstantValue.NotAvailable, methodOpt: null, constrainedToTypeOpt: null, 1006ConstantValue.NotAvailable, 1017return new BoundBinaryOperator(node, kind, left, right, ConstantValue.NotAvailable, methodOpt: null, constrainedToTypeOpt: null, lookupResult, originalUserDefinedOperators, CreateErrorType(), true); 1456private static object FoldDecimalBinaryOperators(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight) 1487private static object FoldNativeIntegerOverflowingBinaryOperator(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight) 1530private static object FoldUncheckedIntegralBinaryOperator(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight) 1586private static object FoldCheckedIntegralBinaryOperator(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight) 1676private ConstantValue? FoldEnumBinaryOperator( 1737var constantValue = FoldBinaryOperator(syntax, newKind, newLeftOperand, newRightOperand, resultTypeSymbol, diagnostics); 1751private ConstantValue? FoldBinaryOperator( 1768ConstantValue? nullableEqualityResult = TryFoldingNullableEquality(kind, left, right); 1774var valueLeft = left.ConstantValueOpt; 1775var valueRight = right.ConstantValueOpt; 1783return ConstantValue.Bad; 1795return ConstantValue.Bad; 1810return ConstantValue.Create(newValue, resultType); 1813ConstantValue? concatResult = FoldStringConcatenation(kind, valueLeft, valueRight); 1834return ConstantValue.Bad; 1839return ConstantValue.Create(newValue, resultType); 1858return ConstantValue.Create(newValue, resultType); 1870return ConstantValue.Bad; 1880return ConstantValue.Create(newValue, resultType); 1908private static ConstantValue? TryFoldingNullableEquality(BinaryOperatorKind kind, BoundExpression left, BoundExpression right) 1919ConstantValue? leftConstant = leftConv.Operand.ConstantValueOpt; 1920ConstantValue? rightConstant = rightConv.Operand.ConstantValueOpt; 1930return (leftIsNull == rightIsNull) == (op == BinaryOperatorKind.Equal) ? ConstantValue.True : ConstantValue.False; 1941private static object? FoldNeverOverflowBinaryOperators(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight) 2173private static ConstantValue? FoldStringConcatenation(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight) 2184return (newLength > int.MaxValue) ? ConstantValue.Bad : ConstantValue.CreateFromRope(Rope.Concat(leftValue, rightValue)); 2696return new BoundUnaryOperator(node, kind, operand, ConstantValue.NotAvailable, 2717constantValueOpt: ConstantValue.NotAvailable, 2734ConstantValue.NotAvailable, 2748var resultConstant = FoldUnaryOperator(node, resultOperatorKind, resultOperand, resultType, diagnostics); 2764private ConstantValue? FoldEnumUnaryOperator( 2785var constantValue = FoldUnaryOperator(syntax, newKind, operand, upconvertType, diagnostics); 2799private ConstantValue? FoldUnaryOperator( 2814var value = operand.ConstantValueOpt; 2829return ConstantValue.Create(newValue, resultType); 2848return ConstantValue.Create(newValue, resultType); 2860return ConstantValue.Bad; 2870return ConstantValue.Create(newValue, resultType); 2876private static object? FoldNeverOverflowUnaryOperator(UnaryOperatorKind kind, ConstantValue value) 2916private static object? FoldUncheckedIntegralUnaryOperator(UnaryOperatorKind kind, ConstantValue value) 2932private static object? FoldCheckedIntegralUnaryOperator(UnaryOperatorKind kind, ConstantValue value) 2948private static object? FoldNativeIntegerOverflowingUnaryOperator(UnaryOperatorKind kind, ConstantValue value) 3061return new BoundLiteral(node, ConstantValue.Create((int)-2147483648), GetSpecialType(SpecialType.System_Int32, diagnostics, node)); 3076return new BoundLiteral(node, ConstantValue.Create(-9223372036854775808), GetSpecialType(SpecialType.System_Int64, diagnostics, node)); 3082private static bool IsDivisionByZero(BinaryOperatorKind kind, ConstantValue valueRight) 3199var convertedExpression = BindExpressionForPattern(operand.Type, node.Right, ref hasErrors, isPatternDiagnostics, out var constantValueOpt, out var wasExpression, out _); 3206node.Right, convertedExpression, constantValueOpt ?? ConstantValue.Bad, operand.Type, convertedExpression.Type ?? operand.Type, hasErrors) 3245if (operand.ConstantValueOpt == ConstantValue.Null || 3311ConstantValue operandConstantValue) 3318ConstantValue constantValue = GetIsOperatorConstantResult(operandType, targetType, conversionKind, operandConstantValue); 3327Debug.Assert(constantValue == ConstantValue.True || constantValue == ConstantValue.False); 3329ErrorCode errorCode = constantValue == ConstantValue.True ? ErrorCode.WRN_IsAlwaysTrue : ErrorCode.WRN_IsAlwaysFalse; 3337/// - <see cref="ConstantValue.False"/> 3338/// - <see cref="ConstantValue.True"/> 3339/// - <see cref="ConstantValue.Bad"/> - compiler doesn't support the type check, i.e. cannot perform it, even at runtime 3342internal static ConstantValue GetIsOperatorConstantResult( 3346ConstantValue operandConstantValue, 3385if (operandConstantValue == ConstantValue.Null) 3387return ConstantValue.False; 3395(operandConstantValue == null || operandConstantValue == ConstantValue.Null); // a non-null constant is never null 3458return ConstantValue.False; 3468return ConstantValue.False; 3475return ConstantValue.Bad; 3509return ConstantValue.False; 3519return ConstantValue.False; 3535return ConstantValue.False; 3544return operandCouldBeNull ? null : ConstantValue.True; 3550return ConstantValue.False; 3553return operandCouldBeNull ? null : ConstantValue.True; 3568return operandCouldBeNull ? null : ConstantValue.True; 3585return operandCouldBeNull ? null : ConstantValue.True; 3597? ConstantValue.True : ConstantValue.False; 3721operand = new BoundDefaultExpression(operand.Syntax, targetType: null, constantValueOpt: ConstantValue.Null, 3779ConstantValue operandConstantValue) 3841ConstantValue operandConstantValue) 3848ConstantValue constantValue = GetAsOperatorConstantResult(operandType, targetType, conversionKind, operandConstantValue); 3865/// - <see cref="ConstantValue.Null"/> 3866/// - <see cref="ConstantValue.Bad"/> - compiler doesn't support the type check, i.e. cannot perform it, even at runtime 3869internal static ConstantValue GetAsOperatorConstantResult(TypeSymbol operandType, TypeSymbol targetType, ConversionKind conversionKind, ConstantValue operandConstantValue) 3876ConstantValue isOperatorConstantResult = GetIsOperatorConstantResult(operandType, targetType, conversionKind, operandConstantValue); 3886return ConstantValue.Null; 4226ConstantValue? constantValue = null; 4329private static ConstantValue FoldConditionalOperator(BoundExpression condition, BoundExpression trueExpr, BoundExpression falseExpr) 4331ConstantValue trueValue = trueExpr.ConstantValueOpt; 4337ConstantValue falseValue = falseExpr.ConstantValueOpt; 4343ConstantValue conditionValue = condition.ConstantValueOpt; 4348else if (conditionValue == ConstantValue.True) 4352else if (conditionValue == ConstantValue.False) 4358return ConstantValue.Bad;
Binder\Binder_Patterns.cs (26)
424var convertedExpression = BindExpressionOrTypeForPattern(inputType, innerExpression, ref hasErrors, diagnostics, out var constantValueOpt, out bool wasExpression, out Conversion patternConversion); 440node, convertedExpression, constantValueOpt ?? ConstantValue.Bad, inputType, convertedType, hasErrors || constantValueOpt is null); 502out ConstantValue? constantValueOpt, 530out ConstantValue? constantValueOpt, 548out ConstantValue? constantValueOpt, 569if (convertedExpression.Type is null && constantValueOpt != ConstantValue.Null) 582out ConstantValue? constantValue, 598if (expression.ConstantValueOpt == ConstantValue.Null) 611ConstantValue match = ExpressionOfTypeMatchesPatternType(Conversions, inputType, expression.Type, ref useSiteInfo, out _, operandConstantValue: null); 612if (match == ConstantValue.False || match == ConstantValue.Bad) 662if (constantValue == ConstantValue.Null) 756ConstantValue matchPossible = ExpressionOfTypeMatchesPatternType( 759if (matchPossible != ConstantValue.False && matchPossible != ConstantValue.Bad) 788/// - <see cref="ConstantValue.True"/> if the matched type catches all of them 789/// - <see cref="ConstantValue.False"/> if it catches none of them 790/// - <see cref="ConstantValue.Bad"/> - compiler doesn't support the type check, i.e. cannot perform it, even at runtime 793internal static ConstantValue ExpressionOfTypeMatchesPatternType( 799ConstantValue? operandConstantValue = null, 809return ConstantValue.True; 819ConstantValue result = Binder.GetIsOperatorConstantResult(expressionType, patternType, conversion.Kind, operandConstantValue, operandCouldBeNull); 822Debug.Assert(!conversion.IsUserDefined || result == ConstantValue.False || result == ConstantValue.Bad); 1622BoundExpression value = BindExpressionForPattern(inputType, node.Expression, ref hasErrors, diagnostics, out var constantValueOpt, out _, out Conversion patternConversion); 1657constantValueOpt = ConstantValue.Bad;
Binder\Binder_Statements.cs (9)
2196Conversion conversion, TypeSymbol sourceType, TypeSymbol targetType, ConstantValue sourceConstantValueOpt = null) 2213else if (conversion.Kind == ConversionKind.ExplicitNumeric && sourceConstantValueOpt != null && sourceConstantValueOpt != ConstantValue.Bad && 2214ConversionsBase.HasImplicitConstantExpressionConversion(new BoundLiteral(syntax, ConstantValue.Bad, sourceType), targetType)) 2546return BoundConversion.Synthesized(node, BindToTypeForErrorRecovery(expr), Conversion.NoConversion, false, explicitCastInCode: false, conversionGroupOpt: null, ConstantValue.NotAvailable, boolean, hasErrors: true); 2558ConstantValue.NotAvailable, 2612return BoundConversion.Synthesized(node, expr, Conversion.NoConversion, false, explicitCastInCode: false, conversionGroupOpt: null, ConstantValue.NotAvailable, boolean, hasErrors: true); 2631return new BoundUnaryOperator(node, signature.Kind, resultOperand, ConstantValue.NotAvailable, signature.Method, signature.ConstrainedToTypeOpt, resultKind, originalUserDefinedOperators, signature.ReturnType) 3241exceptionSource = new BoundLocal(declaration, local, ConstantValue.NotAvailable, local.Type); 3253if (boundFilter.ConstantValueOpt != ConstantValue.NotAvailable)
Binder\DecisionDagBuilder.cs (16)
340tests.Add(new Tests.One(new BoundDagValueTest(syntax, ConstantValue.Create(patternLength), lengthTemp))); 484if (constant.ConstantValue == ConstantValue.Null) 1104resultForRelation(BinaryOperatorKind relation, ConstantValue value) 1252ConstantValue? matches = ExpressionOfTypeMatchesPatternTypeForLearningFromSuccessfulTypeTest(t1.Type, t2.Type, ref useSiteInfo); 1253if (matches == ConstantValue.False) 1259else if (matches == ConstantValue.True) 1269if (matches == ConstantValue.True) 1310ConstantValue value, 1453(conditions ??= ArrayBuilder<Tests>.GetInstance()).Add(new Tests.One(new BoundDagValueTest(syntax, ConstantValue.Create(lengthValue), s1LengthTemp))); 1490private ConstantValue? ExpressionOfTypeMatchesPatternTypeForLearningFromSuccessfulTypeTest( 1495ConstantValue result = Binder.ExpressionOfTypeMatchesPatternType(_conversions, expressionType, patternType, ref useSiteInfo, out Conversion conversion); 1856public bool IsFullyMatched => RemainingTests is Tests.True && (WhenClause is null || WhenClause.ConstantValueOpt == ConstantValue.True); 2098static Tests? knownResult(BinaryOperatorKind relation, ConstantValue constant, int offset) 2110static ConstantValue safeAdd(ConstantValue constant, int offset) 2117return ConstantValue.Create(offset > (int.MaxValue - value) ? int.MaxValue : value + offset);
Binder\DecisionDagBuilder_ListPatterns.cs (2)
45? new BoundDagRelationalTest(syntax, BinaryOperatorKind.IntGreaterThanOrEqual, ConstantValue.Create(subpatterns.Length - 1), lengthTemp) 46: new BoundDagValueTest(syntax, ConstantValue.Create(subpatterns.Length), lengthTemp)));
Binder\ForEachLoopBinder.cs (2)
548ConstantValue.NotAvailable, 1332ConstantValue.NotAvailable,
Binder\LockBinder.cs (1)
46if (expr.ConstantValueOpt != ConstantValue.Null || Compilation.FeatureStrictEnabled) // Dev10 allows the null literal.
Binder\PatternExplainer.cs (8)
612void addRelation(BinaryOperatorKind relation, ConstantValue value) 654field.GetConstantValue(ConstantFieldsInProgress.Empty, false) is ConstantValue constantValue && 664var sample = remainingValues.Sample; 676if (remainingValues.Any(BinaryOperatorKind.GreaterThan, ConstantValue.Create(int.MaxValue))) 679if (remainingValues.Any(BinaryOperatorKind.LessThan, ConstantValue.Create(int.MinValue))) 684if (remainingValues.Any(BinaryOperatorKind.GreaterThan, ConstantValue.Create(uint.MaxValue))) 691private static string ValueString(ConstantValue value, TypeSymbol type, bool requireExactType) 714private static string PrimitiveValueString(ConstantValue value, TypeSymbol type)
Binder\Semantics\Conversions\Conversions.cs (2)
75var defaultValue = p.ExplicitDefaultConstantValue; 76if (defaultValue != ConstantValue.NotAvailable)
Binder\Semantics\Conversions\ConversionsBase.cs (4)
1276var constantValue = source.ConstantValueOpt; 1385var sourceConstantValue = source.ConstantValueOpt; 1617BoundLiteral intMaxValueLiteral = new BoundLiteral(syntaxNode, ConstantValue.Create(int.MaxValue), expectedAttributeType); 1919private static bool IsConstantNumericZero(ConstantValue value)
Binder\SwitchBinder.cs (6)
103var constantValue = label.SwitchCaseLabelConstant; 201ConstantValue boundLabelConstantOpt = null; 236protected BoundExpression ConvertCaseExpression(CSharpSyntaxNode node, BoundExpression caseExpression, out ConstantValue constantValueOpt, BindingDiagnosticBag diagnostics, bool isGotoCaseExpr = false) 273protected static object KeyForConstant(ConstantValue constantValue) 279protected SourceLabelSymbol FindMatchingSwitchCaseLabel(ConstantValue constantValue, CSharpSyntaxNode labelSyntax) 476ConstantValue gotoCaseExpressionConstant = null;
BoundTree\BoundBinaryOperator.UncommonData.cs (4)
15public static UncommonData UnconvertedInterpolatedStringAddition(ConstantValue? constantValue) => 33public static UncommonData? CreateIfNeeded(ConstantValue? constantValue, MethodSymbol? method, TypeSymbol? constrainedToType, ImmutableArray<MethodSymbol> originalUserDefinedOperatorsOpt) 43public readonly ConstantValue? ConstantValue; 54private UncommonData(ConstantValue? constantValue, MethodSymbol? method, TypeSymbol? constrainedToType, ImmutableArray<MethodSymbol> originalUserDefinedOperatorsOpt, bool isUnconvertedInterpolatedStringAddition, InterpolatedStringHandlerData? interpolatedStringHandlerData)
BoundTree\BoundDecisionDag.cs (1)
146ConstantValue inputConstant = input.ConstantValueOpt;
BoundTree\BoundExpression.cs (6)
81public virtual ConstantValue? ConstantValueOpt 214public override ConstantValue? ConstantValueOpt 278public BoundLocal(SyntaxNode syntax, LocalSymbol localSymbol, ConstantValue? constantValueOpt, TypeSymbol type, bool hasErrors = false) 283public BoundLocal Update(LocalSymbol localSymbol, ConstantValue? constantValueOpt, TypeSymbol type) 355public override ConstantValue? ConstantValueOpt => Data?.ConstantValue; 529public override ConstantValue? ConstantValueOpt
BoundTree\BoundExpressionExtensions.cs (1)
96var constValue = node.ConstantValueOpt;
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 (14)
17ConstantValue? constantValueOpt, 27ConstantValue? constantValueOpt, 39ConstantValue? constantValueOpt, 51ConstantValue? constantValueOpt, 271public static BoundConversion SynthesizedNonUserDefined(SyntaxNode syntax, BoundExpression operand, Conversion conversion, TypeSymbol type, ConstantValue? constantValueOpt = null) 299ConstantValue? constantValueOpt, 325ConstantValue? constantValueOpt, 349ConstantValue? constantValueOpt, 362ConstantValue? constantValueOpt, 375ConstantValue? constantValueOpt, 396ConstantValue? constantValueOpt, 409ConstantValue? constantValueOpt, 689ConstantValue? constantValueOpt, 701ConstantValue? constantValueOpt,
BoundTree\LengthBasedStringSwitchData.cs (1)
137internal static LengthBasedStringSwitchData Create(ImmutableArray<(ConstantValue value, LabelSymbol label)> inputCases)
CodeGen\CodeGenerator.cs (1)
463_builder.EmitConstantValue(ConstantValue.Create(true));
CodeGen\EmitArrayInitializer.cs (3)
215private static ConstantValue AsConstOrDefault(BoundExpression init) 217ConstantValue initConstantValueOpt = init.ConstantValueOpt; 225return ConstantValue.Default(type.SpecialType);
CodeGen\EmitExpression.cs (5)
42var constantValue = expression.ConstantValueOpt; 399var receiverConstant = receiver.ConstantValueOpt; 1478var constVal = receiver.ConstantValueOpt; 3216var constantValue = type.GetDefaultValue(); 3253private void EmitConstantExpression(TypeSymbol type, ConstantValue constantValue, bool used, SyntaxNode syntaxNode)
CodeGen\EmitOperators.cs (4)
360var constant = binOp.Left.ConstantValueOpt; 434private void EmitIsNotNullOrZero(BoundExpression comparand, ConstantValue nullOrZero) 448private void EmitIsNullOrZero(BoundExpression comparand, ConstantValue nullOrZero) 484var constantValue = condition.ConstantValueOpt;
CodeGen\EmitStatement.cs (13)
1218dispatch.Cases.Select(p => new KeyValuePair<ConstantValue, object>(p.value, p.label)).ToArray(), 1225KeyValuePair<ConstantValue, object>[] switchCaseLabels, 1385lengthBasedSwitchInfo.LengthBasedJumpTable.LengthCaseLabels.Select(p => new KeyValuePair<ConstantValue, object>(ConstantValue.Create(p.value), p.label)).ToArray(), 1422charJumpTable.CharCaseLabels.Select(p => new KeyValuePair<ConstantValue, object>(ConstantValue.Create(p.value), p.label)).ToArray(), 1439stringJumpTable.StringCaseLabels.Select(p => new KeyValuePair<ConstantValue, object>(ConstantValue.Create(p.value), p.label)).ToArray(), 1455KeyValuePair<ConstantValue, object>[] switchCaseLabels, 1535if (stringConstant == ConstantValue.Null) 1660private void EmitStringCompareAndBranch(LocalOrParameter key, SyntaxNode syntaxNode, ConstantValue stringConstant, object targetLabel, Microsoft.Cci.IReference stringEqualityMethodRef) 1698private void EmitCharCompareAndBranch(LocalOrParameter key, SyntaxNode syntaxNode, ConstantValue stringConstant, object targetLabel, Cci.IReference sequenceEqualsRef, Cci.IReference asSpanRef) 1957var casesBuilder = ArrayBuilder<(ConstantValue, LabelSymbol)>.GetInstance();
CodeGen\Optimizer.cs (1)
2283internal override ConstantValue GetConstantValue(SyntaxNode node, LocalSymbol inProgress, BindingDiagnosticBag diagnostics)
Compilation\CSharpCompilation.cs (3)
2012var dumbInstance = new BoundLiteral(syntax, ConstantValue.Null, namedType); 2153internal override IConvertibleConversion ClassifyConvertibleConversion(IOperation source, ITypeSymbol? destination, out ConstantValue? constantValue) 2164ConstantValue? sourceConstantValue = source.GetConstantValue();
Compilation\MemberSemanticModel.cs (1)
1254ConstantValue constantValue = boundExpr.ConstantValueOpt;
Compiler\MethodBodySynthesizer.cs (8)
105ImmutableArray.Create<BoundExpression>(new BoundLiteral(syntax, ConstantValue.Create(slotIndex), intType) { WasCompilerGenerated = true }), 121new BoundFieldAccess(syntax, thisReference, hostObjectField, ConstantValue.NotAvailable) { WasCompilerGenerated = true }, 125ImmutableArray.Create<BoundExpression>(new BoundLiteral(syntax, ConstantValue.Create(0), intType) { WasCompilerGenerated = true }), 131ConstantValue.NotAvailable, 149new BoundFieldAccess(syntax, thisReference, field, ConstantValue.NotAvailable) { WasCompilerGenerated = true }, 153ImmutableArray.Create<BoundExpression>(new BoundLiteral(syntax, ConstantValue.Create(targetSubmissionIndex), intType) { WasCompilerGenerated = true }), 160ConstantValue.NotAvailable, 187var fieldAccess = new BoundFieldAccess(syntax, thisReference, field, ConstantValue.NotAvailable) { WasCompilerGenerated = true };
Compiler\MethodCompiler.cs (1)
563ConstantValue constantValue = fieldSymbol.GetConstantValue(ConstantFieldsInProgress.Empty, earlyDecodingWellKnownAttributes: false);
Emitter\Model\ParameterSymbolAdapter.cs (1)
81ConstantValue constant = AdaptedParameterSymbol.ExplicitDefaultConstantValue;
FlowAnalysis\AbstractFlowPass.cs (3)
671return node.ConstantValueOpt == ConstantValue.True; 676return node.ConstantValueOpt == ConstantValue.False; 681return node.ConstantValueOpt == ConstantValue.Null;
FlowAnalysis\DefiniteAssignment.cs (1)
878return value.ConstantValueOpt != ConstantValue.Null;
FlowAnalysis\NullableWalker.cs (1)
7097return expr.ConstantValueOpt == ConstantValue.NotAvailable || !expr.ConstantValueOpt.IsNull || expr.IsSuppressed ? NullableAnnotation.NotAnnotated : NullableAnnotation.Annotated;
FlowAnalysis\NullableWalker.DebugVerifier.cs (1)
255if (node.WhenClause?.ConstantValueOpt != ConstantValue.True)
FlowAnalysis\NullableWalker.PlaceholderLocal.cs (1)
61internal override ConstantValue GetConstantValue(SyntaxNode node, LocalSymbol inProgress, BindingDiagnosticBag diagnostics = null) => null;
FlowAnalysis\NullableWalker_Patterns.cs (4)
145bool isExplicitNullCheck = cp.Value.ConstantValueOpt == ConstantValue.Null; 591Debug.Assert(t.Value != ConstantValue.Null); 607bool isFalseTest = t.Value == ConstantValue.False; 665if (w.WhenExpression != null && w.WhenExpression.ConstantValueOpt != ConstantValue.True)
Generated\BoundNodes.xml.Generated.cs (56)
1170public BoundUnaryOperator(SyntaxNode syntax, UnaryOperatorKind operatorKind, BoundExpression operand, ConstantValue? constantValueOpt, MethodSymbol? methodOpt, TypeSymbol? constrainedToTypeOpt, LookupResultKind resultKind, ImmutableArray<MethodSymbol> originalUserDefinedOperatorsOpt, TypeSymbol type, bool hasErrors = false) 1189public override ConstantValue? ConstantValueOpt { get; } 1198public BoundUnaryOperator Update(UnaryOperatorKind operatorKind, BoundExpression operand, ConstantValue? constantValueOpt, MethodSymbol? methodOpt, TypeSymbol? constrainedToTypeOpt, LookupResultKind resultKind, ImmutableArray<MethodSymbol> originalUserDefinedOperatorsOpt, TypeSymbol type) 1953public BoundUnconvertedConditionalOperator(SyntaxNode syntax, BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue? constantValueOpt, ErrorCode noCommonTypeError, bool hasErrors = false) 1972public override ConstantValue? ConstantValueOpt { get; } 1978public BoundUnconvertedConditionalOperator Update(BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue? constantValueOpt, ErrorCode noCommonTypeError) 1992public BoundConditionalOperator(SyntaxNode syntax, bool isRef, BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue? constantValueOpt, TypeSymbol? naturalTypeOpt, bool wasTargetTyped, TypeSymbol type, bool hasErrors = false) 2015public override ConstantValue? ConstantValueOpt { get; } 2022public BoundConditionalOperator Update(bool isRef, BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue? constantValueOpt, TypeSymbol? naturalTypeOpt, bool wasTargetTyped, TypeSymbol type) 2705public BoundDefaultExpression(SyntaxNode syntax, BoundTypeExpression? targetType, ConstantValue? constantValueOpt, TypeSymbol type, bool hasErrors = false) 2717public override ConstantValue? ConstantValueOpt { get; } 2722public BoundDefaultExpression Update(BoundTypeExpression? targetType, ConstantValue? constantValueOpt, TypeSymbol type) 2808public BoundSizeOfOperator(SyntaxNode syntax, BoundTypeExpression sourceType, ConstantValue? constantValueOpt, TypeSymbol type, bool hasErrors = false) 2821public override ConstantValue? ConstantValueOpt { get; } 2826public BoundSizeOfOperator Update(BoundTypeExpression sourceType, ConstantValue? constantValueOpt, TypeSymbol type) 2840public BoundConversion(SyntaxNode syntax, BoundExpression operand, Conversion conversion, bool isBaseConversion, bool @checked, bool explicitCastInCode, ConstantValue? constantValueOpt, ConversionGroup? conversionGroupOpt, ImmutableArray<MethodSymbol> originalUserDefinedConversionsOpt, TypeSymbol type, bool hasErrors = false) 2863public override ConstantValue? ConstantValueOpt { get; } 2870public BoundConversion Update(BoundExpression operand, Conversion conversion, bool isBaseConversion, bool @checked, bool explicitCastInCode, ConstantValue? constantValueOpt, ConversionGroup? conversionGroupOpt, ImmutableArray<MethodSymbol> originalUserDefinedConversionsOpt, TypeSymbol type) 3704public BoundSwitchDispatch(SyntaxNode syntax, BoundExpression expression, ImmutableArray<(ConstantValue value, LabelSymbol label)> cases, LabelSymbol defaultLabel, LengthBasedStringSwitchData? lengthBasedStringSwitchDataOpt, bool hasErrors = false) 3719public ImmutableArray<(ConstantValue value, LabelSymbol label)> Cases { get; } 3726public BoundSwitchDispatch Update(BoundExpression expression, ImmutableArray<(ConstantValue value, LabelSymbol label)> cases, LabelSymbol defaultLabel, LengthBasedStringSwitchData? lengthBasedStringSwitchDataOpt) 4189public BoundLiteral(SyntaxNode syntax, ConstantValue? constantValueOpt, TypeSymbol? type, bool hasErrors) 4195public BoundLiteral(SyntaxNode syntax, ConstantValue? constantValueOpt, TypeSymbol? type) 4201public override ConstantValue? ConstantValueOpt { get; } 4206public BoundLiteral Update(ConstantValue? constantValueOpt, TypeSymbol? type) 4394public BoundLocal(SyntaxNode syntax, LocalSymbol localSymbol, BoundLocalDeclarationKind declarationKind, ConstantValue? constantValueOpt, bool isNullableUnknown, TypeSymbol type, bool hasErrors) 4407public BoundLocal(SyntaxNode syntax, LocalSymbol localSymbol, BoundLocalDeclarationKind declarationKind, ConstantValue? constantValueOpt, bool isNullableUnknown, TypeSymbol type) 4423public override ConstantValue? ConstantValueOpt { get; } 4429public BoundLocal Update(LocalSymbol localSymbol, BoundLocalDeclarationKind declarationKind, ConstantValue? constantValueOpt, bool isNullableUnknown, TypeSymbol type) 5201public BoundDagValueTest(SyntaxNode syntax, ConstantValue value, BoundDagTemp input, bool hasErrors = false) 5211public ConstantValue Value { get; } 5216public BoundDagValueTest Update(ConstantValue value, BoundDagTemp input) 5230public BoundDagRelationalTest(SyntaxNode syntax, BinaryOperatorKind operatorKind, ConstantValue value, BoundDagTemp input, bool hasErrors = false) 5242public ConstantValue Value { get; } 5247public BoundDagRelationalTest Update(BinaryOperatorKind operatorKind, ConstantValue value, BoundDagTemp input) 6228public 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) 6258public override ConstantValue? ConstantValueOpt { get; } 6265public 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) 6988public BoundFieldAccess(SyntaxNode syntax, BoundExpression? receiverOpt, FieldSymbol fieldSymbol, ConstantValue? constantValueOpt, LookupResultKind resultKind, bool isByValue, bool isDeclaration, TypeSymbol type, bool hasErrors = false) 7006public override ConstantValue? ConstantValueOpt { get; } 7014public BoundFieldAccess Update(BoundExpression? receiverOpt, FieldSymbol fieldSymbol, ConstantValue? constantValueOpt, LookupResultKind resultKind, bool isByValue, bool isDeclaration, TypeSymbol type) 7425public BoundNameOfOperator(SyntaxNode syntax, BoundExpression argument, ConstantValue constantValueOpt, TypeSymbol type, bool hasErrors = false) 7439public override ConstantValue ConstantValueOpt { get; } 7444public BoundNameOfOperator Update(BoundExpression argument, ConstantValue constantValueOpt, TypeSymbol type) 7458protected BoundInterpolatedStringBase(BoundKind kind, SyntaxNode syntax, ImmutableArray<BoundExpression> parts, ConstantValue? constantValueOpt, TypeSymbol? type, bool hasErrors = false) 7469public override ConstantValue? ConstantValueOpt { get; } 7474public BoundUnconvertedInterpolatedString(SyntaxNode syntax, ImmutableArray<BoundExpression> parts, ConstantValue? constantValueOpt, TypeSymbol? type, bool hasErrors = false) 7486public BoundUnconvertedInterpolatedString Update(ImmutableArray<BoundExpression> parts, ConstantValue? constantValueOpt, TypeSymbol? type) 7500public BoundInterpolatedString(SyntaxNode syntax, InterpolatedStringHandlerData? interpolationData, ImmutableArray<BoundExpression> parts, ConstantValue? constantValueOpt, TypeSymbol? type, bool hasErrors = false) 7514public BoundInterpolatedString Update(InterpolatedStringHandlerData? interpolationData, ImmutableArray<BoundExpression> parts, ConstantValue? constantValueOpt, TypeSymbol? type) 7699public BoundConstantPattern(SyntaxNode syntax, BoundExpression value, ConstantValue constantValue, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false) 7713public ConstantValue ConstantValue { get; } 7718public BoundConstantPattern Update(BoundExpression value, ConstantValue constantValue, TypeSymbol inputType, TypeSymbol narrowedType) 8174public BoundRelationalPattern(SyntaxNode syntax, BinaryOperatorKind relation, BoundExpression value, ConstantValue constantValue, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false) 8190public ConstantValue ConstantValue { get; } 8195public BoundRelationalPattern Update(BinaryOperatorKind relation, BoundExpression value, ConstantValue constantValue, TypeSymbol inputType, TypeSymbol narrowedType)
Lowering\DiagnosticsPass_Warnings.cs (4)
392private void CheckVacuousComparisons(BoundBinaryOperator tree, ConstantValue constantValue, BoundNode operand) 548ConstantValue constVal = GetConstantValueForBitwiseOrCheck(leftOperand); 572private static ConstantValue GetConstantValueForBitwiseOrCheck(BoundExpression operand) 586ConstantValue constVal = operand.ConstantValueOpt;
Lowering\Extensions.cs (1)
80if ((object)expr.Type == null && expr.ConstantValueOpt == ConstantValue.Null)
Lowering\LocalRewriter\LocalRewriter.cs (2)
225ConstantValue? constantValue = node.ConstantValueOpt; 280var result = new BoundFieldAccess(node.Syntax, new BoundThisReference(node.Syntax, primaryCtor.ContainingType), field, ConstantValue.NotAvailable, LookupResultKind.Viable, node.Type);
Lowering\LocalRewriter\LocalRewriter.DecisionDagRewriter.cs (20)
590var cases = ArrayBuilder<(ConstantValue value, LabelSymbol label)>.GetInstance(); 621ImmutableArray<(ConstantValue value, LabelSymbol label)> cases, 644(ImmutableArray<(ConstantValue value, LabelSymbol label)> whenTrueCases, ImmutableArray<(ConstantValue value, LabelSymbol label)> whenFalseCases) 645splitCases(ImmutableArray<(ConstantValue value, LabelSymbol label)> cases, BinaryOperatorKind op, ConstantValue value) 647var whenTrueBuilder = ArrayBuilder<(ConstantValue value, LabelSymbol label)>.GetInstance(); 648var whenFalseBuilder = ArrayBuilder<(ConstantValue value, LabelSymbol label)>.GetInstance(); 705private sealed class CasesComparer : IComparer<(ConstantValue value, LabelSymbol label)> 714int IComparer<(ConstantValue value, LabelSymbol label)>.Compare((ConstantValue value, LabelSymbol label) left, (ConstantValue value, LabelSymbol label) right) 716var x = left.value; 717var y = right.value; 737static bool isNaN(ConstantValue value) => 787ImmutableArray<(ConstantValue value, LabelSymbol label)> cases; 793cases = node.Cases.SelectAsArray(p => (ConstantValue.Create((long)p.value.Int32Value), p.label)); 799cases = node.Cases.SelectAsArray(p => (ConstantValue.Create((ulong)p.value.UInt32Value), p.label)); 1009if (whenExpression is not null && whenExpression.ConstantValueOpt != ConstantValue.True) 1161if (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)
379_factory.Convert(operandType, new BoundLiteral(syntax, ConstantValue.Null, objectType)), 387protected BoundExpression MakeValueTest(SyntaxNode syntax, BoundExpression input, ConstantValue value) 401protected BoundExpression MakeRelationalTest(SyntaxNode syntax, BoundExpression input, BinaryOperatorKind operatorKind, ConstantValue value) 431private BoundExpression MakeSpanStringTest(BoundExpression input, ConstantValue value)
Lowering\LocalRewriter\LocalRewriter_AsOperator.cs (1)
51ConstantValue constantValue = Binder.GetAsOperatorConstantResult(rewrittenOperand.Type, rewrittenType, conversion.Kind, rewrittenOperand.ConstantValueOpt);
Lowering\LocalRewriter\LocalRewriter_BinaryOperator.cs (48)
278if (loweredRight.ConstantValueOpt == ConstantValue.True) return loweredLeft; 279if (loweredLeft.ConstantValueOpt == ConstantValue.True) return loweredRight; 280if (loweredLeft.ConstantValueOpt == ConstantValue.False) return loweredLeft; 290if (loweredRight.ConstantValueOpt == ConstantValue.False) return loweredLeft; 291if (loweredLeft.ConstantValueOpt == ConstantValue.False) return loweredRight; 292if (loweredLeft.ConstantValueOpt == ConstantValue.True) return loweredLeft; 302if (loweredRight.ConstantValueOpt == ConstantValue.True) return loweredLeft; 303if (loweredLeft.ConstantValueOpt == ConstantValue.True) return loweredRight; 323if (loweredRight.ConstantValueOpt == ConstantValue.False) return loweredLeft; 324if (loweredLeft.ConstantValueOpt == ConstantValue.False) return loweredRight; 328if (loweredLeft.ConstantValueOpt == ConstantValue.True) return loweredRight; 329if (loweredRight.ConstantValueOpt == ConstantValue.True) return loweredLeft; 333if (loweredLeft.ConstantValueOpt == ConstantValue.False) 336if (loweredRight.ConstantValueOpt == ConstantValue.False) 342if (loweredLeft.ConstantValueOpt == ConstantValue.False) return loweredRight; 343if (loweredRight.ConstantValueOpt == ConstantValue.False) return loweredLeft; 347if (loweredLeft.ConstantValueOpt == ConstantValue.True) 350if (loweredRight.ConstantValueOpt == ConstantValue.True) 356if (loweredLeft.ConstantValueOpt == ConstantValue.False) return loweredRight; 357if (loweredRight.ConstantValueOpt == ConstantValue.False) return loweredLeft; 361if (loweredLeft.ConstantValueOpt == ConstantValue.True) 364if (loweredRight.ConstantValueOpt == ConstantValue.True) 623ConstantValue? constantLeft = loweredLeft.ConstantValueOpt ?? UnboxConstant(loweredLeft); 624if (testOperator == UnaryOperatorKind.DynamicFalse && constantLeft == ConstantValue.False || 625testOperator == UnaryOperatorKind.DynamicTrue && constantLeft == ConstantValue.True) 667bool leftTestIsConstantFalse = testOperator == UnaryOperatorKind.DynamicFalse && constantLeft == ConstantValue.True || 668testOperator == UnaryOperatorKind.DynamicTrue && constantLeft == ConstantValue.False; 709private static ConstantValue? UnboxConstant(BoundExpression expression) 745return new BoundUnaryOperator(syntax, UnaryOperatorKind.BoolLogicalNegation, converted, ConstantValue.NotAvailable, MethodSymbol.None, constrainedToTypeOpt: null, LookupResultKind.Viable, boolean) 803return MakeLiteral(syntax, ConstantValue.Create(kind.Operator() == BinaryOperatorKind.Equal), boolType); 830BoundExpression result = MakeLiteral(syntax, ConstantValue.Create(operatorKind == BinaryOperatorKind.NotEqual), boolType); 891return MakeLiteral(syntax, ConstantValue.Create(value), _compilation.GetSpecialType(SpecialType.System_Boolean)); 1181rewrittenAlternative: MakeLiteral(syntax, ConstantValue.Create(operatorKind == BinaryOperatorKind.Equal), boolType), 1548ConstantValue.NotAvailable, 1871return MakeLiteral(syntax, ConstantValue.Create(kind == BinaryOperatorKind.NullableNullEqual), returnType); 1910new BoundUnaryOperator(syntax, UnaryOperatorKind.BoolLogicalNegation, call, ConstantValue.NotAvailable, null, constrainedToTypeOpt: null, LookupResultKind.Viable, returnType); 1917if (oldNode != null && (loweredLeft.ConstantValueOpt == ConstantValue.Null || loweredRight.ConstantValueOpt == ConstantValue.Null)) 2011return MakeLiteral(syntax, ConstantValue.Create(rewrittenExpr.ConstantValueOpt.IsNull, ConstantValueTypeDiscriminator.Boolean), boolType); 2013return MakeLiteral(syntax, ConstantValue.Create(!rewrittenExpr.ConstantValueOpt.IsNull, ConstantValueTypeDiscriminator.Boolean), boolType); 2036MakeLiteral(syntax, ConstantValue.Null, objectType), 2056ConstantValue? rightConstantValue = loweredRight.ConstantValueOpt; 2069loweredRight = MakeLiteral(rightSyntax, ConstantValue.Create(shiftAmount), rightType); 2082MakeLiteral(rightSyntax, ConstantValue.Create(rightMask), rightType), 2128ConstantValue? rightConstantValue = loweredRight.ConstantValueOpt; 2202ConstantValue.NotAvailable, 2260var constVal = numericOperand.ConstantValueOpt; 2271var constVal = numericOperand.ConstantValueOpt;
Lowering\LocalRewriter\LocalRewriter_Call.cs (2)
1321BoundExpression arraySize = MakeLiteral(syntax, ConstantValue.Create(arrayArgs.Length), int32Type, localRewriter); 1334private static BoundExpression MakeLiteral(SyntaxNode syntax, ConstantValue constantValue, TypeSymbol type, LocalRewriter? localRewriter)
Lowering\LocalRewriter\LocalRewriter_ConditionalOperator.cs (4)
47ConstantValue? constantValueOpt, 51ConstantValue? conditionConstantValue = rewrittenCondition.ConstantValueOpt; 52if (conditionConstantValue == ConstantValue.True) 56else if (conditionConstantValue == ConstantValue.False)
Lowering\LocalRewriter\LocalRewriter_Conversion.cs (9)
262ConstantValue? constantValueOpt, 297ConstantValue? constantValueOpt, 701ConstantValue? constantValueOpt = null) 1177MakeConversionNode(null, syntax, conditional.Consequence, conversion, @checked, explicitCastInCode: false, constantValueOpt: ConstantValue.NotAvailable, rewrittenType: type), 1178MakeConversionNode(null, syntax, conditional.Alternative, conversion, @checked, explicitCastInCode: false, constantValueOpt: ConstantValue.NotAvailable, rewrittenType: type), 1179ConstantValue.NotAvailable, 1328ConstantValue? constantValueOpt, 1542private BoundExpression RewriteDecimalConversion(SyntaxNode syntax, BoundExpression operand, TypeSymbol fromType, TypeSymbol toType, bool @checked, bool isImplicit, ConstantValue? constantValueOpt) 1573private BoundExpression RewriteDecimalConversionCore(SyntaxNode syntax, BoundExpression operand, TypeSymbol fromType, TypeSymbol toType, bool isImplicit, ConstantValue? constantValueOpt)
Lowering\LocalRewriter\LocalRewriter_Event.cs (1)
214ConstantValue? constantValueOpt,
Lowering\LocalRewriter\LocalRewriter_Field.cs (1)
21ConstantValue? constantValueOpt,
Lowering\LocalRewriter\LocalRewriter_FixedStatement.cs (1)
538new BoundConditionalOperator(factory.Syntax, false, condition, consequenceAssignment, alternativeAssignment, ConstantValue.NotAvailable, localType, wasTargetTyped: false, localType));
Lowering\LocalRewriter\LocalRewriter_ForEachStatement.cs (6)
390right: MakeLiteral(forEachSyntax, constantValue: ConstantValue.Null, type: null), 555MakeLiteral(forEachSyntax, ConstantValue.Default(SpecialType.System_Int32), intType)); 734MakeLiteral(forEachSyntax, ConstantValue.Default(SpecialType.System_Int32), intType)); 872constantValue: ConstantValue.Create(dimension, ConstantValueTypeDiscriminator.Int32), 927constantValue: ConstantValue.Create(dimension, ConstantValueTypeDiscriminator.Int32), 1040constantValue: ConstantValue.Create(1),
Lowering\LocalRewriter\LocalRewriter_Index.cs (1)
18BoundExpression fromEnd = MakeLiteral(node.Syntax, ConstantValue.Create(true), booleanType);
Lowering\LocalRewriter\LocalRewriter_IsOperator.cs (6)
40return RewriteConstantIsOperator(receiver.Syntax, receiver, ConstantValue.False, rewrittenType); 44return MakeLiteral(syntax, ConstantValue.False, rewrittenType); 58ConstantValue constantValue = Binder.GetIsOperatorConstantResult(operandType, targetType, conversionKind, rewrittenOperand.ConstantValueOpt); 83ConstantValue constantValue, 86Debug.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_LockStatement.cs (2)
32Debug.Assert(rewrittenArgument.ConstantValueOpt == ConstantValue.Null); 100MakeLiteral(rewrittenArgument.Syntax, ConstantValue.False, boolType),
Lowering\LocalRewriter\LocalRewriter_PreviousSubmissionReference.cs (1)
24return new BoundFieldAccess(syntax, thisReference, targetScriptReference, ConstantValue.NotAvailable);
Lowering\LocalRewriter\LocalRewriter_StackAlloc.cs (2)
119var sizeConst = sizeOfExpression.ConstantValueOpt; 126var countConst = countExpression.ConstantValueOpt;
Lowering\LocalRewriter\LocalRewriter_StringConcat.cs (8)
198var rightConstant = boundCoalesce.RightOperand.ConstantValueOpt; 219var leftConst = loweredLeft.ConstantValueOpt; 220var rightConst = loweredRight.ConstantValueOpt; 226ConstantValue? concatenated = TryFoldTwoConcatConsts(leftConst, rightConst); 262private static ConstantValue? TryFoldTwoConcatConsts(ConstantValue leftConst, ConstantValue rightConst) 280return ConstantValue.Create(leftVal + rightVal);
Lowering\LocalRewriter\LocalRewriter_TupleBinaryOperator.cs (5)
206return new BoundLiteral(expr.Syntax, ConstantValue.Null, expr.Type); 259return new BoundLiteral(left.Syntax, ConstantValue.Create(nullnull.Kind == BinaryOperatorKind.Equal), boolType); 318if (rightHasValue.ConstantValueOpt == ConstantValue.False) 326if (leftHasValue.ConstantValueOpt == ConstantValue.False) 569return new BoundLiteral(left.Syntax, ConstantValue.Create(operatorKind == BinaryOperatorKind.Equal), boolType);
Lowering\LocalRewriter\LocalRewriter_UnaryOperator.cs (17)
89var constant = UnboxConstant(loweredOperand); 90if (constant == ConstantValue.True || constant == ConstantValue.False) 337ConstantValue.NotAvailable, 722(TypeSymbol binaryOperandType, ConstantValue constantOne) = GetConstantOneForIncrement(_compilation, binaryOperatorKind); 835return RewriteConditionalOperator(syntax, condition, consequence, alternative, ConstantValue.NotAvailable, operand.Type, isRef: false); 1067private static (TypeSymbol, ConstantValue) GetConstantOneForIncrement( 1071ConstantValue constantOne; 1076constantOne = ConstantValue.Create(1); 1079constantOne = ConstantValue.Create(1U); 1082constantOne = ConstantValue.Create(1L); 1085constantOne = ConstantValue.Create(1LU); 1088constantOne = ConstantValue.Create(1); 1091constantOne = ConstantValue.Create(1U); 1094constantOne = ConstantValue.Create(1f); 1097constantOne = ConstantValue.Create(1.0); 1100constantOne = ConstantValue.Create(1m);
Lowering\LocalRewriter\LocalRewriter_UsingStatement.cs (2)
127if (rewrittenExpression.ConstantValueOpt == ConstantValue.Null) 229if (boundLocal.ConstantValueOpt == ConstantValue.Null)
Lowering\StateMachineRewriter\ResumableStateMachineStateAllocator.cs (1)
92f.StringLiteral(ConstantValue.Create(message)))));
Lowering\SyntheticBoundNodeFactory.cs (21)
290return new BoundFieldAccess(Syntax, receiver, f, ConstantValue.NotAvailable, LookupResultKind.Viable, f.Type) { WasCompilerGenerated = true }; 530expression = BoundConversion.Synthesized(Syntax, expression, conversion, false, explicitCastInCode: false, conversionGroupOpt: null, ConstantValue.NotAvailable, CurrentFunction.ReturnType); 599return new BoundBinaryOperator(this.Syntax, kind, ConstantValue.NotAvailable, methodOpt: null, constrainedToTypeOpt: null, LookupResultKind.Viable, left, right, type) { WasCompilerGenerated = true }; 672return new BoundLiteral(Syntax, ConstantValue.Create(value), SpecialType(Microsoft.CodeAnalysis.SpecialType.System_Byte)) { WasCompilerGenerated = true }; 677return new BoundLiteral(Syntax, ConstantValue.Create(value), SpecialType(Microsoft.CodeAnalysis.SpecialType.System_Int32)) { WasCompilerGenerated = true }; 685return new BoundLiteral(Syntax, ConstantValue.Create(value), SpecialType(Microsoft.CodeAnalysis.SpecialType.System_UInt32)) { WasCompilerGenerated = true }; 688public BoundLiteral Literal(ConstantValue value, TypeSymbol type) 1013var caseBuilder = ArrayBuilder<(ConstantValue Value, LabelSymbol label)>.GetInstance(); 1024caseBuilder.Add((ConstantValue.Create(value), sectionLabel)); 1064return new BoundLiteral(Syntax, ConstantValue.Create(value), SpecialType(Microsoft.CodeAnalysis.SpecialType.System_Boolean)) { WasCompilerGenerated = true }; 1069var stringConst = ConstantValue.Create(value); 1073public BoundLiteral StringLiteral(ConstantValue stringConst) 1081return StringLiteral(ConstantValue.Create(stringValue)); 1084public BoundLiteral CharLiteral(ConstantValue charConst) 1092return CharLiteral(ConstantValue.Create(charValue)); 1169BoundExpression nullLiteral = new BoundLiteral(syntax, ConstantValue.Null, type) { WasCompilerGenerated = true }; 1639return Literal(ConstantValue.Create(rewrittenExpr.ConstantValueOpt.IsNull, ConstantValueTypeDiscriminator.Boolean), boolType); 1641return Literal(ConstantValue.Create(rewrittenExpr.ConstantValueOpt.IsNull, ConstantValueTypeDiscriminator.Boolean), boolType); 1661return RewriteNullableNullEquality(syntax, operatorKind, rewrittenExpr, Literal(ConstantValue.Null, objectType), boolType); 1742new BoundUnaryOperator(syntax, UnaryOperatorKind.BoolLogicalNegation, call, ConstantValue.NotAvailable, methodOpt: null, constrainedToTypeOpt: null, LookupResultKind.Viable, returnType);
Operations\CSharpOperationFactory.cs (21)
304ConstantValue? constantValue = (boundNode as BoundExpression)?.ConstantValueOpt; 442ConstantValue? constantValue = boundCall.ConstantValueOpt; 555ConstantValue? constantValue = boundLocal.ConstantValueOpt; 575ConstantValue? constantValue = boundFieldAccess.ConstantValueOpt; 675ConstantValue? constantValue = boundLiteral.ConstantValueOpt; 703ConstantValue? constantValue = boundObjectCreationExpression.ConstantValueOpt; 924ConstantValue? constantValue = boundCollectionElementInitializer.ConstantValueOpt; 1109ConstantValue? constantValue = boundConversion.ConstantValueOpt; 1183ConstantValue? constantValue = boundSizeOfOperator.ConstantValueOpt; 1220ConstantValue? constantValue = boundDefaultLiteral.ConstantValueOpt; 1229ConstantValue? constantValue = ((BoundExpression)boundDefaultExpression).ConstantValueOpt; 1272ConstantValue? constantValue = boundAssignmentOperator.ConstantValueOpt; 1371ConstantValue? constantValue = boundUnaryOperator.ConstantValueOpt; 1425ConstantValue? constantValue = boundBinaryOperator.ConstantValueOpt; 1457ConstantValue? constantValue = boundBinaryOperator.ConstantValueOpt; 1513ConstantValue? constantValue = boundConditionalOperator.ConstantValueOpt; 1524ConstantValue? constantValue = boundNullCoalescingOperator.ConstantValueOpt; 1595ConstantValue constantValue = boundNameOfOperator.ConstantValueOpt; 1732ConstantValue? constantValue = null; 2149ConstantValue? constantValue = boundInterpolatedString.ConstantValueOpt; 2755var constantValue = field.GetConstantValue(ConstantFieldsInProgress.Empty, earlyDecodingWellKnownAttributes: false);
Symbols\AnonymousTypes\AnonymousTypeField.cs (2)
27public readonly ConstantValue? DefaultValue; 42ConstantValue? defaultValue = null,
Symbols\AnonymousTypes\SynthesizedSymbols\AnonymousType.FieldSymbol.cs (1)
100internal override ConstantValue GetConstantValue(ConstantFieldsInProgress inProgress, bool earlyDecodingWellKnownAttributes)
Symbols\ConstantValueUtils.cs (9)
17public readonly ConstantValue Value; 20public EvaluatedConstant(ConstantValue value, ImmutableBindingDiagnostic<AssemblySymbol> diagnostics) 29public static ConstantValue EvaluateFieldConstant( 50var value = GetAndValidateConstantValue(boundValue.Value, symbol, symbol.Type, initValueNodeLocation, diagnostics); 79internal static ConstantValue GetAndValidateConstantValue( 86var value = ConstantValue.Bad; 107var constantValue = boundValue.ConstantValueOpt; 109var unconvertedConstantValue = unconvertedBoundValue.ConstantValueOpt;
Symbols\FieldSymbol.cs (3)
158ConstantValue constantValue = GetConstantValue(ConstantFieldsInProgress.Empty, earlyDecodingWellKnownAttributes: false); 176ConstantValue constantValue = GetConstantValue(ConstantFieldsInProgress.Empty, earlyDecodingWellKnownAttributes: false); 181internal abstract ConstantValue GetConstantValue(ConstantFieldsInProgress inProgress, bool earlyDecodingWellKnownAttributes);
Symbols\FunctionPointers\FunctionPointerParameterSymbol.cs (1)
79internal override ConstantValue? ExplicitDefaultConstantValue => null;
Symbols\LocalSymbol.cs (3)
323ConstantValue constantValue = this.GetConstantValue(null, null, null); 341ConstantValue constantValue = this.GetConstantValue(null, null, null); 354internal abstract ConstantValue GetConstantValue(SyntaxNode node, LocalSymbol inProgress, BindingDiagnosticBag diagnostics = null);
Symbols\Metadata\PE\PEFieldSymbol.cs (8)
121private ConstantValue _lazyConstantValue = Microsoft.CodeAnalysis.ConstantValue.Unset; // Indicates an uninitialized ConstantValue 480internal override ConstantValue GetConstantValue(ConstantFieldsInProgress inProgress, bool earlyDecodingWellKnownAttributes) 482if (_lazyConstantValue == Microsoft.CodeAnalysis.ConstantValue.Unset) 484ConstantValue value = null; 495ConstantValue defaultValue; 506Microsoft.CodeAnalysis.ConstantValue.Unset); 599ConstantValue value;
Symbols\Metadata\PE\PEParameterSymbol.cs (12)
160private ConstantValue? _lazyDefaultValue = ConstantValue.Unset; 261_lazyDefaultValue = ConstantValue.NotAvailable; 515internal ConstantValue? ImportConstantValue(bool ignoreAttributes = false) 522ConstantValue? value = null; 537internal override ConstantValue? ExplicitDefaultConstantValue 542if (_lazyDefaultValue == ConstantValue.Unset) 547ConstantValue? value = ImportConstantValue(ignoreAttributes: !IsMetadataOptional); 548Interlocked.CompareExchange(ref _lazyDefaultValue, value, ConstantValue.Unset); 555private ConstantValue? GetDefaultDecimalOrDateTimeValue() 558ConstantValue? value = null; 1023ConstantValue defaultValue = this.ExplicitDefaultConstantValue;
Symbols\ParameterSymbol.cs (1)
241internal abstract ConstantValue? ExplicitDefaultConstantValue { get; }
Symbols\ReducedExtensionMethodSymbol.cs (2)
139var thisArgumentValue = new BoundLiteral(syntax, ConstantValue.Bad, thisType) { WasCompilerGenerated = true }; 141var otherArgumentValue = new BoundLiteral(syntax, ConstantValue.Bad, otherArgumentType) { WasCompilerGenerated = true };
Symbols\SignatureOnlyParameterSymbol.cs (1)
70internal override ConstantValue ExplicitDefaultConstantValue { get { throw ExceptionUtilities.Unreachable(); } }
Symbols\Source\FieldSymbolWithAttributesAndModifiers.cs (4)
264private void VerifyConstantValueMatches(ConstantValue attrValue, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 269ConstantValue constValue; 288if (data.ConstValue == CodeAnalysis.ConstantValue.Unset) 297if (constValue != CodeAnalysis.ConstantValue.Unset)
Symbols\Source\GlobalExpressionVariable.cs (1)
62protected override ConstantValue MakeConstantValue(
Symbols\Source\SourceClonedParameterSymbol.cs (2)
67internal override ConstantValue ExplicitDefaultConstantValue 76internal override ConstantValue DefaultValueFromAttributes
Symbols\Source\SourceComplexParameterSymbol.cs (34)
37protected ConstantValue _lazyDefaultSyntaxValue; 73_lazyDefaultSyntaxValue = ConstantValue.Unset; 84internal sealed override ConstantValue ExplicitDefaultConstantValue 102internal sealed override ConstantValue DefaultValueFromAttributes 107return (data != null && data.DefaultParameterValue != ConstantValue.Unset) ? data.DefaultParameterValue : ConstantValue.NotAvailable; 235private ConstantValue DefaultSyntaxValue 243var previousValue = Interlocked.CompareExchange( 246ConstantValue.Unset); 247Debug.Assert(previousValue == ConstantValue.Unset); 265DefaultValueFromAttributes == ConstantValue.NotAvailable) 324var defaultValue = DefaultValueFromAttributes; 353private ConstantValue MakeDefaultExpression(BindingDiagnosticBag diagnostics, out Binder? binder, out BoundParameterEqualsValue? parameterEqualsValue) 361return ConstantValue.NotAvailable; 367return ConstantValue.NotAvailable; 380return ConstantValue.Bad; 387return ConstantValue.Bad; 404var value = convertedExpression.ConstantValueOpt ?? ConstantValue.Null; 705ConstantValue value; 708value = ConstantValue.Bad; 717if (paramData.DefaultParameterValue == ConstantValue.Unset) 889var value = DecodeDefaultParameterValueAttribute(description, attribute, syntax, diagnose: true, diagnosticsOpt: diagnostics); 901private void VerifyParamDefaultValueMatchesAttributeIfAny(ConstantValue value, SyntaxNode syntax, BindingDiagnosticBag diagnostics) 906var attrValue = data.DefaultParameterValue; 907if ((attrValue != ConstantValue.Unset) && 916private ConstantValue DecodeDefaultParameterValueAttribute(AttributeDescription description, CSharpAttributeData attribute, AttributeSyntax node, bool diagnose, BindingDiagnosticBag diagnosticsOpt) 935private ConstantValue DecodeDefaultParameterValueAttribute(CSharpAttributeData attribute, AttributeSyntax node, bool diagnose, BindingDiagnosticBag diagnosticsOpt) 946return ConstantValue.Bad; 967var constantValueDiscriminator = ConstantValue.GetDiscriminator(specialType); 984return ConstantValue.Bad; 994return ConstantValue.Bad; 1005return ConstantValue.Bad; 1013return ConstantValue.Create(arg.ValueInternal, constantValueDiscriminator);
Symbols\Source\SourceEnumConstantSymbol.cs (9)
151protected override ConstantValue MakeConstantValue(HashSet<SourceFieldSymbolWithSyntaxReference> dependencies, bool earlyDecodingWellKnownAttributes, BindingDiagnosticBag diagnostics) 154return Microsoft.CodeAnalysis.ConstantValue.Default(constantType); 172protected override ConstantValue MakeConstantValue(HashSet<SourceFieldSymbolWithSyntaxReference> dependencies, bool earlyDecodingWellKnownAttributes, BindingDiagnosticBag diagnostics) 198protected override ConstantValue MakeConstantValue(HashSet<SourceFieldSymbolWithSyntaxReference> dependencies, bool earlyDecodingWellKnownAttributes, BindingDiagnosticBag diagnostics) 200var otherValue = _otherConstant.GetConstantValue(new ConstantFieldsInProgress(this, dependencies), earlyDecodingWellKnownAttributes); 203if (otherValue == Microsoft.CodeAnalysis.ConstantValue.Unset) 205return Microsoft.CodeAnalysis.ConstantValue.Unset; 209return Microsoft.CodeAnalysis.ConstantValue.Bad; 211ConstantValue value;
Symbols\Source\SourceFieldSymbol.cs (21)
174private ConstantValue _lazyConstantEarlyDecodingValue = Microsoft.CodeAnalysis.ConstantValue.Unset; 175private ConstantValue _lazyConstantValue = Microsoft.CodeAnalysis.ConstantValue.Unset; 248internal sealed override ConstantValue GetConstantValue(ConstantFieldsInProgress inProgress, bool earlyDecodingWellKnownAttributes) 250var value = this.GetLazyConstantValue(earlyDecodingWellKnownAttributes); 251if (value != Microsoft.CodeAnalysis.ConstantValue.Unset) 262return Microsoft.CodeAnalysis.ConstantValue.Unset; 293var value = this.GetLazyConstantValue(earlyDecodingWellKnownAttributes); 294if (value != Microsoft.CodeAnalysis.ConstantValue.Unset) 313(value != Microsoft.CodeAnalysis.ConstantValue.Unset) && 335if (this.GetLazyConstantValue(earlyDecodingWellKnownAttributes) != Microsoft.CodeAnalysis.ConstantValue.Unset) 347var value = MakeConstantValue(builder, earlyDecodingWellKnownAttributes, diagnostics); 357private ConstantValue GetLazyConstantValue(bool earlyDecodingWellKnownAttributes) 363ConstantValue value, 368Debug.Assert(value != Microsoft.CodeAnalysis.ConstantValue.Unset); 369Debug.Assert((GetLazyConstantValue(earlyDecodingWellKnownAttributes) == Microsoft.CodeAnalysis.ConstantValue.Unset) || 374Interlocked.CompareExchange(ref _lazyConstantEarlyDecodingValue, value, Microsoft.CodeAnalysis.ConstantValue.Unset); 378if (Interlocked.CompareExchange(ref _lazyConstantValue, value, Microsoft.CodeAnalysis.ConstantValue.Unset) == Microsoft.CodeAnalysis.ConstantValue.Unset) 392protected abstract ConstantValue MakeConstantValue(HashSet<SourceFieldSymbolWithSyntaxReference> dependencies, bool earlyDecodingWellKnownAttributes, BindingDiagnosticBag diagnostics);
Symbols\Source\SourceFixedFieldSymbol.cs (1)
97ConstantValue sizeConstant = ConstantValueUtils.GetAndValidateConstantValue(boundSizeExpression, this, intType, sizeExpression.Location, diagnostics);
Symbols\Source\SourceLabelSymbol.cs (4)
21private readonly ConstantValue? _switchCaseLabelConstant; 29ConstantValue? switchCaseLabelConstant = null) 70ConstantValue switchCaseLabelConstant) 138public ConstantValue? SwitchCaseLabelConstant
Symbols\Source\SourceLocalSymbol.cs (5)
471internal override ConstantValue GetConstantValue(SyntaxNode node, LocalSymbol inProgress, BindingDiagnosticBag diagnostics) 561var value = Microsoft.CodeAnalysis.ConstantValue.Bad; 577internal override ConstantValue GetConstantValue(SyntaxNode node, LocalSymbol inProgress, BindingDiagnosticBag diagnostics = null) 586return Microsoft.CodeAnalysis.ConstantValue.Bad;
Symbols\Source\SourceMemberFieldSymbol.cs (4)
108var value = this.GetConstantValue(ConstantFieldsInProgress.Empty, earlyDecodingWellKnownAttributes: false); 116if (data == null || data.ConstValue == CodeAnalysis.ConstantValue.Unset) 138!(decodedData is FieldWellKnownAttributeData fieldData && fieldData.ConstValue != CodeAnalysis.ConstantValue.Unset)) 619protected sealed override ConstantValue MakeConstantValue(HashSet<SourceFieldSymbolWithSyntaxReference> dependencies, bool earlyDecodingWellKnownAttributes, BindingDiagnosticBag diagnostics)
Symbols\Source\SourceParameterSymbolBase.cs (4)
67internal abstract ConstantValue DefaultValueFromAttributes { get; } 81var defaultValue = this.ExplicitDefaultConstantValue; 82if (defaultValue != ConstantValue.NotAvailable && 84DefaultValueFromAttributes == ConstantValue.NotAvailable)
Symbols\Source\SourceSimpleParameterSymbol.cs (3)
30internal override ConstantValue? ExplicitDefaultConstantValue 127internal override ConstantValue DefaultValueFromAttributes 129get { return ConstantValue.NotAvailable; }
Symbols\Source\ThisParameterSymbol.cs (1)
73internal override ConstantValue? ExplicitDefaultConstantValue
Symbols\Synthesized\SynthesizedBackingFieldSymbol.cs (1)
60internal override ConstantValue GetConstantValue(ConstantFieldsInProgress inProgress, bool earlyDecodingWellKnownAttributes)
Symbols\Synthesized\SynthesizedDelegateSymbol.cs (2)
35internal ParameterDescription(TypeWithAnnotations type, RefKind refKind, ScopedKind scope, ConstantValue? defaultValue, bool isParams, bool hasUnscopedRefAttribute) 48internal readonly ConstantValue? DefaultValue;
Symbols\Synthesized\SynthesizedFieldSymbolBase.cs (1)
135internal override ConstantValue GetConstantValue(ConstantFieldsInProgress inProgress, bool earlyDecodingWellKnownAttributes)
Symbols\Synthesized\SynthesizedLocal.cs (1)
187internal sealed override ConstantValue GetConstantValue(SyntaxNode node, LocalSymbol inProgress, BindingDiagnosticBag diagnostics)
Symbols\Synthesized\SynthesizedParameterSymbol.cs (10)
78internal override ConstantValue? ExplicitDefaultConstantValue 83internal virtual ConstantValue? DefaultValueFromAttributes => null; 194var defaultValue = this.ExplicitDefaultConstantValue; 195if (defaultValue != ConstantValue.NotAvailable && 196DefaultValueFromAttributes == ConstantValue.NotAvailable && 242ConstantValue? defaultValue = null, 320private readonly ConstantValue? _defaultValue; 330ConstantValue? defaultValue, 388internal override ConstantValue? ExplicitDefaultConstantValue => _baseParameterForAttributes?.ExplicitDefaultConstantValue ?? _defaultValue; 390internal override ConstantValue? DefaultValueFromAttributes => _baseParameterForAttributes?.DefaultValueFromAttributes;
Symbols\Synthesized\TypeSubstitutedLocalSymbol.cs (1)
113internal override ConstantValue GetConstantValue(SyntaxNode node, LocalSymbol inProgress, BindingDiagnosticBag diagnostics)
Symbols\TypedConstantExtensions.cs (6)
54ConstantValue valueConstant = ConstantValue.Create(constant.ValueInternal, splType); 89ConstantValue memberConstant = ConstantValue.Create(field.ConstantValue, specialType); 167ConstantValue memberConstant = ConstantValue.Create(field.ConstantValue, specialType);
Symbols\TypeSymbolExtensions.cs (3)
556public static ConstantValue? GetDefaultValue(this TypeSymbol type) 573return ConstantValue.Null; 597return ConstantValue.Default(type.SpecialType);
Symbols\UpdatedContainingSymbolLocal.cs (1)
93internal override ConstantValue GetConstantValue(SyntaxNode node, LocalSymbol inProgress, BindingDiagnosticBag? diagnostics = null) =>
Symbols\Wrapped\WrappedFieldSymbol.cs (1)
179internal override ConstantValue GetConstantValue(ConstantFieldsInProgress inProgress, bool earlyDecodingWellKnownAttributes)
Symbols\Wrapped\WrappedParameterSymbol.cs (1)
79internal sealed override ConstantValue? ExplicitDefaultConstantValue
Utilities\IValueSet.cs (5)
39bool Any(BinaryOperatorKind relation, ConstantValue value); 43/// Because of that all four combinations of results from <see cref="Any(BinaryOperatorKind, ConstantValue)"/> and <see cref="All(BinaryOperatorKind, ConstantValue)"/> 48bool All(BinaryOperatorKind relation, ConstantValue value); 59ConstantValue? Sample { get; }
Utilities\IValueSetFactory.cs (4)
18IValueSet Related(BinaryOperatorKind relation, ConstantValue value); 23bool Related(BinaryOperatorKind relation, ConstantValue left, ConstantValue right); 33ConstantValue RandomValue(Random random);
Utilities\ValueSetFactory.BoolValueSet.cs (4)
41ConstantValue IValueSet.Sample => ConstantValue.Create(_hasTrue ? true : _hasFalse ? false : throw new ArgumentException()); 56bool IValueSet.Any(BinaryOperatorKind relation, ConstantValue value) => value.IsBad || Any(relation, value.BooleanValue); 71bool IValueSet.All(BinaryOperatorKind relation, ConstantValue value) => !value.IsBad && All(relation, value.BooleanValue);
Utilities\ValueSetFactory.BoolValueSetFactory.cs (5)
51ConstantValue IValueSetFactory.RandomValue(Random random) => ConstantValue.Create(random.NextDouble() < 0.5); 53IValueSet IValueSetFactory.Related(BinaryOperatorKind relation, ConstantValue value) 58bool IValueSetFactory.Related(BinaryOperatorKind relation, ConstantValue left, ConstantValue right)
Utilities\ValueSetFactory.ByteTC.cs (3)
53byte INumericTC<byte>.FromConstantValue(ConstantValue constantValue) => constantValue.IsBad ? (byte)0 : constantValue.ByteValue; 55ConstantValue INumericTC<byte>.ToConstantValue(byte value) => ConstantValue.Create(value);
Utilities\ValueSetFactory.CharTC.cs (3)
48char INumericTC<char>.FromConstantValue(ConstantValue constantValue) => constantValue.IsBad ? (char)0 : constantValue.CharValue; 66ConstantValue INumericTC<char>.ToConstantValue(char value) => ConstantValue.Create(value);
Utilities\ValueSetFactory.DecimalTC.cs (3)
33public decimal FromConstantValue(ConstantValue constantValue) => constantValue.IsBad ? 0m : constantValue.DecimalValue; 35public ConstantValue ToConstantValue(decimal value) => ConstantValue.Create(value);
Utilities\ValueSetFactory.DecimalValueSetFactory.cs (5)
25ConstantValue IValueSetFactory.RandomValue(Random random) => ConstantValue.Create(default(DecimalTC).Random(random)); 27IValueSet IValueSetFactory.Related(BinaryOperatorKind relation, ConstantValue value) => 30bool IValueSetFactory.Related(BinaryOperatorKind relation, ConstantValue left, ConstantValue right) => _underlying.Related(relation, left, right);
Utilities\ValueSetFactory.DoubleTC.cs (3)
81double INumericTC<double>.FromConstantValue(ConstantValue constantValue) => constantValue.IsBad ? 0.0 : constantValue.DoubleValue; 83ConstantValue INumericTC<double>.ToConstantValue(double value) => ConstantValue.Create(value);
Utilities\ValueSetFactory.EnumeratedValueSet.cs (3)
41ConstantValue IValueSet.Sample 82bool IValueSet.Any(BinaryOperatorKind relation, ConstantValue value) => value.IsBad || Any(relation, default(TTC).FromConstantValue(value)); 105bool IValueSet.All(BinaryOperatorKind relation, ConstantValue value) => !value.IsBad && All(relation, default(TTC).FromConstantValue(value));
Utilities\ValueSetFactory.EnumeratedValueSetFactory.cs (4)
39IValueSet IValueSetFactory.Related(BinaryOperatorKind relation, ConstantValue value) => 42bool IValueSetFactory.Related(BinaryOperatorKind relation, ConstantValue left, ConstantValue right) 61ConstantValue IValueSetFactory.RandomValue(Random random)
Utilities\ValueSetFactory.FloatingValueSet.cs (4)
51ConstantValue IValueSet.Sample 60var sample = _numbers.Sample; 131bool IValueSet.Any(BinaryOperatorKind relation, ConstantValue value) => 142bool IValueSet.All(BinaryOperatorKind relation, ConstantValue value) => !value.IsBad && All(relation, default(TFloatingTC).FromConstantValue(value));
Utilities\ValueSetFactory.FloatingValueSetFactory.cs (4)
27ConstantValue IValueSetFactory.RandomValue(Random random) 33IValueSet IValueSetFactory.Related(BinaryOperatorKind relation, ConstantValue value) => 36bool IValueSetFactory.Related(BinaryOperatorKind relation, ConstantValue left, ConstantValue right)
Utilities\ValueSetFactory.IEqualableValueTC.cs (4)
18/// Get the constant value of type <typeparamref name="T"/> from a <see cref="ConstantValue"/>. This method is shared among all 21T FromConstantValue(ConstantValue constantValue); 24/// Translate a numeric value of type <typeparamref name="T"/> into a <see cref="ConstantValue"/>. 26ConstantValue ToConstantValue(T value);
Utilities\ValueSetFactory.IntTC.cs (3)
53public int FromConstantValue(ConstantValue constantValue) => constantValue.IsBad ? 0 : constantValue.Int32Value; 55public ConstantValue ToConstantValue(int value) => ConstantValue.Create(value);
Utilities\ValueSetFactory.INumericTC.cs (4)
18/// Get the constant value of type <typeparamref name="T"/> from a <see cref="ConstantValue"/>. This method is shared among all 21T FromConstantValue(ConstantValue constantValue); 24/// Translate a numeric value of type <typeparamref name="T"/> into a <see cref="ConstantValue"/>. 26ConstantValue ToConstantValue(T value);
Utilities\ValueSetFactory.LongTC.cs (3)
53long INumericTC<long>.FromConstantValue(ConstantValue constantValue) => constantValue.IsBad ? 0L : constantValue.Int64Value; 55ConstantValue INumericTC<long>.ToConstantValue(long value) => ConstantValue.Create(value);
Utilities\ValueSetFactory.NintValueSet.cs (3)
48ConstantValue? IValueSet.Sample 74bool IValueSet.All(BinaryOperatorKind relation, ConstantValue value) => value.IsBad || All(relation, value.Int32Value); 85bool IValueSet.Any(BinaryOperatorKind relation, ConstantValue value) => value.IsBad || Any(relation, value.Int32Value);
Utilities\ValueSetFactory.NintValueSetFactory.cs (5)
41ConstantValue IValueSetFactory.RandomValue(Random random) => ConstantValue.CreateNativeInt(default(IntTC).Random(random)); 43IValueSet IValueSetFactory.Related(BinaryOperatorKind relation, ConstantValue value) 48bool IValueSetFactory.Related(BinaryOperatorKind relation, ConstantValue left, ConstantValue right)
Utilities\ValueSetFactory.NonNegativeIntTC.cs (3)
53public int FromConstantValue(ConstantValue constantValue) 59public ConstantValue ToConstantValue(int value) 61return ConstantValue.Create(value);
Utilities\ValueSetFactory.NonNegativeIntValueSetFactory.cs (4)
55ConstantValue IValueSetFactory.RandomValue(Random random) => _underlying.RandomValue(random); 57IValueSet IValueSetFactory.Related(BinaryOperatorKind relation, ConstantValue value) => 60bool IValueSetFactory.Related(BinaryOperatorKind relation, ConstantValue left, ConstantValue right) => _underlying.Related(relation, left, right);
Utilities\ValueSetFactory.NuintValueSet.cs (3)
39ConstantValue? IValueSet.Sample 63bool IValueSet.All(BinaryOperatorKind relation, ConstantValue value) => value.IsBad || All(relation, value.UInt32Value); 72bool IValueSet.Any(BinaryOperatorKind relation, ConstantValue value) => value.IsBad || Any(relation, value.UInt32Value);
Utilities\ValueSetFactory.NuintValueSetFactory.cs (5)
39ConstantValue IValueSetFactory.RandomValue(Random random) => ConstantValue.CreateNativeUInt(default(UIntTC).Random(random)); 41IValueSet IValueSetFactory.Related(BinaryOperatorKind relation, ConstantValue value) 46bool IValueSetFactory.Related(BinaryOperatorKind relation, ConstantValue left, ConstantValue right)
Utilities\ValueSetFactory.NumericValueSet.cs (3)
55ConstantValue IValueSet.Sample 108bool IValueSet.Any(BinaryOperatorKind relation, ConstantValue value) => value.IsBad || Any(relation, default(TTC).FromConstantValue(value)); 131bool IValueSet.All(BinaryOperatorKind relation, ConstantValue value) => !value.IsBad && All(relation, default(TTC).FromConstantValue(value));
Utilities\ValueSetFactory.NumericValueSetFactory.cs (4)
53IValueSet IValueSetFactory.Related(BinaryOperatorKind relation, ConstantValue value) => 59ConstantValue IValueSetFactory.RandomValue(Random random) 65bool IValueSetFactory.Related(BinaryOperatorKind relation, ConstantValue left, ConstantValue right)
Utilities\ValueSetFactory.SByteTC.cs (3)
53sbyte INumericTC<sbyte>.FromConstantValue(ConstantValue constantValue) => constantValue.IsBad ? (sbyte)0 : constantValue.SByteValue; 55public ConstantValue ToConstantValue(sbyte value) => ConstantValue.Create(value);
Utilities\ValueSetFactory.ShortTC.cs (3)
53short INumericTC<short>.FromConstantValue(ConstantValue constantValue) => constantValue.IsBad ? (short)0 : constantValue.Int16Value; 55ConstantValue INumericTC<short>.ToConstantValue(short value) => ConstantValue.Create(value);
Utilities\ValueSetFactory.SingleTC.cs (3)
85float INumericTC<float>.FromConstantValue(ConstantValue constantValue) => constantValue.IsBad ? 0.0F : constantValue.SingleValue; 87ConstantValue INumericTC<float>.ToConstantValue(float value) => ConstantValue.Create(value);
Utilities\ValueSetFactory.StringTC.cs (3)
14string IEquatableValueTC<string>.FromConstantValue(ConstantValue constantValue) 41ConstantValue IEquatableValueTC<string>.ToConstantValue(string value) => ConstantValue.Create(value);
Utilities\ValueSetFactory.UIntTC.cs (3)
47public uint FromConstantValue(ConstantValue constantValue) => constantValue.IsBad ? (uint)0 : constantValue.UInt32Value; 49public ConstantValue ToConstantValue(uint value) => ConstantValue.Create(value);
Utilities\ValueSetFactory.ULongTC.cs (3)
53ulong INumericTC<ulong>.FromConstantValue(ConstantValue constantValue) => constantValue.IsBad ? 0UL : constantValue.UInt64Value; 55ConstantValue INumericTC<ulong>.ToConstantValue(ulong value) => ConstantValue.Create(value);
Utilities\ValueSetFactory.UShortTC.cs (3)
47ushort INumericTC<ushort>.FromConstantValue(ConstantValue constantValue) => constantValue.IsBad ? (ushort)0 : constantValue.UInt16Value; 49ConstantValue INumericTC<ushort>.ToConstantValue(ushort value) => ConstantValue.Create(value);
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (1)
CodeGen\CodeGenOverridingAndHiding.cs (1)
4119Assert.Equal(ConstantValue.Null, parameterB.ExplicitDefaultConstantValue);
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (3)
Attributes\AttributeTests_WellKnownAttributes.cs (2)
530var constantValue = peModule.Module.GetParamDefaultValue(theParameter.Handle); 531Assert.Equal(ConstantValue.Null, constantValue);
Emit\NumericIntPtrTests.cs (1)
2854var value = field.GetConstantValue(ConstantFieldsInProgress.Empty, earlyDecodingWellKnownAttributes: false);
Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ExpressionCompiler (17)
CSharpEESymbolProvider.cs (2)
63ConstantValue value, 85public override void DecodeLocalConstant(ref BlobReader reader, out TypeSymbol type, out ConstantValue value)
Rewriters\LocalDeclarationRewriter.cs (6)
110var name = new BoundLiteral(syntax, ConstantValue.Create(local.Name), stringType); 129var value = ConstantValue.Create(CustomTypeInfo.PayloadTypeId.ToString()); 146return new BoundLiteral(syntax, ConstantValue.Null, byteArrayType); 156initializerExprs.Add(new BoundLiteral(syntax, ConstantValue.Create(b), byteType)); 159var lengthExpr = new BoundLiteral(syntax, ConstantValue.Create(numBytes), intType);
Symbols\DisplayClassVariable.cs (1)
209internal override ConstantValue GetConstantValue(ConstantFieldsInProgress inProgress, bool earlyDecodingWellKnownAttributes)
Symbols\EELocalConstantSymbol.cs (4)
18private readonly ConstantValue _value; 24ConstantValue value) 33ConstantValue value) 87internal override ConstantValue GetConstantValue(SyntaxNode node, LocalSymbol inProgress, BindingDiagnosticBag diagnostics)
Symbols\EELocalSymbolBase.cs (1)
36internal override ConstantValue GetConstantValue(SyntaxNode node, LocalSymbol inProgress, BindingDiagnosticBag diagnostics)
Symbols\ObjectAddressLocalSymbol.cs (1)
36Microsoft.CodeAnalysis.ConstantValue.Create(_address),
Symbols\ObjectIdLocalSymbol.cs (1)
89Microsoft.CodeAnalysis.ConstantValue.Create(name),
Symbols\ReturnValueLocalSymbol.cs (1)
33Microsoft.CodeAnalysis.ConstantValue.Create(_index),
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (55)
Semantics\ConstantTests.cs (26)
1463private static object ExtractValue(ConstantValue constantValue) 2301ConstantValue nonNullValue = ConstantValue.Create(10); 2302ConstantValue nullValue = null; 2310private static void ConstantEquals(ConstantValue a, ConstantValue b) 3988ConstantValue charConstant = ConstantValue.Create('c'), 3989byteConst = ConstantValue.Create(0x4), 3990sbyteConst = ConstantValue.Create(unchecked((sbyte)byte.MaxValue)), 3991shortConst = ConstantValue.Create(unchecked((short)ushort.MaxValue)), 3992ushortConst = ConstantValue.Create(ushort.MaxValue), 3993int32Const = ConstantValue.Create(unchecked((int)uint.MaxValue)), 3994uint32Const = ConstantValue.Create(uint.MaxValue), 3995nintConst = ConstantValue.CreateNativeInt(unchecked((int)uint.MaxValue)), 3996nuintConst = ConstantValue.CreateNativeUInt(uint.MaxValue), 3997int64Const = ConstantValue.Create(unchecked((long)ulong.MaxValue)), 3998uint64Const = ConstantValue.Create(ulong.MaxValue), 3999decimalConst = ConstantValue.Create(1m / 3m), 4000floatConst = ConstantValue.Create(Math.Round(1f / 3f, 5)), 4001doubleConst = ConstantValue.Create(Math.Round((double)1 / 3, 8)), 4002stringConst = ConstantValue.Create("abcdefghijklmnopqrstuvwxyz"), 4003dateTimeConst = ConstantValue.Create(DateTime.MaxValue), 4004boolConst = ConstantValue.Create(true), 4005badConst = ConstantValue.Bad, 4006nullConst = ConstantValue.Null;
Semantics\NamedAndOptionalTests.cs (25)
2061Assert.Equal(ConstantValue.Create(0), parameters[1].ExplicitDefaultConstantValue); 2067Assert.Equal(ConstantValue.Create(1), parameters[2].ExplicitDefaultConstantValue); 2080Assert.Equal(ConstantValue.Create(0), parameters[4].ExplicitDefaultConstantValue); 2087Assert.Equal(ConstantValue.Create(1), parameters[5].ExplicitDefaultConstantValue); 2093Assert.Equal(ConstantValue.Create(0), parameters[6].ExplicitDefaultConstantValue); 2099Assert.Equal(ConstantValue.Create(1), parameters[7].ExplicitDefaultConstantValue); 2143Assert.Equal(ConstantValue.Null, parameters[1].ExplicitDefaultConstantValue); 2194Assert.Equal(ConstantValue.Null, parameters[1].ExplicitDefaultConstantValue); 2200Assert.Equal(ConstantValue.Create("A"), parameters[2].ExplicitDefaultConstantValue); 2213Assert.Equal(ConstantValue.Null, parameters[4].ExplicitDefaultConstantValue); 2219Assert.Equal(ConstantValue.Null, parameters[5].ExplicitDefaultConstantValue); 2226Assert.Equal(ConstantValue.Create("A"), parameters[6].ExplicitDefaultConstantValue); 2232Assert.Equal(ConstantValue.Create("A"), parameters[7].ExplicitDefaultConstantValue); // not imported for non-optional parameter 2277Assert.Equal(ConstantValue.Create(0M), parameters[1].ExplicitDefaultConstantValue); 2283Assert.Equal(ConstantValue.Create(1M), parameters[2].ExplicitDefaultConstantValue); 2296Assert.Equal(isFromSource ? ConstantValue.Create(0M) : null, parameters[4].ExplicitDefaultConstantValue); // not imported for non-optional parameter 2303Assert.Equal(isFromSource ? ConstantValue.Create(1M) : null, parameters[5].ExplicitDefaultConstantValue); // not imported for non-optional parameter 2309Assert.Equal(ConstantValue.Create(0M), parameters[6].ExplicitDefaultConstantValue); 2315Assert.Equal(ConstantValue.Create(1M), parameters[7].ExplicitDefaultConstantValue); 2359Assert.Equal(ConstantValue.Null, parameters[1].ExplicitDefaultConstantValue); 2372Assert.Equal(isFromSource ? ConstantValue.Create(new DateTime(0)) : null, parameters[3].ExplicitDefaultConstantValue); // not imported for non-optional parameter 2379Assert.Equal(isFromSource ? ConstantValue.Create(new DateTime(1)) : null, parameters[4].ExplicitDefaultConstantValue); // not imported for non-optional parameter 2385Assert.Equal(ConstantValue.Create(new DateTime(0)), parameters[5].ExplicitDefaultConstantValue); 2391Assert.Equal(ConstantValue.Create(new DateTime(1)), parameters[6].ExplicitDefaultConstantValue); 2463Assert.Equal(ConstantValue.Bad, param.ExplicitDefaultConstantValue);
Semantics\NativeIntegerTests.cs (1)
7026var value = field.GetConstantValue(ConstantFieldsInProgress.Empty, earlyDecodingWellKnownAttributes: false);
Utilities\ValueSetTests.cs (3)
626ConstantValue value = fac.RandomValue(Random); 875ConstantValue badConstant = ConstantValue.Bad;
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (101)
Compilation\GetSemanticInfoTests.cs (99)
888EnumOffset(ConstantValue.Create((sbyte)sbyte.MinValue), 1, EnumOverflowKind.NoOverflow, ConstantValue.Create((sbyte)(sbyte.MinValue + 1))); 889EnumOffset(ConstantValue.Create((sbyte)sbyte.MinValue), 2, EnumOverflowKind.NoOverflow, ConstantValue.Create((sbyte)(sbyte.MinValue + 2))); 890EnumOffset(ConstantValue.Create((sbyte)-2), 1, EnumOverflowKind.NoOverflow, ConstantValue.Create((sbyte)(-1))); 891EnumOffset(ConstantValue.Create((sbyte)-2), 3, EnumOverflowKind.NoOverflow, ConstantValue.Create((sbyte)(1))); 892EnumOffset(ConstantValue.Create((sbyte)(sbyte.MaxValue - 3)), 3, EnumOverflowKind.NoOverflow, ConstantValue.Create((sbyte)sbyte.MaxValue)); 893EnumOffset(ConstantValue.Create((sbyte)(sbyte.MaxValue - 3)), 4, EnumOverflowKind.OverflowReport, ConstantValue.Bad); 894EnumOffset(ConstantValue.Create((sbyte)(sbyte.MaxValue - 3)), 5, EnumOverflowKind.OverflowIgnore, ConstantValue.Bad); 897EnumOffset(ConstantValue.Create((byte)0), 1, EnumOverflowKind.NoOverflow, ConstantValue.Create((byte)1)); 898EnumOffset(ConstantValue.Create((byte)0), 2, EnumOverflowKind.NoOverflow, ConstantValue.Create((byte)2)); 899EnumOffset(ConstantValue.Create((byte)(byte.MaxValue - 3)), 3, EnumOverflowKind.NoOverflow, ConstantValue.Create((byte)byte.MaxValue)); 900EnumOffset(ConstantValue.Create((byte)(byte.MaxValue - 3)), 4, EnumOverflowKind.OverflowReport, ConstantValue.Bad); 901EnumOffset(ConstantValue.Create((byte)(byte.MaxValue - 3)), 5, EnumOverflowKind.OverflowIgnore, ConstantValue.Bad); 904EnumOffset(ConstantValue.Create((short)short.MinValue), 1, EnumOverflowKind.NoOverflow, ConstantValue.Create((short)(short.MinValue + 1))); 905EnumOffset(ConstantValue.Create((short)short.MinValue), 2, EnumOverflowKind.NoOverflow, ConstantValue.Create((short)(short.MinValue + 2))); 906EnumOffset(ConstantValue.Create((short)-2), 1, EnumOverflowKind.NoOverflow, ConstantValue.Create((short)(-1))); 907EnumOffset(ConstantValue.Create((short)-2), 3, EnumOverflowKind.NoOverflow, ConstantValue.Create((short)(1))); 908EnumOffset(ConstantValue.Create((short)(short.MaxValue - 3)), 3, EnumOverflowKind.NoOverflow, ConstantValue.Create((short)short.MaxValue)); 909EnumOffset(ConstantValue.Create((short)(short.MaxValue - 3)), 4, EnumOverflowKind.OverflowReport, ConstantValue.Bad); 910EnumOffset(ConstantValue.Create((short)(short.MaxValue - 3)), 5, EnumOverflowKind.OverflowIgnore, ConstantValue.Bad); 913EnumOffset(ConstantValue.Create((ushort)0), 1, EnumOverflowKind.NoOverflow, ConstantValue.Create((ushort)1)); 914EnumOffset(ConstantValue.Create((ushort)0), 2, EnumOverflowKind.NoOverflow, ConstantValue.Create((ushort)2)); 915EnumOffset(ConstantValue.Create((ushort)(ushort.MaxValue - 3)), 3, EnumOverflowKind.NoOverflow, ConstantValue.Create((ushort)ushort.MaxValue)); 916EnumOffset(ConstantValue.Create((ushort)(ushort.MaxValue - 3)), 4, EnumOverflowKind.OverflowReport, ConstantValue.Bad); 917EnumOffset(ConstantValue.Create((ushort)(ushort.MaxValue - 3)), 5, EnumOverflowKind.OverflowIgnore, ConstantValue.Bad); 920EnumOffset(ConstantValue.Create((int)int.MinValue), 1, EnumOverflowKind.NoOverflow, ConstantValue.Create((int)(int.MinValue + 1))); 921EnumOffset(ConstantValue.Create((int)int.MinValue), 2, EnumOverflowKind.NoOverflow, ConstantValue.Create((int)(int.MinValue + 2))); 922EnumOffset(ConstantValue.Create((int)-2), 1, EnumOverflowKind.NoOverflow, ConstantValue.Create((int)(-1))); 923EnumOffset(ConstantValue.Create((int)-2), 3, EnumOverflowKind.NoOverflow, ConstantValue.Create((int)(1))); 924EnumOffset(ConstantValue.Create((int)(int.MaxValue - 3)), 3, EnumOverflowKind.NoOverflow, ConstantValue.Create((int)int.MaxValue)); 925EnumOffset(ConstantValue.Create((int)(int.MaxValue - 3)), 4, EnumOverflowKind.OverflowReport, ConstantValue.Bad); 926EnumOffset(ConstantValue.Create((int)(int.MaxValue - 3)), 5, EnumOverflowKind.OverflowIgnore, ConstantValue.Bad); 929EnumOffset(ConstantValue.Create((uint)0), 1, EnumOverflowKind.NoOverflow, ConstantValue.Create((uint)1)); 930EnumOffset(ConstantValue.Create((uint)0), 2, EnumOverflowKind.NoOverflow, ConstantValue.Create((uint)2)); 931EnumOffset(ConstantValue.Create((uint)(uint.MaxValue - 3)), 3, EnumOverflowKind.NoOverflow, ConstantValue.Create((uint)uint.MaxValue)); 932EnumOffset(ConstantValue.Create((uint)(uint.MaxValue - 3)), 4, EnumOverflowKind.OverflowReport, ConstantValue.Bad); 933EnumOffset(ConstantValue.Create((uint)(uint.MaxValue - 3)), 5, EnumOverflowKind.OverflowIgnore, ConstantValue.Bad); 936EnumOffset(ConstantValue.Create((long)long.MinValue), 1, EnumOverflowKind.NoOverflow, ConstantValue.Create((long)(long.MinValue + 1))); 937EnumOffset(ConstantValue.Create((long)long.MinValue), 2, EnumOverflowKind.NoOverflow, ConstantValue.Create((long)(long.MinValue + 2))); 938EnumOffset(ConstantValue.Create((long)-2), 1, EnumOverflowKind.NoOverflow, ConstantValue.Create((long)(-1))); 939EnumOffset(ConstantValue.Create((long)-2), 3, EnumOverflowKind.NoOverflow, ConstantValue.Create((long)(1))); 940EnumOffset(ConstantValue.Create((long)(long.MaxValue - 3)), 3, EnumOverflowKind.NoOverflow, ConstantValue.Create((long)long.MaxValue)); 941EnumOffset(ConstantValue.Create((long)(long.MaxValue - 3)), 4, EnumOverflowKind.OverflowReport, ConstantValue.Bad); 942EnumOffset(ConstantValue.Create((long)(long.MaxValue - 3)), 5, EnumOverflowKind.OverflowIgnore, ConstantValue.Bad); 945EnumOffset(ConstantValue.Create((ulong)0), 1, EnumOverflowKind.NoOverflow, ConstantValue.Create((ulong)1)); 946EnumOffset(ConstantValue.Create((ulong)0), 2, EnumOverflowKind.NoOverflow, ConstantValue.Create((ulong)2)); 947EnumOffset(ConstantValue.Create((ulong)(ulong.MaxValue - 3)), 3, EnumOverflowKind.NoOverflow, ConstantValue.Create((ulong)ulong.MaxValue)); 948EnumOffset(ConstantValue.Create((ulong)(ulong.MaxValue - 3)), 4, EnumOverflowKind.OverflowReport, ConstantValue.Bad); 949EnumOffset(ConstantValue.Create((ulong)(ulong.MaxValue - 3)), 5, EnumOverflowKind.OverflowIgnore, ConstantValue.Bad); 952private void EnumOffset(ConstantValue constantValue, uint offset, EnumOverflowKind expectedOverflowKind, ConstantValue expectedValue) 954ConstantValue actualValue;
Compilation\SemanticModelAPITests.cs (1)
1929Assert.Equal(ConstantValue.Default(SpecialType.System_Int32), labelSymbol.SwitchCaseLabelConstant);
Compilation\SemanticModelGetDeclaredSymbolAPITests.cs (1)
724Assert.Equal(ConstantValue.Default(SpecialType.System_Int32), labelSymbol.SwitchCaseLabelConstant);
Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler (26)
EESymbolProvider.cs (2)
28public abstract void DecodeLocalConstant(ref BlobReader reader, out TTypeSymbol type, out ConstantValue value); 42ConstantValue value,
PDB\MethodDebugInfo.Native.cs (1)
661ConstantValue constantValue = PdbHelpers.GetSymConstantValue(type, rawValue);
PDB\MethodDebugInfo.Portable.cs (1)
205symbolProvider.DecodeLocalConstant(ref sigReader, out var typeSymbol, out var value);
PDB\PdbHelpers.cs (22)
78/// Translates the value of a constant returned by <see cref="ISymUnmanagedConstant.GetValue(out object)"/> to a <see cref="ConstantValue"/>. 80public static ConstantValue GetSymConstantValue(ITypeSymbolInternal type, object symValue) 89(SpecialType.System_Boolean, short shortVal) => ConstantValue.Create(shortVal != 0), 90(SpecialType.System_Byte, short shortVal) when unchecked((byte)shortVal) == shortVal => ConstantValue.Create((byte)shortVal), 91(SpecialType.System_SByte, short shortVal) when unchecked((sbyte)shortVal) == shortVal => ConstantValue.Create((sbyte)shortVal), 92(SpecialType.System_Int16, short shortVal) => ConstantValue.Create(shortVal), 93(SpecialType.System_Char, ushort ushortVal) => ConstantValue.Create((char)ushortVal), 94(SpecialType.System_UInt16, ushort ushortVal) => ConstantValue.Create(ushortVal), 95(SpecialType.System_Int32, int intVal) => ConstantValue.Create(intVal), 96(SpecialType.System_UInt32, uint uintVal) => ConstantValue.Create(uintVal), 97(SpecialType.System_Int64, long longVal) => ConstantValue.Create(longVal), 98(SpecialType.System_UInt64, ulong ulongVal) => ConstantValue.Create(ulongVal), 99(SpecialType.System_Single, float floatVal) => ConstantValue.Create(floatVal), 100(SpecialType.System_Double, double doubleVal) => ConstantValue.Create(doubleVal), 101(SpecialType.System_String, 0) => ConstantValue.Null, 102(SpecialType.System_String, null) => ConstantValue.Create(string.Empty), 103(SpecialType.System_String, string str) => ConstantValue.Create(str), 104(SpecialType.System_Object, 0) => ConstantValue.Null, 105(SpecialType.System_Decimal, decimal decimalValue) => ConstantValue.Create(decimalValue), 106(SpecialType.System_DateTime, double doubleVal) => ConstantValue.Create(DateTimeUtilities.ToDateTime(doubleVal)), 107(SpecialType.None, 0) when type.IsReferenceType => ConstantValue.Null, 108_ => ConstantValue.Bad,
Microsoft.CodeAnalysis.Test.Utilities (2)
Diagnostics\CouldHaveMoreSpecificTypeAnalyzer.cs (2)
68var constantValue = ConstantValue.Create(1);
Microsoft.CodeAnalysis.UnitTests (63)
CorLibTypesTests.cs (63)
94Assert.Throws<InvalidOperationException>(() => { ConstantValue.Create(null, ConstantValueTypeDiscriminator.Bad); }); 96var cv = ConstantValue.Create(1); 101var cv1 = ConstantValue.Create(null, ConstantValueTypeDiscriminator.Null); 113Assert.Equal(ConstantValue.Bad, ConstantValue.Default(ConstantValueTypeDiscriminator.Bad)); 115var cv1 = ConstantValue.Create((sbyte)-1); 118var cv2 = ConstantValue.Create(-0.12345f); 121var cv3 = ConstantValue.Create((double)-1.234); 124var cv4 = ConstantValue.Create((decimal)-12345m); 128var cv5 = ConstantValue.Create(null); 137var cv11 = ConstantValue.Create((sbyte)-1); 138var cv12 = ConstantValue.Create((sbyte)-1); 141var cv21 = ConstantValue.Create((byte)255); 142var cv22 = ConstantValue.Create((byte)255); 145var cv31 = ConstantValue.Create((short)-32768); 146var cv32 = ConstantValue.Create((short)-32768); 149var cv41 = ConstantValue.Create((ushort)65535); 150var cv42 = ConstantValue.Create((ushort)65535); 153var cv51 = ConstantValue.Create(12345); 154var cv52 = ConstantValue.Create(12345); 157var cv61 = ConstantValue.Create(uint.MinValue); 158var cv62 = ConstantValue.Create(uint.MinValue); 161var cv71 = ConstantValue.Create(long.MaxValue); 162var cv72 = ConstantValue.Create(long.MaxValue); 165var cv81 = ConstantValue.Create((ulong)123456789); 166var cv82 = ConstantValue.Create((ulong)123456789); 169var cv91 = ConstantValue.Create(1.1m); 170var cv92 = ConstantValue.Create(1.1m); 184var cv1 = ConstantValue.Create("1"); 185var cv2 = ConstantValue.Create("2"); 199var cv = ConstantValue.Create(null, ConstantValueTypeDiscriminator.Null); 202cv = ConstantValue.Create(null, ConstantValueTypeDiscriminator.String); 208cv = ConstantValue.Create(strVal); 211cv = ConstantValue.Create((sbyte)-128); 214cv = ConstantValue.Create((ulong)123456789);
Microsoft.CodeAnalysis.VisualBasic (510)
Analysis\InitializerRewriter.vb (2)
77New BoundLiteral(syntax, ConstantValue.Null, Nothing), 225submissionResult = New BoundLiteral(method.Syntax, ConstantValue.Nothing, submissionResultType)
Binding\Binder_Conversions.vb (1)
1163Return New BoundConversion(tree, argument, convKind.Key, CheckOverflow, isExplicit, DirectCast(Nothing, ConstantValue), targetType)
Binding\Binder_Expressions.vb (15)
744Return New BoundNameOfOperator(node, argument, ConstantValue.Create(value), GetSpecialType(SpecialType.System_String, node, diagnostics)) 1952Dim constVal As ConstantValue = Nothing 2026Dim constVal As ConstantValue 2122constantValueOpt As ConstantValue, 3720ConstantValue.Create(node.Name.Identifier.ValueText), 3740Dim arg = New BoundLiteral(name, ConstantValue.Create(node.Name.Identifier.ValueText), GetSpecialType(SpecialType.System_String, name, diagnostics)) 3759Dim arg = New BoundLiteral(name, ConstantValue.Create(node.Name.Identifier.ValueText), GetSpecialType(SpecialType.System_String, name, diagnostics)) 3801ConstantValue.Create(node.Name.Identifier.ValueText), 4111ConstantValue.Create(size.Size), 4295Dim lowerBoundConstantValueOpt As ConstantValue = lowerBound.ConstantValueOpt 4377Dim upperBoundConstantValueOpt As ConstantValue = upperBound.ConstantValueOpt 4387Dim one = New BoundLiteral(argumentSyntax, ConstantValue.Create(1), int32Type) 4425Dim cv As ConstantValue 4430cv = ConstantValue.Null 4441cv = ConstantValue.Create(value, specialType)
Binding\Binder_Initializers.vb (3)
496<Out> ByRef constValue As ConstantValue 593<Out> ByRef constValue As ConstantValue) As BoundExpression 648<Out> ByRef constValue As ConstantValue
Binding\Binder_Invocation.vb (19)
902Dim constantValue As ConstantValue = Nothing 1088) As ConstantValue 1121Return ConstantValue.Create(AscW(argumentValue)) 1135Return ConstantValue.Create(ChrW(argumentValue)) 1164Return ConstantValue.Create(charValue) 1176Return ConstantValue.Create(ChrW(argumentValue)) 2724ConstantValue.Create(items.Count), 3108Dim defaultConstantValue As ConstantValue = If(param.IsOptional, param.ExplicitDefaultConstantValue(DefaultParametersInProgress), Nothing) 3124Dim callerInfoValue As ConstantValue = Nothing 3127callerInfoValue = ConstantValue.Create(callerInfoOpt.SyntaxTree.GetDisplayLineNumber(GetCallerLocation(callerInfoOpt))) 3155callerInfoValue = ConstantValue.Create(container.Name) 3158callerInfoValue = ConstantValue.Create(callerInfoOpt.SyntaxTree.GetDisplayPath(callerInfoOpt.Span, Me.Compilation.Options.SourceReferenceResolver)) 3174callerInfoValue = ConstantValue.Create(argumentSyntax.ToString()) 3207defaultConstantValue = ConstantValue.Null 3223defaultConstantValue = ConstantValue.Create(1) 3225defaultConstantValue = ConstantValue.Default(SpecialType.System_Int32) 3260defaultArgument = New BoundLiteral(syntax, ConstantValue.Null, Nothing) 3272Dim argument = New BoundLiteral(syntax, ConstantValue.Null, param.Type).MakeCompilerGenerated() 3280defaultArgument = New BoundLiteral(syntax, ConstantValue.Null, Nothing)
Binding\Binder_Operators.vb (6)
487Dim value As ConstantValue = Nothing 515value = ConstantValue.Bad 543Dim nothingStr = New BoundLiteral(left.Syntax, ConstantValue.Nothing, stringType).MakeCompilerGenerated() 796constantValueOpt:=ConstantValue.Nothing) 1187Dim constantValue As ConstantValue = Nothing 1199constantValue = constantValue.Bad
Binding\Binder_SelectCase.vb (2)
687Private Shared Function IsInvalidSelectCaseRange(lbConstantValue As ConstantValue, ubConstantValue As ConstantValue) As Boolean
Binding\Binder_Statements.vb (5)
771Dim nothingLiteral = New BoundLiteral(operand, ConstantValue.Nothing, Nothing).MakeCompilerGenerated() 3135ConstantValue.Create(1), 3470New BoundLiteral(collectionSyntax, ConstantValue.Nothing, Nothing), 3492New BoundLiteral(collectionSyntax, ConstantValue.Nothing, Nothing), 4592New BoundLiteral(syntaxNode, ConstantValue.Nothing, Nothing),
Binding\Binder_Utils.vb (3)
1299Public Function GetExpressionConstantValueIfAny(boundExpression As BoundExpression, diagnostics As BindingDiagnosticBag, context As ConstantContext) As ConstantValue 1391Private Function CheckConversionForConstantExpression(conv As BoundExpression, operand As BoundExpression, diagnostics As BindingDiagnosticBag, context As ConstantContext) As ConstantValue 1423Dim nestedConstValue As ConstantValue = GetExpressionConstantValueIfAny(operand, diagnostics, context)
Binding\Binder_XmlLiterals.vb (2)
42ImmutableArray.Create(Of BoundExpression)(declaration, New BoundLiteral(syntax, ConstantValue.Nothing, Nothing)), 1057Dim result = New BoundLiteral(syntax, ConstantValue.Create(str), GetSpecialType(SpecialType.System_String, syntax, diagnostics), hasErrors:=hasErrors)
Binding\MemberSemanticModel.vb (1)
897Friend Overrides Function GetExpressionConstantValue(node As ExpressionSyntax, Optional cancellationToken As CancellationToken = Nothing) As ConstantValue
Binding\SyntheticBoundTrees\AnonymousTypeSyntheticMethods.vb (8)
131expression = New BoundLiteral(syntax, ConstantValue.Create(hashBase), integerType).MakeCompilerGenerated() 133Dim factorLiteral = New BoundLiteral(syntax, ConstantValue.Create(&HA5555529), integerType).MakeCompilerGenerated() 134Dim zeroLiteral = New BoundLiteral(syntax, ConstantValue.Create(0), integerType).MakeCompilerGenerated() 135Dim nothingLiteral = New BoundLiteral(syntax, ConstantValue.Nothing, objectType).MakeCompilerGenerated() 205Dim nothingLiteral = New BoundLiteral(syntax, ConstantValue.Nothing, objectType).MakeCompilerGenerated() 367New BoundLiteral(syntax, ConstantValue.Create(numberOfFields), 375New BoundLiteral(syntax, ConstantValue.Nothing, 377New BoundLiteral(syntax, ConstantValue.Create(formatString),
Binding\SyntheticBoundTrees\SynthesizedPropertyAccessorBase.vb (2)
263New BoundLiteral(syntax, ConstantValue.Nothing, 343New BoundLiteral(syntax, ConstantValue.Nothing,
Binding\SyntheticBoundTrees\SynthesizedStringSwitchHashMethod.vb (4)
96F.Assignment(F.Local(hashCode, True), New BoundLiteral(Me.Syntax, ConstantValue.Create(CUInt(2166136261)), hashCode.Type)), 102F.Assignment(F.Local(i, True), New BoundLiteral(Me.Syntax, ConstantValue.Create(0), i.Type)), 111New BoundLiteral(Me.Syntax, ConstantValue.Create(CUInt(16777619)), hashCode.Type))), 116New BoundLiteral(Me.Syntax, ConstantValue.Create(1), i.Type))),
BoundTree\BoundCall.vb (2)
18constantValueOpt As ConstantValue, 37constantValueOpt As ConstantValue,
BoundTree\BoundConversion.vb (1)
31constantValueOpt As ConstantValue,
BoundTree\BoundDirectCast.vb (1)
34Public Sub New(syntax As SyntaxNode, operand As BoundExpression, conversionKind As ConversionKind, constantValueOpt As ConstantValue, type As TypeSymbol, Optional hasErrors As Boolean = False)
BoundTree\BoundExpression.vb (2)
18Public Overridable ReadOnly Property ConstantValueOpt As ConstantValue 73Protected Shared Sub ValidateConstantValue(type As TypeSymbol, constValue As ConstantValue)
BoundTree\BoundExpressionExtensions.vb (4)
27Dim constValue As ConstantValue = node.ConstantValueOpt 394Return expr.ConstantValueOpt Is ConstantValue.True 402Return expr.ConstantValueOpt Is ConstantValue.False 493Dim constantValue As ConstantValue
BoundTree\BoundFieldAccess.vb (2)
36Public Overrides ReadOnly Property ConstantValueOpt As ConstantValue 44Dim result As ConstantValue
BoundTree\BoundLiteral.vb (1)
12Public Overrides ReadOnly Property ConstantValueOpt As ConstantValue
BoundTree\BoundLocal.vb (2)
39Public Overrides ReadOnly Property ConstantValueOpt As ConstantValue 47Dim result As ConstantValue = LocalSymbol.GetConstantValue(Nothing)
BoundTree\BoundParenthesized.vb (1)
19Public Overrides ReadOnly Property ConstantValueOpt As ConstantValue
BoundTree\BoundTryCast.vb (1)
33Public Sub New(syntax As SyntaxNode, operand As BoundExpression, conversionKind As ConversionKind, constantValueOpt As ConstantValue, type As TypeSymbol, Optional hasErrors As Boolean = False)
CodeGen\EmitArrayInitializer.vb (3)
179Private Function AsConstOrDefault(init As BoundExpression) As ConstantValue 180Dim initConstantValueOpt As ConstantValue = init.ConstantValueOpt 187Return ConstantValue.Default(type.SpecialType)
CodeGen\EmitConversion.vb (1)
78_builder.EmitConstantValue(ConstantValue.Default(underlyingFrom.GetConstantValueTypeDiscriminator()))
CodeGen\EmitExpression.vb (1)
1586Private Sub EmitConstantExpression(type As TypeSymbol, constantValue As ConstantValue, used As Boolean, syntaxNode As SyntaxNode)
CodeGen\EmitOperators.vb (4)
313_builder.EmitConstantValue(ConstantValue.Create(shiftMax)) 328_builder.EmitConstantValue(ConstantValue.Create(shiftMax)) 557Private Sub EmitIsNotNullOrZero(comparand As BoundExpression, nullOrZero As ConstantValue) 569Private Sub EmitIsNullOrZero(comparand As BoundExpression, nullOrZero As ConstantValue)
CodeGen\EmitStatement.vb (11)
504Dim constOp As ConstantValue = condition.Left.ConstantValueOpt 939Dim caseLabelsForEmit As KeyValuePair(Of ConstantValue, Object)() = GetCaseLabelsForEmitSwitchHeader(caseBlocks, caseBlockLabels, fallThroughLabel) 973) As KeyValuePair(Of ConstantValue, Object)() 979Dim labelsBuilder = ArrayBuilder(Of KeyValuePair(Of ConstantValue, Object)).GetInstance() 980Dim constantsSet = New HashSet(Of ConstantValue)(New SwitchConstantValueHelper.SwitchLabelsComparer()) 990Dim constant As ConstantValue 1024labelsBuilder.Add(New KeyValuePair(Of ConstantValue, Object)(constant, caseBlockLabel)) 1041Private Sub EmitSwitchTableHeader(selectExpression As BoundExpression, caseLabels As KeyValuePair(Of ConstantValue, Object)(), fallThroughLabel As LabelSymbol) 1086Private Sub EmitStringSwitchJumpTable(caseLabels As KeyValuePair(Of ConstantValue, Object)(), fallThroughLabel As LabelSymbol, key As LocalDefinition, syntaxNode As SyntaxNode) 1147Private Sub EmitStringCompareAndBranch(key As LocalOrParameter, syntaxNode As SyntaxNode, stringConstant As ConstantValue, targetLabel As Object, stringCompareMethodRef As Microsoft.Cci.IReference) 1176_builder.EmitConstantValue(ConstantValue.False)
CodeGen\ResumableStateMachineStateAllocator.vb (1)
88f.StringLiteral(ConstantValue.Create(message)))))
Compilation\SemanticModel.vb (5)
89Friend MustOverride Function GetExpressionConstantValue(node As ExpressionSyntax, Optional cancellationToken As CancellationToken = Nothing) As ConstantValue 387Dim val As ConstantValue = GetExpressionConstantValue(expression, cancellationToken) 415Dim val As ConstantValue = Me.GetConstantValueForNode(bnodeSummary) 425Friend Function GetConstantValueForNode(boundNodes As BoundNodeSummary) As ConstantValue 426Dim constValue As ConstantValue = Nothing
Compilation\SpeculativeSemanticModelWithMemberModel.vb (1)
245Friend Overrides Function GetExpressionConstantValue(node As ExpressionSyntax, Optional cancellationToken As CancellationToken = Nothing) As ConstantValue
Compilation\SpeculativeSyntaxTreeSemanticModel.vb (1)
109Friend Overrides Function GetExpressionConstantValue(node As ExpressionSyntax, Optional cancellationToken As CancellationToken = Nothing) As ConstantValue
Compilation\SyntaxTreeSemanticModel.vb (1)
343Friend Overrides Function GetExpressionConstantValue(node As ExpressionSyntax, Optional cancellationToken As CancellationToken = Nothing) As ConstantValue
Compilation\VisualBasicCompilation.vb (2)
1890Friend Overrides Function ClassifyConvertibleConversion(source As IOperation, destination As ITypeSymbol, ByRef constantValue As ConstantValue) As IConvertibleConversion 1899Dim sourceConstantValue As ConstantValue = source.GetConstantValue()
Generated\BoundNodes.xml.Generated.vb (41)
1358Public Sub New(syntax As SyntaxNode, operatorKind As UnaryOperatorKind, operand As BoundExpression, checked As Boolean, constantValueOpt As ConstantValue, type As TypeSymbol, Optional hasErrors As Boolean = False) 1397Private ReadOnly _ConstantValueOpt As ConstantValue 1398Public Overrides ReadOnly Property ConstantValueOpt As ConstantValue 1409Public Function Update(operatorKind As UnaryOperatorKind, operand As BoundExpression, checked As Boolean, constantValueOpt As ConstantValue, type As TypeSymbol) As BoundUnaryOperator 1510Public Sub New(syntax As SyntaxNode, operatorKind As BinaryOperatorKind, left As BoundExpression, right As BoundExpression, checked As Boolean, constantValueOpt As ConstantValue, type As TypeSymbol, Optional hasErrors As Boolean = False) 1558Private ReadOnly _ConstantValueOpt As ConstantValue 1559Public Overrides ReadOnly Property ConstantValueOpt As ConstantValue 1570Public Function Update(operatorKind As BinaryOperatorKind, left As BoundExpression, right As BoundExpression, checked As Boolean, constantValueOpt As ConstantValue, type As TypeSymbol) As BoundBinaryOperator 1908Public Sub New(syntax As SyntaxNode, condition As BoundExpression, whenTrue As BoundExpression, whenFalse As BoundExpression, constantValueOpt As ConstantValue, type As TypeSymbol, Optional hasErrors As Boolean = False) 1949Private ReadOnly _ConstantValueOpt As ConstantValue 1950Public Overrides ReadOnly Property ConstantValueOpt As ConstantValue 1961Public Function Update(condition As BoundExpression, whenTrue As BoundExpression, whenFalse As BoundExpression, constantValueOpt As ConstantValue, type As TypeSymbol) As BoundTernaryConditionalExpression 1974Public Sub New(syntax As SyntaxNode, testExpression As BoundExpression, convertedTestExpression As BoundExpression, testExpressionPlaceholder As BoundRValuePlaceholder, elseExpression As BoundExpression, constantValueOpt As ConstantValue, type As TypeSymbol, Optional hasErrors As Boolean = False) 2022Private ReadOnly _ConstantValueOpt As ConstantValue 2023Public Overrides ReadOnly Property ConstantValueOpt As ConstantValue 2034Public Function Update(testExpression As BoundExpression, convertedTestExpression As BoundExpression, testExpressionPlaceholder As BoundRValuePlaceholder, elseExpression As BoundExpression, constantValueOpt As ConstantValue, type As TypeSymbol) As BoundBinaryConditionalExpression 2066Public Sub New(syntax As SyntaxNode, operand As BoundExpression, conversionKind As ConversionKind, checked As Boolean, explicitCastInCode As Boolean, constantValueOpt As ConstantValue, extendedInfoOpt As BoundExtendedConversionInfo, type As TypeSymbol, Optional hasErrors As Boolean = False) 2114Private ReadOnly _ConstantValueOpt As ConstantValue 2115Public Overrides ReadOnly Property ConstantValueOpt As ConstantValue 2133Public Function Update(operand As BoundExpression, conversionKind As ConversionKind, checked As Boolean, explicitCastInCode As Boolean, constantValueOpt As ConstantValue, extendedInfoOpt As BoundExtendedConversionInfo, type As TypeSymbol) As BoundConversion 2297Public Sub New(syntax As SyntaxNode, operand As BoundExpression, conversionKind As ConversionKind, suppressVirtualCalls As Boolean, constantValueOpt As ConstantValue, relaxationLambdaOpt As BoundLambda, type As TypeSymbol, Optional hasErrors As Boolean = False) 2337Private ReadOnly _ConstantValueOpt As ConstantValue 2338Public Overrides ReadOnly Property ConstantValueOpt As ConstantValue 2356Public Function Update(operand As BoundExpression, conversionKind As ConversionKind, suppressVirtualCalls As Boolean, constantValueOpt As ConstantValue, relaxationLambdaOpt As BoundLambda, type As TypeSymbol) As BoundDirectCast 2369Public Sub New(syntax As SyntaxNode, operand As BoundExpression, conversionKind As ConversionKind, constantValueOpt As ConstantValue, relaxationLambdaOpt As BoundLambda, type As TypeSymbol, Optional hasErrors As Boolean = False) 2401Private ReadOnly _ConstantValueOpt As ConstantValue 2402Public Overrides ReadOnly Property ConstantValueOpt As ConstantValue 2420Public Function Update(operand As BoundExpression, conversionKind As ConversionKind, constantValueOpt As ConstantValue, relaxationLambdaOpt As BoundLambda, type As TypeSymbol) As BoundTryCast 3017Public Sub New(syntax As SyntaxNode, method As MethodSymbol, methodGroupOpt As BoundMethodGroup, receiverOpt As BoundExpression, arguments As ImmutableArray(Of BoundExpression), defaultArguments As BitVector, constantValueOpt As ConstantValue, isLValue As Boolean, suppressObjectClone As Boolean, type As TypeSymbol, Optional hasErrors As Boolean = False) 3075Private ReadOnly _ConstantValueOpt As ConstantValue 3076Public Overrides ReadOnly Property ConstantValueOpt As ConstantValue 3101Public Function Update(method As MethodSymbol, methodGroupOpt As BoundMethodGroup, receiverOpt As BoundExpression, arguments As ImmutableArray(Of BoundExpression), defaultArguments As BitVector, constantValueOpt As ConstantValue, isLValue As Boolean, suppressObjectClone As Boolean, type As TypeSymbol) As BoundCall 5881Public Sub New(syntax As SyntaxNode, value As ConstantValue, type As TypeSymbol, hasErrors As Boolean) 5894Public Sub New(syntax As SyntaxNode, value As ConstantValue, type As TypeSymbol) 5905Private ReadOnly _Value As ConstantValue 5906Public ReadOnly Property Value As ConstantValue 5917Public Function Update(value As ConstantValue, type As TypeSymbol) As BoundLiteral 9119Public Sub New(syntax As SyntaxNode, argument As BoundExpression, constantValueOpt As ConstantValue, type As TypeSymbol, Optional hasErrors As Boolean = False) 9142Private ReadOnly _ConstantValueOpt As ConstantValue 9143Public Overrides ReadOnly Property ConstantValueOpt As ConstantValue 9154Public Function Update(argument As BoundExpression, constantValueOpt As ConstantValue, type As TypeSymbol) As BoundNameOfOperator
Lowering\AsyncRewriter\AsyncRewriter.CapturedSymbolOrExpression.vb (2)
43Private ReadOnly _constValue As ConstantValue 46Public Sub New(constValue As ConstantValue, type As TypeSymbol)
Lowering\ExpressionLambdaRewriter\ExpressionLambdaRewriter_BinaryOperator.vb (1)
463Private Function MaskShiftCountOperand(loweredOperand As BoundExpression, shiftedType As TypeSymbol, shiftMask As Integer, shiftConst As ConstantValue, isChecked As Boolean) As BoundExpression
Lowering\LambdaRewriter\LambdaRewriter.vb (1)
441New BoundLiteral(syntaxNode, ConstantValue.Nothing, obj),
Lowering\LocalRewriter\LocalRewriter.vb (2)
485constantValueOpt As ConstantValue, 703Dim constValue As ConstantValue = value.ConstantValueOpt
Lowering\LocalRewriter\LocalRewriter_AssignmentOperator.vb (1)
490If(midResult.LengthOpt, New BoundLiteral(node.Syntax, ConstantValue.Create(&H7FFFFFFF), midResult.Start.Type)),
Lowering\LocalRewriter\LocalRewriter_BinaryOperators.vb (11)
496New BoundLiteral(node.Syntax, ConstantValue.Create(0I), memberSymbol.ReturnType), 535New BoundLiteral(node.Syntax, ConstantValue.Create(0I), memberSymbol.ReturnType), 705New BoundLiteral(node.Syntax, ConstantValue.Create(compareText), memberSymbol.Parameters(2).Type)), 710compare, New BoundLiteral(node.Syntax, ConstantValue.Create(0I), memberSymbol.ReturnType), 737New BoundLiteral(node.Syntax, ConstantValue.Create(compareText), memberSymbol.Parameters(2).Type)), 770New BoundLiteral(node.Syntax, ConstantValue.Create(If(compareText, 1I, 0I)), memberSymbol.Parameters(2).Type)), 1043Dim result = New BoundLiteral(node.Syntax, ConstantValue.False, node.Type.GetNullableUnderlyingType()) 1332ConstantValue.True, 1333ConstantValue.False), 1339ConstantValue.False, 1340ConstantValue.True),
Lowering\LocalRewriter\LocalRewriter_Constant.vb (10)
16Private Function RewriteConstant(node As BoundExpression, constantValue As ConstantValue) As BoundExpression 31Private Shared Function RewriteDecimalConstant(node As BoundExpression, nodeValue As ConstantValue, currentMethod As MethodSymbol, diagnostics As BindingDiagnosticBag) As BoundExpression 97{New BoundLiteral(node.Syntax, ConstantValue.Create(value), decCtorInt64.Parameters(0).Type)}), 126New BoundLiteral(node.Syntax, ConstantValue.Create(UncheckedCInt(low)), decCtor.Parameters(0).Type), 127New BoundLiteral(node.Syntax, ConstantValue.Create(UncheckedCInt(mid)), decCtor.Parameters(1).Type), 128New BoundLiteral(node.Syntax, ConstantValue.Create(UncheckedCInt(high)), decCtor.Parameters(2).Type), 129New BoundLiteral(node.Syntax, ConstantValue.Create(isNegative), decCtor.Parameters(3).Type), 130New BoundLiteral(node.Syntax, ConstantValue.Create(scale), decCtor.Parameters(4).Type)), 138Private Shared Function RewriteDateConstant(node As BoundExpression, nodeValue As ConstantValue, currentMethod As MethodSymbol, diagnostics As BindingDiagnosticBag) As BoundExpression 175{New BoundLiteral(node.Syntax, ConstantValue.Create(dt.Ticks), dtCtorInt64.Parameters(0).Type)}),
Lowering\LocalRewriter\LocalRewriter_Conversion.vb (1)
405If rewrittenOperand.ConstantValueOpt Is ConstantValue.Nothing Then
Lowering\LocalRewriter\LocalRewriter_FieldAccess.vb (1)
35constantValueOpt As ConstantValue,
Lowering\LocalRewriter\LocalRewriter_ForEach.vb (2)
245ConstantValue.Default(SpecialType.System_Int32), 391New BoundLiteral(syntaxNode, ConstantValue.Create(1), expressionType),
Lowering\LocalRewriter\LocalRewriter_ForTo.vb (2)
128Dim literal As BoundExpression = New BoundLiteral(rewrittenStep.Syntax, ConstantValue.Default(literalUnderlyingType.SpecialType), stepValue.Type) 635Dim shiftConst = New BoundLiteral(value.Syntax, ConstantValue.Create(bits), int32Type)
Lowering\LocalRewriter\LocalRewriter_InterpolatedString.vb (3)
40Return factory.StringLiteral(ConstantValue.Create(String.Empty)) 46Return factory.StringLiteral(ConstantValue.Create(valueWithEscapes.Replace("{{", "{").Replace("}}", "}"))) 164arguments(0) = factory.StringLiteral(ConstantValue.Create(formatStringBuilderHandle.ToStringAndFree())).MakeCompilerGenerated()
Lowering\LocalRewriter\LocalRewriter_Label.vb (1)
31New BoundLiteral(node.Syntax, ConstantValue.Create(lineNumber), _currentLineTemporary.Type),
Lowering\LocalRewriter\LocalRewriter_LateBindingHelpers.vb (12)
75Dim bounds As BoundExpression = New BoundLiteral(node, ConstantValue.Create(flags.Length), intType) 115Dim bounds As BoundExpression = New BoundLiteral(node, ConstantValue.Create(rewrittenArguments.Length), intType) 143Dim indexExpr As BoundExpression = New BoundLiteral(node, ConstantValue.Create(indexVal), intType) 204Dim bounds As BoundExpression = New BoundLiteral(node, ConstantValue.Create(rewrittenArguments.Length + 1), intType) 254Dim indexExpr As BoundExpression = New BoundLiteral(node, ConstantValue.Create(index), intType) 276Dim bounds As BoundExpression = New BoundLiteral(node, ConstantValue.Default(ConstantValueTypeDiscriminator.Int32), intType) 280Dim bounds As BoundExpression = New BoundLiteral(node, ConstantValue.Create(rewrittenArguments.Length), intType) 329Dim bounds As BoundExpression = New BoundLiteral(node, ConstantValue.Create(initializer.Initializers.Length), intType) 347Dim index As BoundExpression = New BoundLiteral(syntax, ConstantValue.Create(argNum), intType) 929Return New BoundLiteral(node, ConstantValue.Create(value), stringType) 937Return New BoundLiteral(node, ConstantValue.Create(value), booleanType) 953Dim bounds As BoundExpression = New BoundLiteral(node, ConstantValue.Create(types.Length), intType)
Lowering\LocalRewriter\LocalRewriter_LocalDeclaration.vb (5)
212New BoundLiteral(syntax, ConstantValue.Nothing, objectType), 226ImmutableArray.Create(Of BoundExpression)(flag, newFlagInstance, New BoundLiteral(syntax, ConstantValue.Nothing, flag.Type)), 266Dim two = New BoundLiteral(syntax, ConstantValue.Create(2S), flagState.Type) 270New BoundLiteral(syntax, ConstantValue.Default(ConstantValueTypeDiscriminator.Int16), flagState.Type), 320New BoundLiteral(syntax, ConstantValue.Create(1S), flagState.Type),
Lowering\LocalRewriter\LocalRewriter_NullableHelpers.vb (6)
67hasValueExpr = New BoundLiteral(operand.Syntax, ConstantValue.True, Me.GetSpecialType(SpecialType.System_Boolean)) 186New BoundLiteral(expr.Syntax, ConstantValue.False, expr.Type.GetNullableUnderlyingType())) 300Return WrapInNullable(New BoundLiteral(syntax, ConstantValue.False, booleanType), nullableOfBoolean) 306Return WrapInNullable(New BoundLiteral(syntax, ConstantValue.True, booleanType), nullableOfBoolean) 484Return New BoundLiteral(syntax, ConstantValue.Nothing, type) 526Return MakeSequence(syntax, condition, If(ifConditionConst Is ConstantValue.True, whenTrue, whenFalse))
Lowering\LocalRewriter\LocalRewriter_RaiseEvent.vb (1)
79New BoundLiteral(syntax, ConstantValue.Nothing,
Lowering\LocalRewriter\LocalRewriter_SelectCase.vb (2)
350Dim uniqueStringConstants = New HashSet(Of ConstantValue) 354Dim constant As ConstantValue = Nothing
Lowering\LocalRewriter\LocalRewriter_StringConcat.vb (8)
72Return factory.StringLiteral(ConstantValue.Create("")) 168Dim leftConst As ConstantValue = loweredLeft.ConstantValueOpt 169Dim rightConst As ConstantValue = loweredRight.ConstantValueOpt 174Dim concatenated As ConstantValue = TryFoldTwoConcatConsts(leftConst, rightConst) 204Private Shared Function TryFoldTwoConcatConsts(leftConst As ConstantValue, rightConst As ConstantValue) As ConstantValue 219Return ConstantValue.Create(leftVal + rightVal)
Lowering\LocalRewriter\LocalRewriter_SyncLock.vb (2)
194New BoundLiteral(syntaxNode, ConstantValue.False, boundLockTakenLocal.Type), 263New BoundLiteral(syntaxNode, ConstantValue.True, boundLockTakenLocal.Type),
Lowering\LocalRewriter\LocalRewriter_UnaryOperators.vb (1)
32Return New BoundLiteral(node.Syntax, ConstantValue.False, node.Type)
Lowering\LocalRewriter\LocalRewriter_With.vb (1)
119New BoundLiteral(syntax, ConstantValue.Nothing, Nothing).MakeCompilerGenerated(),
Lowering\LocalRewriter\LocalRewriter_XmlLiterals.vb (4)
260ConstantValue.Create(rewrittenCallArguments.Length), 326Return New BoundLiteral(syntax, ConstantValue.Create(str), GetSpecialType(SpecialType.System_String)).MakeCompilerGenerated() 348result = New BoundLiteral(syntax, ConstantValue.Nothing, arrayType) 350Dim size = (New BoundLiteral(syntax, ConstantValue.Create(items.Length), GetSpecialType(SpecialType.System_Int32))).MakeCompilerGenerated()
Lowering\SyntheticBoundNodeFactory.vb (8)
439Dim boundNode = New BoundLiteral(_syntax, ConstantValue.Create(value), SpecialType(Microsoft.CodeAnalysis.SpecialType.System_Boolean)) 445Dim boundNode = New BoundLiteral(_syntax, ConstantValue.Create(value), SpecialType(Microsoft.CodeAnalysis.SpecialType.System_Int32)) 758Dim boundNode = New BoundLiteral(_syntax, ConstantValue.Create(value), SpecialType(Microsoft.CodeAnalysis.SpecialType.System_String)) 763Public Function StringLiteral(value As ConstantValue) As BoundLiteral 814Dim nullLiteral As BoundExpression = New BoundLiteral(_syntax, ConstantValue.Null, Nothing) 821Dim nullLiteral As BoundExpression = New BoundLiteral(_syntax, ConstantValue.Null, type) 826Dim nullLiteral As BoundExpression = New BoundLiteral(_syntax, ConstantValue.Null, Nothing) 992Dim boundNode = New BoundConversion(_syntax, arg, convKind, isChecked, True, ConstantValue.NotAvailable, type)
Lowering\UseTwiceRewriter.vb (1)
181Dim constantValue As ConstantValue = value.ConstantValueOpt
Lowering\WithExpressionRewriter.vb (1)
156Dim constantValue As ConstantValue = value.ConstantValueOpt
Operations\VisualBasicOperationFactory.vb (24)
313Dim constantValue As ConstantValue = Nothing 363Dim constantValue As ConstantValue = boundAssignmentOperator.ConstantValueOpt 376Dim constantValue As ConstantValue = boundAssignmentOperator.ConstantValueOpt 408Dim constantValue As ConstantValue = boundLiteral.ConstantValueOpt 425Dim constantValue As ConstantValue = boundNameOfOperator.ConstantValueOpt 468Dim constantValue As ConstantValue = boundParenthesized.ConstantValueOpt 504Dim constantValue As ConstantValue = boundUnaryOperator.ConstantValueOpt 517Dim constantValue As ConstantValue = boundUserDefinedUnaryOperator.ConstantValueOpt 570Dim constantValue As ConstantValue = currentBinary.ConstantValueOpt 589Dim constantValue As ConstantValue = boundUserDefinedBinaryOperator.ConstantValueOpt 601Dim constantValue As ConstantValue = boundBinaryConditionalExpression.ConstantValueOpt 630Dim constantValue As ConstantValue = boundUserDefinedShortCircuitingOperator.ConstantValueOpt 652Dim constantValue As ConstantValue = boundBadExpression.ConstantValueOpt 669Dim constantValue As ConstantValue = boundTypeArguments.ConstantValueOpt 722Dim constantValue As ConstantValue = boundConversionOrCast.ConstantValueOpt 783Dim constantValue As ConstantValue = boundTernaryConditionalExpression.ConstantValueOpt 826Dim constantValue As ConstantValue = boundObjectCreationExpression.ConstantValueOpt 925Dim constantValue As ConstantValue = boundFieldAccess.ConstantValueOpt 960Dim constantValue As ConstantValue = boundLocal.ConstantValueOpt 1066Dim constantValue As ConstantValue = Nothing 1428Dim constantValue As ConstantValue = Nothing 1537Dim constantValue As ConstantValue = Nothing 1562Dim constantValue As ConstantValue = boundInterpolatedString.ConstantValueOpt 1652Dim constantValue As ConstantValue = boundNullableIsTrueOperator.ConstantValueOpt
Operations\VisualBasicOperationFactory_Methods.vb (1)
350Dim constantValue As ConstantValue = value.GetConstantValue()
Semantics\CompileTimeCalculations.vb (58)
146Friend Function GetConstantValueAsInt64(ByRef value As ConstantValue) As Long 163Friend Function GetConstantValue(type As ConstantValueTypeDiscriminator, value As Long) As ConstantValue 164Dim result As ConstantValue 167Case ConstantValueTypeDiscriminator.SByte : result = ConstantValue.Create(UncheckedCSByte(value)) 168Case ConstantValueTypeDiscriminator.Byte : result = ConstantValue.Create(UncheckedCByte(value)) 169Case ConstantValueTypeDiscriminator.Int16 : result = ConstantValue.Create(UncheckedCShort(value)) 170Case ConstantValueTypeDiscriminator.UInt16 : result = ConstantValue.Create(UncheckedCUShort(value)) 171Case ConstantValueTypeDiscriminator.Int32 : result = ConstantValue.Create(UncheckedCInt(value)) 172Case ConstantValueTypeDiscriminator.UInt32 : result = ConstantValue.Create(UncheckedCUInt(value)) 173Case ConstantValueTypeDiscriminator.Int64 : result = ConstantValue.Create(value) 174Case ConstantValueTypeDiscriminator.UInt64 : result = ConstantValue.Create(UncheckedCULng(value)) 175Case ConstantValueTypeDiscriminator.Char : result = ConstantValue.Create(ChrW(UncheckedCInt(value))) 176Case ConstantValueTypeDiscriminator.Boolean : result = ConstantValue.Create(If(value = 0, False, True)) 177Case ConstantValueTypeDiscriminator.DateTime : result = ConstantValue.Create(New DateTime(value)) 232If Not ConstantValue.IsBooleanType(sourceType) AndAlso 233(ConstantValue.IsUnsignedIntegralType(sourceType) Xor ConstantValue.IsUnsignedIntegralType(resultType)) Then 237If Not ConstantValue.IsUnsignedIntegralType(sourceType) Then 242Debug.Assert(Not ConstantValue.IsUnsignedIntegralType(resultType), "Expected signed Target type!!!") 293) As ConstantValue 295Debug.Assert(ConstantValue.IsIntegralType(sourceType) OrElse ConstantValue.IsBooleanType(sourceType) OrElse ConstantValue.IsCharType(sourceType), 298If ConstantValue.IsIntegralType(targetType) OrElse ConstantValue.IsBooleanType(targetType) OrElse ConstantValue.IsCharType(targetType) Then 302If ConstantValue.IsStringType(targetType) Then 304If ConstantValue.IsCharType(sourceType) Then 305Return ConstantValue.Create(New String(ChrW(UncheckedCInt(sourceValue)), 1)) 309If ConstantValue.IsFloatingType(targetType) Then 311If(ConstantValue.IsUnsignedIntegralType(sourceType), CType(UncheckedCULng(sourceValue), Double), CType(sourceValue, Double)), 316If ConstantValue.IsDecimalType(targetType) Then 322If Not ConstantValue.IsUnsignedIntegralType(sourceType) AndAlso sourceValue < 0 Then 350) As ConstantValue 354If (ConstantValue.IsBooleanType(targetType)) Then 362If ConstantValue.IsIntegralType(targetType) OrElse ConstantValue.IsCharType(targetType) Then 364overflow = DetectFloatingToIntegralOverflow(sourceValue, ConstantValue.IsUnsignedIntegralType(targetType)) 401If ConstantValue.IsFloatingType(targetType) Then 408Return ConstantValue.Create(CType(resultValue, Single)) 412Return ConstantValue.Create(resultValue) 415If ConstantValue.IsDecimalType(targetType) Then 430Return ConstantValue.Bad 440) As ConstantValue 444If ConstantValue.IsIntegralType(targetType) OrElse ConstantValue.IsCharType(targetType) Then 465If ConstantValue.IsUnsignedIntegralType(targetType) OrElse 496If ConstantValue.IsFloatingType(targetType) OrElse ConstantValue.IsBooleanType(targetType) Then 507If ConstantValue.IsDecimalType(targetType) Then 508Return ConstantValue.Create(sourceValue) 512Return ConstantValue.Bad 670Friend Function AdjustConstantValueFromMetadata(value As ConstantValue, targetType As TypeSymbol, isByRefParamValue As Boolean) As ConstantValue 710value = ConstantValue.Nothing 712value = ConstantValue.Bad 719value = ConstantValue.Create(New DateTime(value.Int64Value)) 753If ConstantValue.IsUnsignedIntegralType(resultType) Then
Semantics\Conversions.vb (12)
700) As ConstantValue 708Dim sourceValue As ConstantValue = source.ConstantValueOpt 729Return ConstantValue.Default(dstDiscriminator) 762Return ConstantValue.Create([char]) 768Return ConstantValue.Create(New String(sourceValue.CharValue, 1)) 794ByRef sourceValue As ConstantValue, 798) As ConstantValue 868) As ConstantValue 874Dim sourceValue As ConstantValue = source.ConstantValueOpt 880sourceValue As ConstantValue, 883) As ConstantValue 1617Dim result As ConstantValue
Semantics\Operators.vb (45)
707) As ConstantValue 714Dim operandValue As ConstantValue = operand.ConstantValueOpt 722Dim result As ConstantValue = Nothing 779result = ConstantValue.Create(CType(value, Single)) 781result = ConstantValue.Create(value) 797result = ConstantValue.Create(value) 802result = ConstantValue.Create(Not operandValue.BooleanValue) 1027) As ConstantValue 1037Dim leftConstantValue As ConstantValue = left.ConstantValueOpt 1038Dim rightConstantValue As ConstantValue = right.ConstantValueOpt 1051Dim result As ConstantValue = Nothing 1121left As ConstantValue, 1122right As ConstantValue, 1127) As ConstantValue 1133Dim result As ConstantValue 1175result = ConstantValue.Create(resultValue) 1285result = ConstantValue.Bad 1296left As ConstantValue, 1297right As ConstantValue, 1300) As ConstantValue 1304Dim result As ConstantValue 1336result = ConstantValue.Create(resultValue) 1407result = ConstantValue.Create(CType(resultValue, Single)) 1409result = ConstantValue.Create(resultValue) 1419left As ConstantValue, 1420right As ConstantValue, 1423) As ConstantValue 1427Dim result As ConstantValue 1460result = ConstantValue.Create(resultValue) 1493result = ConstantValue.Bad 1495result = ConstantValue.Create(resultValue) 1507left As ConstantValue, 1508right As ConstantValue 1509) As ConstantValue 1512Dim result As ConstantValue 1523Return ConstantValue.Bad 1527result = ConstantValue.CreateFromRope(Rope.Concat(leftValue, rightValue)) 1529Return ConstantValue.Bad 1567result = ConstantValue.Create(stringComparisonSucceeds) 1578left As ConstantValue, 1579right As ConstantValue 1580) As ConstantValue 1583Dim result As ConstantValue 1627result = ConstantValue.Create(operationSucceeds) 3321Friend Overrides ReadOnly Property ExplicitDefaultConstantValue(inProgress As SymbolsInProgress(Of ParameterSymbol)) As ConstantValue
Symbols\ConstantValueUtils.vb (6)
13Public Sub New(value As ConstantValue, type As TypeSymbol) 20Public ReadOnly Value As ConstantValue 37Dim constValue As ConstantValue = Nothing 49Dim value As ConstantValue = If(constValue, ConstantValue.Bad) 57<Out> ByRef constValue As ConstantValue) As BoundExpression
Symbols\FieldSymbol.vb (1)
163Friend MustOverride Function GetConstantValue(inProgress As ConstantFieldsInProgress) As ConstantValue
Symbols\Metadata\PE\PEFieldSymbol.vb (16)
42Private _lazyConstantValue As ConstantValue = Microsoft.CodeAnalysis.ConstantValue.Unset 162Dim value As ConstantValue 224Friend Overrides Function GetConstantValue(inProgress As ConstantFieldsInProgress) As ConstantValue 225If _lazyConstantValue Is Microsoft.CodeAnalysis.ConstantValue.Unset Then 226Dim value As ConstantValue = Nothing 238value = Microsoft.CodeAnalysis.ConstantValue.Default( 239Microsoft.CodeAnalysis.ConstantValue.GetDiscriminator(selfOrUnderlyingSpecialType)) 242value = Microsoft.CodeAnalysis.ConstantValue.Default(ConstantValueTypeDiscriminator.DateTime) 245value = Microsoft.CodeAnalysis.ConstantValue.Default(ConstantValueTypeDiscriminator.Boolean) 248value = Microsoft.CodeAnalysis.ConstantValue.Default(ConstantValueTypeDiscriminator.Char) 260value = Microsoft.CodeAnalysis.ConstantValue.Bad 266value = Microsoft.CodeAnalysis.ConstantValue.Bad 272Dim defaultValue As ConstantValue = CodeAnalysis.ConstantValue.NotAvailable 286Microsoft.CodeAnalysis.ConstantValue.Unset)
Symbols\Metadata\PE\PEParameterSymbol.vb (12)
43Private _lazyDefaultValue As ConstantValue = ConstantValue.Unset 88defaultValue As ConstantValue, 109defaultValue As ConstantValue 179_lazyDefaultValue = ConstantValue.NotAvailable 221defaultValue As ConstantValue, 324Friend Overrides ReadOnly Property ExplicitDefaultConstantValue(inProgress As SymbolsInProgress(Of ParameterSymbol)) As ConstantValue 326If _lazyDefaultValue Is ConstantValue.Unset Then 329Dim defaultValue As ConstantValue = ConstantValue.NotAvailable 345Interlocked.CompareExchange(_lazyDefaultValue, defaultValue, ConstantValue.Unset) 368Dim defaultValue As ConstantValue = Me.ExplicitDefaultConstantValue
Symbols\Metadata\PE\PEPropertySymbol.vb (1)
460Dim defaultValue As ConstantValue = Nothing
Symbols\MethodSignatureComparer.vb (6)
683Dim constValue1 As ConstantValue = param1.ExplicitDefaultConstantValue 684Dim constValue2 As ConstantValue = param2.ExplicitDefaultConstantValue 697Dim descriminator = ConstantValue.GetDiscriminator(param1.Type.GetEnumUnderlyingTypeOrSelf.SpecialType) 699constValue1 = ConstantValue.Default(descriminator) 704Dim descriminator = ConstantValue.GetDiscriminator(param2.Type.GetEnumUnderlyingTypeOrSelf.SpecialType) 706constValue2 = ConstantValue.Default(descriminator)
Symbols\ParameterSymbol.vb (2)
176Friend MustOverride ReadOnly Property ExplicitDefaultConstantValue(inProgress As SymbolsInProgress(Of ParameterSymbol)) As ConstantValue 178Friend ReadOnly Property ExplicitDefaultConstantValue As ConstantValue
Symbols\ReducedExtensionMethodSymbol.vb (1)
907Friend Overrides ReadOnly Property ExplicitDefaultConstantValue(inProgress As SymbolsInProgress(Of ParameterSymbol)) As ConstantValue
Symbols\Retargeting\RetargetingFieldSymbol.vb (1)
205Friend Overrides Function GetConstantValue(inProgress As ConstantFieldsInProgress) As ConstantValue
Symbols\Retargeting\RetargetingParameterSymbol.vb (1)
144Friend Overrides ReadOnly Property ExplicitDefaultConstantValue(inProgress As SymbolsInProgress(Of ParameterSymbol)) As ConstantValue
Symbols\SignatureOnlyParameterSymbol.vb (3)
21Private ReadOnly _defaultValue As ConstantValue 30ByVal defaultConstantValue As ConstantValue, 112Friend Overrides ReadOnly Property ExplicitDefaultConstantValue(inProgress As SymbolsInProgress(Of ParameterSymbol)) As ConstantValue
Symbols\Source\LambdaParameterSymbol.vb (1)
59Friend Overrides ReadOnly Property ExplicitDefaultConstantValue(inProgress As SymbolsInProgress(Of ParameterSymbol)) As ConstantValue
Symbols\Source\LocalSymbol.vb (7)
360Dim constant As ConstantValue = Me.GetConstantValue(Nothing) 373Friend Overridable Function GetConstantValue(binder As Binder) As ConstantValue 812Public Sub New(value As ConstantValue, type As TypeSymbol, expression As BoundExpression, diagnostics As BindingDiagnosticBag) 875Dim constValue As ConstantValue = Nothing 901Friend Overrides Function GetConstantValue(containingBinder As Binder) As ConstantValue 915Private Sub SetConstantExpression(type As TypeSymbol, constantValue As ConstantValue, expression As BoundExpression, diagnostics As BindingDiagnosticBag) 1013Friend Overrides Function GetConstantValue(binder As Binder) As ConstantValue
Symbols\Source\MeParameterSymbol.vb (1)
60Friend Overrides ReadOnly Property ExplicitDefaultConstantValue(inProgress As SymbolsInProgress(Of ParameterSymbol)) As ConstantValue
Symbols\Source\SourceClonedParameterSymbol.vb (1)
88Friend Overloads Overrides ReadOnly Property ExplicitDefaultConstantValue(inProgress As SymbolsInProgress(Of ParameterSymbol)) As ConstantValue
Symbols\Source\SourceComplexParameterSymbol.vb (12)
22Private _lazyDefaultValue As ConstantValue 132Friend Overrides ReadOnly Property ExplicitDefaultConstantValue(inProgress As SymbolsInProgress(Of ParameterSymbol)) As ConstantValue 134If _lazyDefaultValue Is ConstantValue.Unset Then 136If Interlocked.CompareExchange(_lazyDefaultValue, BindDefaultValue(inProgress, diagnostics), ConstantValue.Unset) Is ConstantValue.Unset Then 146Private Function BindDefaultValue(inProgress As SymbolsInProgress(Of ParameterSymbol), diagnostics As BindingDiagnosticBag) As ConstantValue 172Dim constValue As ConstantValue = Nothing 281defaultValueOpt As ConstantValue 297defaultValueOpt As ConstantValue) As ParameterSymbol 367Dim defaultValue As ConstantValue = Nothing 373defaultValue = ConstantValue.Unset 427defaultValueOpt As ConstantValue,
Symbols\Source\SourceEnumConstantSymbol.vb (4)
73Friend NotOverridable Overrides Function GetConstantValue(inProgress As ConstantFieldsInProgress) As ConstantValue 105Return New EvaluatedConstant(Microsoft.CodeAnalysis.ConstantValue.Default(underlyingType.SpecialType), underlyingType) 142Dim value As ConstantValue = Microsoft.CodeAnalysis.ConstantValue.Bad
Symbols\Source\SourceFieldSymbol.vb (8)
172Friend Overrides Function GetConstantValue(inProgress As ConstantFieldsInProgress) As ConstantValue 185Protected Function GetConstantValueImpl(inProgress As ConstantFieldsInProgress) As ConstantValue 196Return CodeAnalysis.ConstantValue.Bad 662If data Is Nothing OrElse data.ConstValue = CodeAnalysis.ConstantValue.Unset Then 756Private Sub VerifyConstantValueMatches(attrValue As ConstantValue, ByRef arguments As DecodeWellKnownAttributeArguments(Of AttributeSyntax, VisualBasicAttributeData, AttributeLocation)) 758Dim constValue As ConstantValue 772If data.ConstValue = CodeAnalysis.ConstantValue.Unset Then 778If constValue <> CodeAnalysis.ConstantValue.Unset Then
Symbols\Source\SourceMemberFieldSymbol.vb (2)
324Friend Overrides Function GetConstantValue(inProgress As ConstantFieldsInProgress) As ConstantValue 381Friend Overrides Function GetConstantValue(inProgress As ConstantFieldsInProgress) As ConstantValue
Symbols\Source\SourceNamedTypeSymbol_ComClass.vb (1)
1453Friend Overloads Overrides ReadOnly Property ExplicitDefaultConstantValue(inProgress As SymbolsInProgress(Of ParameterSymbol)) As ConstantValue
Symbols\Source\SourceParameterSymbol.vb (12)
165Return data IsNot Nothing AndAlso data.DefaultParameterValue <> ConstantValue.Unset 302Dim value As ConstantValue 305value = ConstantValue.Bad 312If paramData.DefaultParameterValue = ConstantValue.Unset Then 391Protected Sub VerifyParamDefaultValueMatchesAttributeIfAny(value As ConstantValue, syntax As VisualBasicSyntaxNode, diagnostics As BindingDiagnosticBag) 395If attrValue <> ConstantValue.Unset AndAlso 402Private Function DecodeDefaultParameterValueAttribute(description As AttributeDescription, attribute As VisualBasicAttributeData) As ConstantValue 415Private Function DecodeDefaultParameterValueAttribute(attribute As VisualBasicAttributeData) As ConstantValue 424Dim constantValueDiscriminator = ConstantValue.GetDiscriminator(specialType) 430Return ConstantValue.Null 433Return ConstantValue.Bad 436Return ConstantValue.Create(arg.ValueInternal, constantValueDiscriminator)
Symbols\Source\SourceSimpleParameterSymbol.vb (1)
92Friend Overrides ReadOnly Property ExplicitDefaultConstantValue(inProgress As SymbolsInProgress(Of ParameterSymbol)) As ConstantValue
Symbols\Source\SynthesizedFieldSymbol.vb (1)
110Friend Overrides Function GetConstantValue(inProgress As ConstantFieldsInProgress) As ConstantValue
Symbols\Source\SynthesizedSubmissionConstructorSymbol.vb (3)
79New BoundArrayAccess(syntax, submissionArrayReference, ImmutableArray.Create(Of BoundExpression)(New BoundLiteral(syntax, ConstantValue.Create(slotIndex), intType)), isLValue:=True, type:=objectType), 93New BoundArrayAccess(syntax, submissionArrayReference, ImmutableArray.Create(Of BoundExpression)(New BoundLiteral(syntax, ConstantValue.Create(0), intType)), isLValue:=False, type:=objectType), 113New BoundArrayAccess(syntax, submissionArrayReference, ImmutableArray.Create(Of BoundExpression)(New BoundLiteral(syntax, ConstantValue.Create(targetSubmissionId), intType)), isLValue:=False, type:=objectType),
Symbols\SubstitutedFieldSymbol.vb (1)
110Friend Overrides Function GetConstantValue(inProgress As ConstantFieldsInProgress) As ConstantValue
Symbols\SubstitutedParameterSymbol.vb (1)
52Friend Overrides ReadOnly Property ExplicitDefaultConstantValue(inProgress As SymbolsInProgress(Of ParameterSymbol)) As ConstantValue
Symbols\SynthesizedSymbols\SynthesizedBackingFieldBase.vb (1)
63Friend Overrides Function GetConstantValue(inProgress As ConstantFieldsInProgress) As ConstantValue
Symbols\SynthesizedSymbols\SynthesizedParameterSymbol.vb (4)
66Friend Overrides ReadOnly Property ExplicitDefaultConstantValue(inProgress As SymbolsInProgress(Of ParameterSymbol)) As ConstantValue 264Private ReadOnly _defaultValue As ConstantValue 286Public Sub New(container As MethodSymbol, type As TypeSymbol, ordinal As Integer, isByRef As Boolean, name As String, isOptional As Boolean, defaultValue As ConstantValue) 359Friend NotOverridable Overrides ReadOnly Property ExplicitDefaultConstantValue(inProgress As SymbolsInProgress(Of ParameterSymbol)) As ConstantValue
Symbols\TypedConstant.vb (4)
55Dim valueConstant As ConstantValue = ConstantValue.Create(constant.ValueInternal, splType) 82Dim memberConstant = ConstantValue.Create(field.ConstantValue, splType) 147Dim memberConstant = ConstantValue.Create(field.ConstantValue, splType)
Symbols\TypeSymbolExtensions.vb (1)
470Public Function IsValidForConstantValue(this As TypeSymbol, value As ConstantValue) As Boolean
Symbols\Wrapped\WrappedFieldSymbol.vb (1)
139Friend Overrides Function GetConstantValue(inProgress As ConstantFieldsInProgress) As ConstantValue
Symbols\Wrapped\WrappedParameterSymbol.vb (1)
157Friend Overrides ReadOnly Property ExplicitDefaultConstantValue(inProgress As SymbolsInProgress(Of ParameterSymbol)) As ConstantValue
Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.ExpressionCompiler (11)
Rewriters\LocalDeclarationRewriter.vb (2)
72Dim name = New BoundLiteral(syntax, ConstantValue.Create(local.Name), stringType) 74Dim customTypeInfoPayload = New BoundLiteral(syntax, ConstantValue.Null, byteArrayType)
Symbols\DisplayClassVariable.vb (1)
164Friend Overrides Function GetConstantValue(inProgress As ConstantFieldsInProgress) As ConstantValue
Symbols\EELocalConstantSymbol.vb (3)
15Private ReadOnly _constantValue As ConstantValue 21constantValue As ConstantValue) 75Friend Overrides Function GetConstantValue(binder As Binder) As ConstantValue
Symbols\EELocalSymbol.vb (1)
101Friend Overrides Function GetConstantValue(binder As Binder) As ConstantValue
Symbols\ObjectIdLocalSymbol.vb (1)
104Microsoft.CodeAnalysis.ConstantValue.Create(name),
Symbols\ReturnValueLocalSymbol.vb (1)
37Microsoft.CodeAnalysis.ConstantValue.Create(_index),
VisualBasicEESymbolProvider.vb (2)
44value As ConstantValue, 64Public Overrides Sub DecodeLocalConstant(ByRef reader As BlobReader, ByRef type As TypeSymbol, ByRef value As ConstantValue)
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (76)
Semantics\Conversions.vb (47)
102Dim [nothing] = New BoundLiteral(DirectCast(DirectCast(dummyTree.GetRoot(Nothing), VisualBasicSyntaxNode), VisualBasicSyntaxNode), ConstantValue.Nothing, Nothing) 103Dim intZero = New BoundLiteral(DirectCast(DirectCast(dummyTree.GetRoot(Nothing), VisualBasicSyntaxNode), VisualBasicSyntaxNode), ConstantValue.Create(0I), m13p(c)) 104Dim longZero = New BoundLiteral(DirectCast(DirectCast(dummyTree.GetRoot(Nothing), VisualBasicSyntaxNode), VisualBasicSyntaxNode), ConstantValue.Create(0L), m13p(d)) 271Dim _nothing = New BoundLiteral(DirectCast(DirectCast(dummyTree.GetRoot(Nothing), VisualBasicSyntaxNode), VisualBasicSyntaxNode), ConstantValue.Nothing, Nothing) 273Dim resultValue As ConstantValue 310Dim zero = ConstantValue.Default(integralType.GetConstantValueTypeDiscriminator()) 335Dim zero = ConstantValue.Default(If(convertibleType.IsStringType(), ConstantValueTypeDiscriminator.Nothing, convertibleType.GetConstantValueTypeDiscriminator())) 338literal = New BoundConversion(dummyTree.GetVisualBasicRoot(Nothing), New BoundLiteral(DirectCast(DirectCast(dummyTree.GetRoot(Nothing), VisualBasicSyntaxNode), VisualBasicSyntaxNode), ConstantValue.Null, Nothing), ConversionKind.WideningNothingLiteral, False, True, zero, convertibleType, Nothing) 366Dim zero = ConstantValue.Default(If(type1.IsStringType(), ConstantValueTypeDiscriminator.Nothing, type1.GetConstantValueTypeDiscriminator())) 369literal = New BoundConversion(dummyTree.GetVisualBasicRoot(Nothing), New BoundLiteral(DirectCast(dummyTree.GetRoot(Nothing), VisualBasicSyntaxNode), ConstantValue.Null, Nothing), ConversionKind.WideningNothingLiteral, False, True, zero, type1, Nothing) 375New BoundLiteral(dummyTree.GetVisualBasicRoot(Nothing), ConstantValue.Default(ConstantValueTypeDiscriminator.Int32), int32Type), 615Dim resultValue2 As ConstantValue 620Dim v = ConstantValue.Create(mv.Value, mv.Type.GetConstantValueTypeDiscriminator()) 626New BoundLiteral(DirectCast(dummyTree.GetRoot(Nothing), VisualBasicSyntaxNode), ConstantValue.Null, Nothing), 750Dim zero = New BoundConversion(dummyTree.GetVisualBasicRoot(Nothing), New BoundLiteral(DirectCast(dummyTree.GetRoot(Nothing), VisualBasicSyntaxNode), ConstantValue.Null, Nothing), ConversionKind.Widening, True, True, ConstantValue.Default(mv.Type.GetConstantValueTypeDiscriminator()), mv.Type, Nothing) 774Dim doubleValue = ConstantValue.Create(dbl) 776constant = New BoundConversion(dummyTree.GetVisualBasicRoot(Nothing), New BoundLiteral(dummyTree.GetVisualBasicRoot(Nothing), ConstantValue.Null, Nothing), ConversionKind.Widening, True, True, doubleValue, doubleType, Nothing) 787doubleValue = ConstantValue.Create(dbl) 789constant = New BoundConversion(dummyTree.GetVisualBasicRoot(Nothing), New BoundLiteral(dummyTree.GetVisualBasicRoot(Nothing), ConstantValue.Null, Nothing), ConversionKind.Widening, True, True, doubleValue, doubleType, Nothing) 800doubleValue = ConstantValue.Create(dbl) 802constant = New BoundConversion(dummyTree.GetVisualBasicRoot(Nothing), New BoundLiteral(dummyTree.GetVisualBasicRoot(Nothing), ConstantValue.Null, Nothing), ConversionKind.Widening, True, True, doubleValue, doubleType, Nothing) 813doubleValue = ConstantValue.Create(dbl) 815constant = New BoundConversion(dummyTree.GetVisualBasicRoot(Nothing), New BoundLiteral(dummyTree.GetVisualBasicRoot(Nothing), ConstantValue.Null, Nothing), ConversionKind.Widening, True, True, doubleValue, doubleType, Nothing) 826doubleValue = ConstantValue.Create(dbl) 828constant = New BoundConversion(dummyTree.GetVisualBasicRoot(Nothing), New BoundLiteral(dummyTree.GetVisualBasicRoot(Nothing), ConstantValue.Null, Nothing), ConversionKind.Widening, True, True, doubleValue, doubleType, Nothing) 838Dim falseValue = ConstantValue.Create(False) 843constant = New BoundConversion(dummyTree.GetVisualBasicRoot(Nothing), New BoundLiteral(dummyTree.GetVisualBasicRoot(Nothing), ConstantValue.Null, Nothing), ConversionKind.Widening, True, True, falseValue, booleanType, Nothing) 870Dim trueValue = ConstantValue.Create(True) 875constant = New BoundConversion(dummyTree.GetVisualBasicRoot(Nothing), New BoundLiteral(dummyTree.GetVisualBasicRoot(Nothing), ConstantValue.Null, Nothing), ConversionKind.Widening, True, True, trueValue, booleanType, Nothing) 933Dim v = ConstantValue.Create(mv.Value, mv.Type.GetConstantValueTypeDiscriminator()) 938constant = New BoundConversion(dummyTree.GetVisualBasicRoot(Nothing), New BoundLiteral(dummyTree.GetVisualBasicRoot(Nothing), ConstantValue.Null, Nothing), ConversionKind.Widening, True, True, v, mv.Type, Nothing) 966Dim stringValue = ConstantValue.Nothing 971constant = New BoundConversion(dummyTree.GetVisualBasicRoot(Nothing), New BoundLiteral(dummyTree.GetVisualBasicRoot(Nothing), ConstantValue.Null, Nothing), ConversionKind.Widening, True, True, stringValue, stringType, Nothing) 991stringValue = ConstantValue.Create("") 996constant = New BoundConversion(dummyTree.GetVisualBasicRoot(Nothing), New BoundLiteral(dummyTree.GetVisualBasicRoot(Nothing), ConstantValue.Null, Nothing), ConversionKind.Widening, True, True, stringValue, stringType, Nothing) 1016stringValue = ConstantValue.Create("abc") 1019constant = New BoundConversion(dummyTree.GetVisualBasicRoot(Nothing), New BoundLiteral(dummyTree.GetVisualBasicRoot(Nothing), ConstantValue.Null, Nothing), ConversionKind.Widening, True, True, stringValue, stringType, Nothing) 1038Dim charValue = ConstantValue.Create("b"c) 1041constant = New BoundConversion(dummyTree.GetVisualBasicRoot(Nothing), New BoundLiteral(dummyTree.GetVisualBasicRoot(Nothing), ConstantValue.Null, Nothing), ConversionKind.Widening, True, True, charValue, charType, Nothing) 1120Dim _nothing = New BoundLiteral(DirectCast(dummyTree.GetRoot(Nothing), VisualBasicSyntaxNode), ConstantValue.Nothing, Nothing) 1122Dim resultValue As ConstantValue 1175Dim resultValue2 As ConstantValue 1180Dim v = ConstantValue.Create(mv.Value, mv.Type.GetConstantValueTypeDiscriminator()) 1186New BoundLiteral(DirectCast(dummyTree.GetRoot(Nothing), VisualBasicSyntaxNode), ConstantValue.Null, Nothing), 1316New BoundLiteral(dummyTree.GetVisualBasicRoot(Nothing), ConstantValue.Default(ConstantValueTypeDiscriminator.Int32), int32Type), 1317ConversionKind.Widening, True, True, ConstantValue.Default(mv.Type.GetConstantValueTypeDiscriminator()), mv.Type, Nothing)
Semantics\OptionalArgumentTests.vb (13)
2216Assert.Equal(ConstantValue.Create(0), parameters(1).ExplicitDefaultConstantValue) 2222Assert.Equal(ConstantValue.Create(1), parameters(2).ExplicitDefaultConstantValue) 2327Assert.Equal(ConstantValue.Null, parameters(1).ExplicitDefaultConstantValue) 2416Assert.Equal(ConstantValue.Null, parameters(1).ExplicitDefaultConstantValue) 2422Assert.Equal(ConstantValue.Create("A"), parameters(2).ExplicitDefaultConstantValue) 2541Assert.Equal(ConstantValue.Create(decimalZero), parameters(1).ExplicitDefaultConstantValue) 2547Assert.Equal(ConstantValue.Create(decimalOne), parameters(2).ExplicitDefaultConstantValue) 2632Assert.Equal(ConstantValue.Create(decimalZero), parameters(10).ExplicitDefaultConstantValue) 2638Assert.Equal(ConstantValue.Create(decimalOne), parameters(11).ExplicitDefaultConstantValue) 2703Assert.Equal(ConstantValue.Create(dateTimeZero), parameters(1).ExplicitDefaultConstantValue) 2709Assert.Equal(ConstantValue.Create(dateTimeOther), parameters(2).ExplicitDefaultConstantValue) 2774Assert.Equal(ConstantValue.Create(dateTimeZero), parameters(8).ExplicitDefaultConstantValue) 2780Assert.Equal(ConstantValue.Create(dateTimeOne), parameters(9).ExplicitDefaultConstantValue)
Semantics\OverloadResolution.vb (16)
193Dim [nothing] As BoundExpression = New BoundLiteral(_syntaxNode, ConstantValue.Nothing, Nothing) 194Dim intZero As BoundExpression = New BoundLiteral(_syntaxNode, ConstantValue.Create(0I), c1.GetSpecialType(System_Int32)) 195Dim longZero As BoundExpression = New BoundLiteral(_syntaxNode, ConstantValue.Create(0L), c1.GetSpecialType(System_Int64)) 196Dim unsignedOne As BoundExpression = New BoundLiteral(_syntaxNode, ConstantValue.Create(1UI), c1.GetSpecialType(System_UInt32)) 197Dim longConst As BoundExpression = New BoundConversion(_syntaxNode, New BoundLiteral(_syntaxNode, ConstantValue.Null, Nothing), ConversionKind.Widening, True, True, ConstantValue.Create(-1L), c1.GetSpecialType(System_Int64), Nothing) 202Dim doubleConst As BoundExpression = New BoundConversion(_syntaxNode, New BoundLiteral(_syntaxNode, ConstantValue.Null, Nothing), ConversionKind.Widening, True, True, ConstantValue.Create(0.0R), c1.GetSpecialType(System_Double), Nothing) 2883Dim DoubleMaxValue As BoundExpression = New BoundConversion(_syntaxNode, New BoundLiteral(_syntaxNode, ConstantValue.Null, Nothing), ConversionKind.Widening, True, True, ConstantValue.Create(Double.MaxValue), c1.GetSpecialType(System_Double), Nothing) 2884Dim IntegerMaxValue As BoundExpression = New BoundConversion(_syntaxNode, New BoundLiteral(_syntaxNode, ConstantValue.Null, Nothing), ConversionKind.Widening, True, True, ConstantValue.Create(Integer.MaxValue), c1.GetSpecialType(System_Int32), Nothing) 3074Dim DoubleMaxValue As BoundExpression = New BoundConversion(_syntaxNode, New BoundLiteral(_syntaxNode, ConstantValue.Null, Nothing), ConversionKind.Widening, True, True, ConstantValue.Create(Double.MaxValue), c1.GetSpecialType(System_Double), Nothing) 3075Dim IntegerMaxValue As BoundExpression = New BoundConversion(_syntaxNode, New BoundLiteral(_syntaxNode, ConstantValue.Null, Nothing), ConversionKind.Widening, True, True, ConstantValue.Create(Integer.MaxValue), c1.GetSpecialType(System_Int32), Nothing)
Microsoft.CodeAnalysis.VisualBasic.Symbol.UnitTests (1)
SymbolsTests\Source\PropertyTests.vb (1)
7140Dim defaultValue = ConstantValue.Create(1)