248 references to BindValueKind
Microsoft.CodeAnalysis.CSharp (248)
Binder\Binder.ValueChecks.cs (104)
227
private const
BindValueKind
ValueKindSignificantBitsMask = unchecked((
BindValueKind
)~((1 << ValueKindInsignificantBits) - 1));
324
private static bool RequiresRValueOnly(
BindValueKind
kind)
326
return (kind & ValueKindSignificantBitsMask) ==
BindValueKind
.RValue;
329
private static bool RequiresAssignmentOnly(
BindValueKind
kind)
331
return (kind & ValueKindSignificantBitsMask) ==
BindValueKind
.Assignable;
334
private static bool RequiresVariable(
BindValueKind
kind)
339
private static bool RequiresReferenceToLocation(
BindValueKind
kind)
341
return (kind &
BindValueKind
.RefersToLocation) != 0;
344
private static bool RequiresAssignableVariable(
BindValueKind
kind)
346
return (kind &
BindValueKind
.Assignable) != 0;
349
private static bool RequiresRefAssignableVariable(
BindValueKind
kind)
351
return (kind &
BindValueKind
.RefAssignable) != 0;
354
private static bool RequiresRefOrOut(
BindValueKind
kind)
356
return (kind &
BindValueKind
.RefOrOut) ==
BindValueKind
.RefOrOut;
361
private static AccessorKind GetIndexerAccessorKind(BoundIndexerAccess indexerAccess,
BindValueKind
valueKind)
371
private static AccessorKind GetAccessorKind(
BindValueKind
valueKind)
373
var
coreValueKind = valueKind & ValueKindSignificantBitsMask;
376
BindValueKind
.CompoundAssignment => AccessorKind.Both,
377
BindValueKind
.Assignable => AccessorKind.Set,
382
private BoundIndexerAccess BindIndexerDefaultArgumentsAndParamsCollection(BoundIndexerAccess indexerAccess,
BindValueKind
valueKind, BindingDiagnosticBag diagnostics)
384
var
coreValueKind = valueKind & ValueKindSignificantBitsMask;
386
var useSetAccessor = coreValueKind ==
BindValueKind
.Assignable && indexerAccess.Indexer.RefKind != RefKind.Ref;
481
private BoundExpression CheckValue(BoundExpression expr,
BindValueKind
valueKind, BindingDiagnosticBag diagnostics)
496
Debug.Assert(expr.Syntax.Kind() != SyntaxKind.Argument || valueKind ==
BindValueKind
.RefOrOut);
501
Debug.Assert(valueKind ==
BindValueKind
.RefOrOut);
505
Debug.Assert(valueKind is (
BindValueKind
.Assignable or
BindValueKind
.RefOrOut or
BindValueKind
.RefAssignable) || diagnostics.DiagnosticBag is null || diagnostics.HasAnyResolvedErrors());
553
if (valueKind ==
BindValueKind
.RValue)
560
if (valueKind ==
BindValueKind
.RValue)
567
if ((valueKind &
BindValueKind
.RefersToLocation) ==
BindValueKind
.RefersToLocation)
575
if ((valueKind &
BindValueKind
.RefersToLocation) ==
BindValueKind
.RefersToLocation)
589
if (expr.Kind == BoundKind.MethodGroup && valueKind !=
BindValueKind
.RValueOrMethodGroup)
637
expr.HasAnyErrors && valueKind ==
BindValueKind
.RValueOrMethodGroup)
642
var resultKind = (valueKind ==
BindValueKind
.RValue || valueKind ==
BindValueKind
.RValueOrMethodGroup) ?
674
internal bool CheckValueKind(SyntaxNode node, BoundExpression expr,
BindValueKind
valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
732
case BoundKind.MethodGroup when valueKind ==
BindValueKind
.AddressOf:
954
bool checkArrayAccessValueKind(SyntaxNode node,
BindValueKind
valueKind, ImmutableArray<BoundExpression> indices, BindingDiagnosticBag diagnostics)
976
private static void ReportThisLvalueError(SyntaxNode node,
BindValueKind
valueKind, bool isValueType, bool isPrimaryConstructorParameter, BindingDiagnosticBag diagnostics)
1004
private void CheckAddressOfInAsyncOrIteratorMethod(SyntaxNode node,
BindValueKind
valueKind, BindingDiagnosticBag diagnostics)
1006
if (valueKind ==
BindValueKind
.AddressOf)
1019
private bool CheckLocalValueKind(SyntaxNode node, BoundLocal local,
BindValueKind
valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
1109
private bool CheckParameterValueKind(SyntaxNode node, BoundParameter parameter,
BindValueKind
valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
1111
Debug.Assert(!RequiresAssignableVariable(
BindValueKind
.AddressOf));
1172
static void reportReadOnlyParameterError(ParameterSymbol parameterSymbol, SyntaxNode node,
BindValueKind
valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
1176
Debug.Assert(valueKind !=
BindValueKind
.AddressOf); // If this assert fails, we probably should report ErrorCode.ERR_InvalidAddrOp
1182
if (valueKind ==
BindValueKind
.RefReturn)
1201
if (valueKind ==
BindValueKind
.RefReturn)
1317
private bool CheckFieldValueKind(SyntaxNode node, BoundFieldAccess fieldAccess,
BindValueKind
valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
1363
Debug.Assert(valueKind ==
BindValueKind
.RefAssignable);
1372
return CheckIsValidReceiverForVariable(node, fieldAccess.ReceiverOpt,
BindValueKind
.Assignable, diagnostics);
1457
private bool CheckSimpleAssignmentValueKind(SyntaxNode node, BoundAssignmentOperator assignment,
BindValueKind
valueKind, BindingDiagnosticBag diagnostics)
1536
private bool CheckEventValueKind(BoundEventAccess boundEvent,
BindValueKind
valueKind, BindingDiagnosticBag diagnostics)
1547
if (valueKind ==
BindValueKind
.CompoundAssignment)
1573
if (!CheckIsValidReceiverForVariable(eventSyntax, receiver,
BindValueKind
.Assignable, diagnostics))
1580
if (eventSymbol.IsWindowsRuntimeEvent && valueKind !=
BindValueKind
.Assignable)
1584
if (valueKind ==
BindValueKind
.RefOrOut)
1605
private bool CheckIsValidReceiverForVariable(SyntaxNode node, BoundExpression receiver,
BindValueKind
kind, BindingDiagnosticBag diagnostics)
1635
BindValueKind
valueKind,
1676
private bool CheckPropertyValueKind(SyntaxNode node, BoundExpression expr,
BindValueKind
valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
1703
else if (valueKind ==
BindValueKind
.RefOrOut)
1774
var
setValueKind = setMethod.IsEffectivelyReadOnly ?
BindValueKind
.RValue :
BindValueKind
.Assignable;
3064
private static void ReportReadonlyLocalError(SyntaxNode node, LocalSymbol local,
BindValueKind
kind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
3067
Debug.Assert(kind !=
BindValueKind
.RValue);
3102
private static ErrorCode GetThisLvalueError(
BindValueKind
kind, bool isValueType, bool isPrimaryConstructorParameter)
3106
case
BindValueKind
.CompoundAssignment:
3107
case
BindValueKind
.Assignable:
3110
case
BindValueKind
.RefOrOut:
3113
case
BindValueKind
.AddressOf:
3116
case
BindValueKind
.IncrementDecrement:
3119
case
BindValueKind
.RefReturn:
3120
case
BindValueKind
.ReadonlyRef:
3123
case
BindValueKind
.RefAssignable:
3135
private static ErrorCode GetRangeLvalueError(
BindValueKind
kind)
3139
case
BindValueKind
.Assignable:
3140
case
BindValueKind
.CompoundAssignment:
3141
case
BindValueKind
.IncrementDecrement:
3144
case
BindValueKind
.AddressOf:
3147
case
BindValueKind
.RefReturn:
3148
case
BindValueKind
.ReadonlyRef:
3151
case
BindValueKind
.RefAssignable:
3163
private static ErrorCode GetMethodGroupOrFunctionPointerLvalueError(
BindValueKind
valueKind)
3174
private static ErrorCode GetStandardLvalueError(
BindValueKind
kind)
3178
case
BindValueKind
.CompoundAssignment:
3179
case
BindValueKind
.Assignable:
3182
case
BindValueKind
.AddressOf:
3185
case
BindValueKind
.IncrementDecrement:
3188
case
BindValueKind
.FixedReceiver:
3191
case
BindValueKind
.RefReturn:
3192
case
BindValueKind
.ReadonlyRef:
3195
case
BindValueKind
.RefAssignable:
3223
private static void ReportReadOnlyFieldError(FieldSymbol field, SyntaxNode node,
BindValueKind
kind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
3231
Debug.Assert(kind !=
BindValueKind
.AddressOf); // If this assert fails, we probably should report ErrorCode.ERR_InvalidAddrOp
3248
int index = (checkingReceiver ? 6 : 0) + (field.IsStatic ? 3 : 0) + (kind ==
BindValueKind
.RefReturn ? 0 : (RequiresRefOrOut(kind) ? 1 : 2));
3259
private static void ReportReadOnlyError(Symbol symbol, SyntaxNode node,
BindValueKind
kind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
3266
if (kind ==
BindValueKind
.AddressOf)
3284
int index = (checkingReceiver ? 3 : 0) + (kind ==
BindValueKind
.RefReturn ? 0 : (RequiresRefOrOut(kind) ? 1 : 2));
Binder\Binder_Attributes.cs (1)
561
BoundExpression namedArgumentValue = this.BindValue(namedArgument.Expression, diagnostics,
BindValueKind
.RValue);
Binder\Binder_Conversions.cs (3)
455
if (CheckValueKind(syntax, source,
BindValueKind
.RefersToLocation, checkingReceiver: false, BindingDiagnosticBag.Discarded))
470
if (CheckValueKind(syntax, source,
BindValueKind
.RefersToLocation |
BindValueKind
.Assignable, checkingReceiver: false, BindingDiagnosticBag.Discarded))
Binder\Binder_Deconstruct.cs (3)
99
BoundExpression boundRight = rightPlaceholder ?? BindValue(right, deconstructionDiagnostics,
BindValueKind
.RValue);
658
memberAccess = CheckValue(memberAccess,
BindValueKind
.RValueOrMethodGroup, diagnostics);
791
var checkedVariable = CheckValue(boundVariable,
BindValueKind
.Assignable, diagnostics);
Binder\Binder_Expressions.cs (54)
236
internal BoundExpression BindValue(ExpressionSyntax node, BindingDiagnosticBag diagnostics,
BindValueKind
valueKind)
244
return BindToNaturalType(BindValue(node, diagnostics,
BindValueKind
.RValue), diagnostics, reportNoTargetType);
261
return CheckValue(valueOrType,
BindValueKind
.RValue, diagnostics);
430
internal BoundExpression BindValueAllowArgList(ExpressionSyntax node, BindingDiagnosticBag diagnostics,
BindValueKind
valueKind)
475
BindValueKind
valueKind;
506
valueBeforeConversion = defaultValueBinder.BindValue(defaultValueSyntax.Value, diagnostics,
BindValueKind
.RValue);
524
var initializer = initializerBinder.BindValue(equalsValueSyntax.Value, diagnostics,
BindValueKind
.RValue);
854
node, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, ImmutableArray.Create<BoundExpression>(BindToTypeForErrorRecovery(BindValue(node.Expression, BindingDiagnosticBag.Discarded,
BindValueKind
.RefersToLocation))),
1006
ImmutableArray.Create(BindValue(arguments[0].Expression, diagnostics,
BindValueKind
.RValue)) :
1036
BoundExpression boundArgument = BindValue(argumentSyntax.Expression, diagnostics,
BindValueKind
.RValue);
1217
BoundExpression argument = BindValue(node.Expression, diagnostics,
BindValueKind
.RValue);
1240
BoundExpression argument = this.BindValue(node.Expression, diagnostics,
BindValueKind
.RefOrOut);
1265
BoundExpression argument = BindValue(node.Expression, diagnostics,
BindValueKind
.RValue);
2539
BoundExpression operand = this.BindValue(node.Expression, diagnostics,
BindValueKind
.RValue);
2564
BoundExpression boundOperand = BindValue(node.Operand, diagnostics,
BindValueKind
.RValue);
2672
BoundExpression boundOperand = BindValue(operand, diagnostics,
BindValueKind
.RValue);
3075
var
requiredValueKind = origRefKind == RefKind.In ?
BindValueKind
.ReadonlyRef :
BindValueKind
.RefOrOut;
3354
BindValueKind
valueKind =
3356
BindValueKind
.RValue :
3358
BindValueKind
.ReadonlyRef :
3359
BindValueKind
.RefOrOut;
3441
if (!this.CheckValueKind(argument.Syntax, argument,
BindValueKind
.RefersToLocation, checkingReceiver: false, BindingDiagnosticBag.Discarded))
3453
if (this.CheckValueKind(argument.Syntax, argument,
BindValueKind
.Assignable, checkingReceiver: false, BindingDiagnosticBag.Discarded))
4040
var size = BindValue(dimension, diagnostics,
BindValueKind
.RValue);
4156
var boundExpression = BindValue(expression, diagnostics,
BindValueKind
.RValue);
4173
var boundExpression = BindValue(expression, diagnostics,
BindValueKind
.RValue);
4502
count = BindValue(countSyntax, diagnostics,
BindValueKind
.RValue);
5217
ExpressionElementSyntax expressionElementSyntax => @this.BindValue(expressionElementSyntax.Expression, diagnostics,
BindValueKind
.RValue),
5591
BindValueKind
rhsValueKind,
5603
Debug.Assert(rhsValueKind ==
BindValueKind
.RValue);
5691
var
rhsKind = isRef ? GetRequiredRHSValueKindForRefAssignment(boundLeft) :
BindValueKind
.RValue;
5739
var boundExpression = BindValue(memberInitializer, diagnostics,
BindValueKind
.RValue);
5754
BindValueKind
valueKind = isRhsNestedInitializer ?
BindValueKind
.RValue : (isRef ?
BindValueKind
.RefAssignable :
BindValueKind
.Assignable);
5767
leftSyntax, implicitReceiver,
BindValueKind
.Assignable, false, diagnostics);
5774
BindValueKind
valueKind,
6016
BindValueKind
valueKind,
6050
return ToBadExpression(boundMember, (valueKind ==
BindValueKind
.RValue) ? LookupResultKind.NotAValue : LookupResultKind.NotAVariable);
6305
var boundElementInitializer = BindInitializerExpressionOrValue(elementInitializer, initializerType,
BindValueKind
.RValue, implicitReceiver.Syntax, diagnostics);
6334
exprBuilder.Add(BindValue(childElementInitializer, diagnostics,
BindValueKind
.RValue));
7624
boundLeft = CheckValue(boundLeft,
BindValueKind
.RValue, diagnostics);
7734
boundLeft = CheckValue(boundLeft,
BindValueKind
.RValue, diagnostics);
8576
hasError = !CheckValueKind(node, receiver,
BindValueKind
.FixedReceiver, checkingReceiver: false, diagnostics: diagnostics);
8989
receiver = CheckValue(receiver,
BindValueKind
.RValue, diagnostics);
9119
if (CheckValueKind(node, expr,
BindValueKind
.RefersToLocation |
BindValueKind
.Assignable, checkingReceiver: false, BindingDiagnosticBag.Discarded))
9131
if (!CheckValueKind(node, expr,
BindValueKind
.RefersToLocation, checkingReceiver: false, BindingDiagnosticBag.Discarded))
10154
lengthOrCountAccess = CheckValue(lengthOrCountAccess,
BindValueKind
.RValue, diagnostics);
10949
var access = conditionalAccessBinder.BindValue(node.WhenNotNull, diagnostics,
BindValueKind
.RValue);
Binder\Binder_InterpolatedString.cs (2)
90
var value = BindValue(interpolation.Expression, diagnostics,
BindValueKind
.RValue);
101
alignment = GenerateConversionForAssignment(intType, BindValue(interpolation.AlignmentClause.Value, diagnostics, Binder.
BindValueKind
.RValue), diagnostics);
Binder\Binder_Invocation.cs (8)
125
boundExpression = CheckValue(boundExpression,
BindValueKind
.RValueOrMethodGroup, diagnostics);
245
boundExpression = CheckValue(boundExpression,
BindValueKind
.RValueOrMethodGroup, diagnostics);
1230
receiverArgument = CheckValue(receiverArgument,
BindValueKind
.RefOrOut, diagnostics);
1341
var
valueKind = method.IsEffectivelyReadOnly
1342
?
BindValueKind
.RefersToLocation
1343
:
BindValueKind
.RefersToLocation |
BindValueKind
.Assignable;
1860
return CheckValue(typeOrValue.Data.ValueExpression,
BindValueKind
.RValue, diagnostics);
Binder\Binder_Operators.cs (24)
27
BoundExpression right = BindValue(node.Right, diagnostics,
BindValueKind
.RValue);
99
if (left.Kind == BoundKind.EventAccess && !CheckEventValueKind((BoundEventAccess)left,
BindValueKind
.Assignable, diagnostics))
494
BindValueKind
bindValueKind = GetBinaryAssignmentKind(syntaxNode.Kind());
496
BoundExpression right = BindValue(syntaxNode.Right, diagnostics,
BindValueKind
.RValue);
2264
BoundExpression operand = BindToNaturalType(BindValue(operandSyntax, diagnostics,
BindValueKind
.IncrementDecrement), diagnostics);
2512
BoundExpression operand = BindToNaturalType(BindValue(node.Operand, diagnostics,
BindValueKind
.AddressOf), diagnostics);
2599
bool receiverIsLValue = CheckValueKind(receiver.Syntax, receiver,
BindValueKind
.AddressOf, checkingReceiver: false, diagnostics: BindingDiagnosticBag.Discarded);
3024
private static
BindValueKind
GetBinaryAssignmentKind(SyntaxKind kind)
3029
return
BindValueKind
.Assignable;
3042
return
BindValueKind
.CompoundAssignment;
3044
return
BindValueKind
.RValue;
3048
private static
BindValueKind
GetUnaryAssignmentKind(SyntaxKind kind)
3056
return
BindValueKind
.IncrementDecrement;
3061
return
BindValueKind
.RValue;
3982
var leftOperand = BindValue(node.Left, diagnostics,
BindValueKind
.RValue);
3984
var rightOperand = BindValue(node.Right, diagnostics,
BindValueKind
.RValue);
4171
BoundExpression leftOperand = BindValue(node.Left, diagnostics,
BindValueKind
.CompoundAssignment);
4173
BoundExpression rightOperand = BindValue(node.Right, diagnostics,
BindValueKind
.RValue);
4300
BoundExpression trueExpr = BindValue(whenTrue, diagnostics,
BindValueKind
.RValue);
4301
BoundExpression falseExpr = BindValue(whenFalse, diagnostics,
BindValueKind
.RValue);
4341
BoundExpression trueExpr = BindValue(whenTrue, diagnostics,
BindValueKind
.RValue |
BindValueKind
.RefersToLocation);
4342
BoundExpression falseExpr = BindValue(whenFalse, diagnostics,
BindValueKind
.RValue |
BindValueKind
.RefersToLocation);
Binder\Binder_Patterns.cs (5)
239
indexerAccess = CheckValue(indexerAccess,
BindValueKind
.RValue, diagnostics);
388
indexerAccess = CheckValue(indexerAccess,
BindValueKind
.RValue, diagnostics);
536
expression = CheckValue(expression,
BindValueKind
.RValue, diagnostics);
1588
boundMember = CheckValue(boundMember,
BindValueKind
.RValue, diagnostics);
1601
if (!hasErrors && !CheckValueKind(node: memberName.Parent, expr: boundMember, valueKind:
BindValueKind
.RValue,
Binder\Binder_Query.cs (3)
837
BoundExpression boundExpression = lambdaBodyBinder.BindValue(expression, diagnostics,
BindValueKind
.RValue);
847
BoundExpression boundExpression = lambdaBodyBinder.BindValue(expression, diagnostics,
BindValueKind
.RValue);
1001
var checkedUltimateReceiver = CheckValue(ultimateReceiver,
BindValueKind
.RValue, diagnostics);
Binder\Binder_Statements.cs (28)
240
: BindValue(node.Expression, diagnostics,
BindValueKind
.RValue);
395
var boundExpr = BindValue(exprSyntax, diagnostics,
BindValueKind
.RValue);
864
BindValueKind
valueKind;
871
protected BoundExpression BindInferredVariableInitializer(BindingDiagnosticBag diagnostics, ExpressionSyntax initializer,
BindValueKind
valueKind, CSharpSyntaxNode errorSyntax)
912
out
BindValueKind
valueKind,
919
valueKind =
BindValueKind
.RValue;
929
?
BindValueKind
.ReadonlyRef
930
:
BindValueKind
.RefOrOut;
1005
BindValueKind
valueKind;
1417
var
lhsKind = isRef ?
BindValueKind
.RefAssignable :
BindValueKind
.Assignable;
1425
var
rhsKind = isRef ? GetRequiredRHSValueKindForRefAssignment(op1) :
BindValueKind
.RValue;
1438
private static
BindValueKind
GetRequiredRHSValueKindForRefAssignment(BoundExpression boundLeft)
1440
var
rhsKind =
BindValueKind
.RefersToLocation;
1450
rhsKind |=
BindValueKind
.Assignable;
1826
BindValueKind
valueKind,
2639
var expr = BindValue(node, diagnostics,
BindValueKind
.RValue);
2994
BindValueKind
requiredValueKind = GetRequiredReturnValueKind(refKind);
3575
BindValueKind
requiredValueKind = bodyBinder.GetRequiredReturnValueKind(refKind);
3591
BindValueKind
requiredValueKind = GetRequiredReturnValueKind(refKind);
3605
private
BindValueKind
GetRequiredReturnValueKind(RefKind refKind)
3607
BindValueKind
requiredValueKind =
BindValueKind
.RValue;
3612
BindValueKind
.RefReturn :
3613
BindValueKind
.ReadonlyRef;
Binder\ForEachLoopBinder.cs (9)
333
BindValueKind
requiredCurrentKind;
337
requiredCurrentKind =
BindValueKind
.RValue;
340
requiredCurrentKind =
BindValueKind
.Assignable |
BindValueKind
.RefersToLocation;
343
requiredCurrentKind =
BindValueKind
.RefersToLocation;
611
BoundExpression collectionExpr = this.GetBinder(collectionSyntax).BindValue(collectionSyntax, diagnostics,
BindValueKind
.RValue);
821
if (CheckValueKind(collectionExpr.Syntax, collectionExpr,
BindValueKind
.RefersToLocation |
BindValueKind
.Assignable, checkingReceiver: false, BindingDiagnosticBag.Discarded))
829
if (!CheckValueKind(collectionExpr.Syntax, collectionExpr,
BindValueKind
.RefersToLocation, checkingReceiver: false, BindingDiagnosticBag.Discarded))
Binder\LockOrUsingBinder.cs (1)
84
BoundExpression boundExpression = originalBinder.BindValue(TargetExpressionSyntax, expressionDiagnostics, Binder.
BindValueKind
.RValueOrMethodGroup);
Binder\SwitchBinder.cs (1)
497
gotoCaseExpressionOpt = gotoBinder.BindValue(node.Expression, diagnostics,
BindValueKind
.RValue);
Binder\SwitchExpressionArmBinder.cs (1)
46
BoundExpression armResult = armBinder.BindValue(node.Expression, diagnostics,
BindValueKind
.RValue);
Symbols\Source\SourceFixedFieldSymbol.cs (1)
92
binder.BindValue(sizeExpression, diagnostics, Binder.
BindValueKind
.RValue),