248 references to BindValueKind
Microsoft.CodeAnalysis.CSharp (248)
Binder\Binder.ValueChecks.cs (104)
250
private const
BindValueKind
ValueKindSignificantBitsMask = unchecked((
BindValueKind
)~((1 << ValueKindInsignificantBits) - 1));
347
private static bool RequiresRValueOnly(
BindValueKind
kind)
349
return (kind & ValueKindSignificantBitsMask) ==
BindValueKind
.RValue;
352
private static bool RequiresAssignmentOnly(
BindValueKind
kind)
354
return (kind & ValueKindSignificantBitsMask) ==
BindValueKind
.Assignable;
357
private static bool RequiresVariable(
BindValueKind
kind)
362
private static bool RequiresReferenceToLocation(
BindValueKind
kind)
364
return (kind &
BindValueKind
.RefersToLocation) != 0;
367
private static bool RequiresAssignableVariable(
BindValueKind
kind)
369
return (kind &
BindValueKind
.Assignable) != 0;
372
private static bool RequiresRefAssignableVariable(
BindValueKind
kind)
374
return (kind &
BindValueKind
.RefAssignable) != 0;
377
private static bool RequiresRefOrOut(
BindValueKind
kind)
379
return (kind &
BindValueKind
.RefOrOut) ==
BindValueKind
.RefOrOut;
384
private static AccessorKind GetIndexerAccessorKind(BoundIndexerAccess indexerAccess,
BindValueKind
valueKind)
394
private static AccessorKind GetAccessorKind(
BindValueKind
valueKind)
396
var
coreValueKind = valueKind & ValueKindSignificantBitsMask;
399
BindValueKind
.CompoundAssignment => AccessorKind.Both,
400
BindValueKind
.Assignable => AccessorKind.Set,
405
private BoundIndexerAccess BindIndexerDefaultArgumentsAndParamsCollection(BoundIndexerAccess indexerAccess,
BindValueKind
valueKind, BindingDiagnosticBag diagnostics)
407
var
coreValueKind = valueKind & ValueKindSignificantBitsMask;
409
var useSetAccessor = coreValueKind ==
BindValueKind
.Assignable && indexerAccess.Indexer.RefKind != RefKind.Ref;
504
private BoundExpression CheckValue(BoundExpression expr,
BindValueKind
valueKind, BindingDiagnosticBag diagnostics)
519
Debug.Assert(expr.Syntax.Kind() != SyntaxKind.Argument || valueKind ==
BindValueKind
.RefOrOut);
524
Debug.Assert(valueKind ==
BindValueKind
.RefOrOut);
528
Debug.Assert(valueKind is (
BindValueKind
.Assignable or
BindValueKind
.RefOrOut or
BindValueKind
.RefAssignable) || diagnostics.DiagnosticBag is null || diagnostics.HasAnyResolvedErrors());
576
if (valueKind ==
BindValueKind
.RValue)
583
if (valueKind ==
BindValueKind
.RValue)
590
if ((valueKind &
BindValueKind
.RefersToLocation) ==
BindValueKind
.RefersToLocation)
598
if ((valueKind &
BindValueKind
.RefersToLocation) ==
BindValueKind
.RefersToLocation)
612
if (expr.Kind == BoundKind.MethodGroup && valueKind !=
BindValueKind
.RValueOrMethodGroup)
660
expr.HasAnyErrors && valueKind ==
BindValueKind
.RValueOrMethodGroup)
665
var resultKind = (valueKind ==
BindValueKind
.RValue || valueKind ==
BindValueKind
.RValueOrMethodGroup) ?
697
internal bool CheckValueKind(SyntaxNode node, BoundExpression expr,
BindValueKind
valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
755
case BoundKind.MethodGroup when valueKind ==
BindValueKind
.AddressOf:
977
bool checkArrayAccessValueKind(SyntaxNode node,
BindValueKind
valueKind, ImmutableArray<BoundExpression> indices, BindingDiagnosticBag diagnostics)
999
private static void ReportThisLvalueError(SyntaxNode node,
BindValueKind
valueKind, bool isValueType, bool isPrimaryConstructorParameter, BindingDiagnosticBag diagnostics)
1027
private void CheckAddressOfInAsyncOrIteratorMethod(SyntaxNode node,
BindValueKind
valueKind, BindingDiagnosticBag diagnostics)
1029
if (valueKind ==
BindValueKind
.AddressOf)
1042
private bool CheckLocalValueKind(SyntaxNode node, BoundLocal local,
BindValueKind
valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
1132
private bool CheckParameterValueKind(SyntaxNode node, BoundParameter parameter,
BindValueKind
valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
1134
Debug.Assert(!RequiresAssignableVariable(
BindValueKind
.AddressOf));
1195
static void reportReadOnlyParameterError(ParameterSymbol parameterSymbol, SyntaxNode node,
BindValueKind
valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
1199
Debug.Assert(valueKind !=
BindValueKind
.AddressOf); // If this assert fails, we probably should report ErrorCode.ERR_InvalidAddrOp
1205
if (valueKind ==
BindValueKind
.RefReturn)
1224
if (valueKind ==
BindValueKind
.RefReturn)
1340
private bool CheckFieldValueKind(SyntaxNode node, BoundFieldAccess fieldAccess,
BindValueKind
valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
1386
Debug.Assert(valueKind ==
BindValueKind
.RefAssignable);
1395
return CheckIsValidReceiverForVariable(node, fieldAccess.ReceiverOpt,
BindValueKind
.Assignable, diagnostics);
1480
private bool CheckSimpleAssignmentValueKind(SyntaxNode node, BoundAssignmentOperator assignment,
BindValueKind
valueKind, BindingDiagnosticBag diagnostics)
1559
private bool CheckEventValueKind(BoundEventAccess boundEvent,
BindValueKind
valueKind, BindingDiagnosticBag diagnostics)
1570
if (valueKind ==
BindValueKind
.CompoundAssignment)
1596
if (!CheckIsValidReceiverForVariable(eventSyntax, receiver,
BindValueKind
.Assignable, diagnostics))
1603
if (eventSymbol.IsWindowsRuntimeEvent && valueKind !=
BindValueKind
.Assignable)
1607
if (valueKind ==
BindValueKind
.RefOrOut)
1628
private bool CheckIsValidReceiverForVariable(SyntaxNode node, BoundExpression receiver,
BindValueKind
kind, BindingDiagnosticBag diagnostics)
1658
BindValueKind
valueKind,
1699
private bool CheckPropertyValueKind(SyntaxNode node, BoundExpression expr,
BindValueKind
valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
1726
else if (valueKind ==
BindValueKind
.RefOrOut)
1797
var
setValueKind = setMethod.IsEffectivelyReadOnly ?
BindValueKind
.RValue :
BindValueKind
.Assignable;
3087
private static void ReportReadonlyLocalError(SyntaxNode node, LocalSymbol local,
BindValueKind
kind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
3090
Debug.Assert(kind !=
BindValueKind
.RValue);
3125
private static ErrorCode GetThisLvalueError(
BindValueKind
kind, bool isValueType, bool isPrimaryConstructorParameter)
3129
case
BindValueKind
.CompoundAssignment:
3130
case
BindValueKind
.Assignable:
3133
case
BindValueKind
.RefOrOut:
3136
case
BindValueKind
.AddressOf:
3139
case
BindValueKind
.IncrementDecrement:
3142
case
BindValueKind
.RefReturn:
3143
case
BindValueKind
.ReadonlyRef:
3146
case
BindValueKind
.RefAssignable:
3158
private static ErrorCode GetRangeLvalueError(
BindValueKind
kind)
3162
case
BindValueKind
.Assignable:
3163
case
BindValueKind
.CompoundAssignment:
3164
case
BindValueKind
.IncrementDecrement:
3167
case
BindValueKind
.AddressOf:
3170
case
BindValueKind
.RefReturn:
3171
case
BindValueKind
.ReadonlyRef:
3174
case
BindValueKind
.RefAssignable:
3186
private static ErrorCode GetMethodGroupOrFunctionPointerLvalueError(
BindValueKind
valueKind)
3197
private static ErrorCode GetStandardLvalueError(
BindValueKind
kind)
3201
case
BindValueKind
.CompoundAssignment:
3202
case
BindValueKind
.Assignable:
3205
case
BindValueKind
.AddressOf:
3208
case
BindValueKind
.IncrementDecrement:
3211
case
BindValueKind
.FixedReceiver:
3214
case
BindValueKind
.RefReturn:
3215
case
BindValueKind
.ReadonlyRef:
3218
case
BindValueKind
.RefAssignable:
3246
private static void ReportReadOnlyFieldError(FieldSymbol field, SyntaxNode node,
BindValueKind
kind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
3254
Debug.Assert(kind !=
BindValueKind
.AddressOf); // If this assert fails, we probably should report ErrorCode.ERR_InvalidAddrOp
3271
int index = (checkingReceiver ? 6 : 0) + (field.IsStatic ? 3 : 0) + (kind ==
BindValueKind
.RefReturn ? 0 : (RequiresRefOrOut(kind) ? 1 : 2));
3282
private static void ReportReadOnlyError(Symbol symbol, SyntaxNode node,
BindValueKind
kind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
3289
if (kind ==
BindValueKind
.AddressOf)
3307
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);
2536
BoundExpression operand = this.BindValue(node.Expression, diagnostics,
BindValueKind
.RValue);
2561
BoundExpression boundOperand = BindValue(node.Operand, diagnostics,
BindValueKind
.RValue);
2669
BoundExpression boundOperand = BindValue(operand, diagnostics,
BindValueKind
.RValue);
3072
var
requiredValueKind = origRefKind == RefKind.In ?
BindValueKind
.ReadonlyRef :
BindValueKind
.RefOrOut;
3351
BindValueKind
valueKind =
3353
BindValueKind
.RValue :
3355
BindValueKind
.ReadonlyRef :
3356
BindValueKind
.RefOrOut;
3438
if (!this.CheckValueKind(argument.Syntax, argument,
BindValueKind
.RefersToLocation, checkingReceiver: false, BindingDiagnosticBag.Discarded))
3450
if (this.CheckValueKind(argument.Syntax, argument,
BindValueKind
.Assignable, checkingReceiver: false, BindingDiagnosticBag.Discarded))
4037
var size = BindValue(dimension, diagnostics,
BindValueKind
.RValue);
4153
var boundExpression = BindValue(expression, diagnostics,
BindValueKind
.RValue);
4170
var boundExpression = BindValue(expression, diagnostics,
BindValueKind
.RValue);
4499
count = BindValue(countSyntax, diagnostics,
BindValueKind
.RValue);
5214
ExpressionElementSyntax expressionElementSyntax => @this.BindValue(expressionElementSyntax.Expression, diagnostics,
BindValueKind
.RValue),
5588
BindValueKind
rhsValueKind,
5600
Debug.Assert(rhsValueKind ==
BindValueKind
.RValue);
5688
var
rhsKind = isRef ? GetRequiredRHSValueKindForRefAssignment(boundLeft) :
BindValueKind
.RValue;
5736
var boundExpression = BindValue(memberInitializer, diagnostics,
BindValueKind
.RValue);
5751
BindValueKind
valueKind = isRhsNestedInitializer ?
BindValueKind
.RValue : (isRef ?
BindValueKind
.RefAssignable :
BindValueKind
.Assignable);
5764
leftSyntax, implicitReceiver,
BindValueKind
.Assignable, false, diagnostics);
5771
BindValueKind
valueKind,
6013
BindValueKind
valueKind,
6047
return ToBadExpression(boundMember, (valueKind ==
BindValueKind
.RValue) ? LookupResultKind.NotAValue : LookupResultKind.NotAVariable);
6302
var boundElementInitializer = BindInitializerExpressionOrValue(elementInitializer, initializerType,
BindValueKind
.RValue, implicitReceiver.Syntax, diagnostics);
6331
exprBuilder.Add(BindValue(childElementInitializer, diagnostics,
BindValueKind
.RValue));
7621
boundLeft = CheckValue(boundLeft,
BindValueKind
.RValue, diagnostics);
7731
boundLeft = CheckValue(boundLeft,
BindValueKind
.RValue, diagnostics);
8573
hasError = !CheckValueKind(node, receiver,
BindValueKind
.FixedReceiver, checkingReceiver: false, diagnostics: diagnostics);
8986
receiver = CheckValue(receiver,
BindValueKind
.RValue, diagnostics);
9116
if (CheckValueKind(node, expr,
BindValueKind
.RefersToLocation |
BindValueKind
.Assignable, checkingReceiver: false, BindingDiagnosticBag.Discarded))
9128
if (!CheckValueKind(node, expr,
BindValueKind
.RefersToLocation, checkingReceiver: false, BindingDiagnosticBag.Discarded))
10151
lengthOrCountAccess = CheckValue(lengthOrCountAccess,
BindValueKind
.RValue, diagnostics);
10946
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;
1823
BindValueKind
valueKind,
2636
var expr = BindValue(node, diagnostics,
BindValueKind
.RValue);
2991
BindValueKind
requiredValueKind = GetRequiredReturnValueKind(refKind);
3572
BindValueKind
requiredValueKind = bodyBinder.GetRequiredReturnValueKind(refKind);
3588
BindValueKind
requiredValueKind = GetRequiredReturnValueKind(refKind);
3602
private
BindValueKind
GetRequiredReturnValueKind(RefKind refKind)
3604
BindValueKind
requiredValueKind =
BindValueKind
.RValue;
3609
BindValueKind
.RefReturn :
3610
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),