Binder\Binder_Operators.cs (301)
28BinaryOperatorKind kind = SyntaxKindToBinaryOperatorKind(node.Kind());
35BinaryOperatorKind kindOperator = kind.Operator();
38case BinaryOperatorKind.Addition:
39case BinaryOperatorKind.Subtraction:
59if (IsLegalDynamicOperand(right) && IsLegalDynamicOperand(left) && kind != BinaryOperatorKind.UnsignedRightShift)
74kind.WithType(BinaryOperatorKind.Dynamic).WithOverflowChecksIfApplicable(CheckOverflowAtRuntime),
180isUnsignedRightShift: bestSignature.Kind.Operator() == BinaryOperatorKind.UnsignedRightShift, bestSignature.ConstrainedToTypeOpt, diagnostics);
258private BoundExpression BindEventAssignment(AssignmentExpressionSyntax node, BoundEventAccess left, BoundExpression right, BinaryOperatorKind opKind, BindingDiagnosticBag diagnostics)
260Debug.Assert(opKind == BinaryOperatorKind.Addition || opKind == BinaryOperatorKind.Subtraction);
283bool isAddition = opKind == BinaryOperatorKind.Addition;
368BinaryOperatorKind kind,
381if (!leftValidOperand || !rightValidOperand || kind == BinaryOperatorKind.UnsignedRightShift)
395if (!IsValidDynamicCondition(left, isNegative: kind == BinaryOperatorKind.LogicalAnd, diagnostics, userDefinedOperator: out userDefinedOperator))
399Error(diagnostics, ErrorCode.ERR_InvalidDynamicCondition, node.Left, left.Type, kind == BinaryOperatorKind.LogicalAnd ? "false" : "true");
412operatorKind: (hasError ? kind : kind.WithType(BinaryOperatorKind.Dynamic)).WithOverflowChecksIfApplicable(CheckOverflowAtRuntime),
508BinaryOperatorKind kind = SyntaxKindToBinaryOperatorKind(node.Kind());
539bool isEquality = kind == BinaryOperatorKind.Equal || kind == BinaryOperatorKind.NotEqual;
542return new BoundLiteral(node, ConstantValue.Create(kind == BinaryOperatorKind.Equal), GetSpecialType(SpecialType.System_Boolean, diagnostics, node));
546(kind == BinaryOperatorKind.Equal || kind == BinaryOperatorKind.NotEqual))
553&& kind == BinaryOperatorKind.Addition
558var stringConstant = FoldBinaryOperator(node, BinaryOperatorKind.StringConcatenation, left, right, right.Type, diagnostics);
559return new BoundBinaryOperator(node, BinaryOperatorKind.StringConcatenation, BoundBinaryOperator.UncommonData.UnconvertedInterpolatedStringAddition(stringConstant), LookupResultKind.Empty, left, right, right.Type);
584BinaryOperatorKind resultOperatorKind = signature.Kind;
589resultOperatorKind &= ~BinaryOperatorKind.TypeMask;
605if ((resultOperatorKind & BinaryOperatorKind.Pointer) == BinaryOperatorKind.Pointer &&
627isUnsignedRightShift: resultOperatorKind.Operator() == BinaryOperatorKind.UnsignedRightShift, signature.ConstrainedToTypeOpt, diagnostics);
635if (foundOperator && (resultOperatorKind.OperandTypes() != BinaryOperatorKind.NullableNull))
642resultOperatorKind is BinaryOperatorKind.ObjectEqual or BinaryOperatorKind.ObjectNotEqual &&
698private bool BindSimpleBinaryOperatorParts(BinaryExpressionSyntax node, BindingDiagnosticBag diagnostics, BoundExpression left, BoundExpression right, BinaryOperatorKind kind,
721bool isObjectEquality = signature.Kind == BinaryOperatorKind.ObjectEqual || signature.Kind == BinaryOperatorKind.ObjectNotEqual;
730(signature.Kind.Operator() == BinaryOperatorKind.Equal || signature.Kind.Operator() == BinaryOperatorKind.NotEqual) &&
736resultSignature = new BinaryOperatorSignature(kind | BinaryOperatorKind.NullableNull, leftType: null, rightType: null,
812private void ReportAssignmentOperatorError(AssignmentExpressionSyntax node, BinaryOperatorKind kind, BindingDiagnosticBag diagnostics, BoundExpression left, BoundExpression right, LookupResultKind resultKind)
928BinaryOperatorKind kind = SyntaxKindToBinaryOperatorKind(node.Kind());
930Debug.Assert(kind == BinaryOperatorKind.LogicalAnd || kind == BinaryOperatorKind.LogicalOr);
939var constantValue = FoldBinaryOperator(node, kind | BinaryOperatorKind.Bool, left, right, left.Type, diagnostics);
942return new BoundBinaryOperator(node, kind | BinaryOperatorKind.Bool, constantValue, methodOpt: null, constrainedToTypeOpt: null,
1000var resultKind = kind | signature.Kind.OperandTypes();
1003resultKind |= BinaryOperatorKind.Lifted;
1011CheckConstraintLanguageVersionAndRuntimeSupportForOperator(node, kind == BinaryOperatorKind.LogicalAnd ? falseOperator : trueOperator,
1106Debug.Assert(signature.Kind.OperandTypes() == BinaryOperatorKind.UserDefined);
1295private TypeSymbol GetBinaryOperatorErrorType(BinaryOperatorKind kind, BindingDiagnosticBag diagnostics, CSharpSyntaxNode node)
1299case BinaryOperatorKind.Equal:
1300case BinaryOperatorKind.NotEqual:
1301case BinaryOperatorKind.GreaterThan:
1302case BinaryOperatorKind.LessThan:
1303case BinaryOperatorKind.GreaterThanOrEqual:
1304case BinaryOperatorKind.LessThanOrEqual:
1312BinaryOperatorKind kind,
1391private bool IsTypelessExpressionAllowedInBinaryOperator(BinaryOperatorKind kind, BoundExpression left, BoundExpression right)
1402bool isEquality = kind == BinaryOperatorKind.Equal || kind == BinaryOperatorKind.NotEqual;
1492private static object FoldDecimalBinaryOperators(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
1508case BinaryOperatorKind.DecimalAddition:
1510case BinaryOperatorKind.DecimalSubtraction:
1512case BinaryOperatorKind.DecimalMultiplication:
1514case BinaryOperatorKind.DecimalDivision:
1516case BinaryOperatorKind.DecimalRemainder:
1523private static object FoldNativeIntegerOverflowingBinaryOperator(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
1532case BinaryOperatorKind.NIntAddition:
1534case BinaryOperatorKind.NUIntAddition:
1536case BinaryOperatorKind.NIntSubtraction:
1538case BinaryOperatorKind.NUIntSubtraction:
1540case BinaryOperatorKind.NIntMultiplication:
1542case BinaryOperatorKind.NUIntMultiplication:
1544case BinaryOperatorKind.NIntDivision:
1546case BinaryOperatorKind.NIntRemainder:
1548case BinaryOperatorKind.NIntLeftShift:
1554case BinaryOperatorKind.NUIntLeftShift:
1566private static object FoldUncheckedIntegralBinaryOperator(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
1575case BinaryOperatorKind.IntAddition:
1577case BinaryOperatorKind.LongAddition:
1579case BinaryOperatorKind.UIntAddition:
1581case BinaryOperatorKind.ULongAddition:
1583case BinaryOperatorKind.IntSubtraction:
1585case BinaryOperatorKind.LongSubtraction:
1587case BinaryOperatorKind.UIntSubtraction:
1589case BinaryOperatorKind.ULongSubtraction:
1591case BinaryOperatorKind.IntMultiplication:
1593case BinaryOperatorKind.LongMultiplication:
1595case BinaryOperatorKind.UIntMultiplication:
1597case BinaryOperatorKind.ULongMultiplication:
1601case BinaryOperatorKind.IntDivision:
1609case BinaryOperatorKind.LongDivision:
1622private static object FoldCheckedIntegralBinaryOperator(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
1631case BinaryOperatorKind.IntAddition:
1633case BinaryOperatorKind.LongAddition:
1635case BinaryOperatorKind.UIntAddition:
1637case BinaryOperatorKind.ULongAddition:
1639case BinaryOperatorKind.IntSubtraction:
1641case BinaryOperatorKind.LongSubtraction:
1643case BinaryOperatorKind.UIntSubtraction:
1645case BinaryOperatorKind.ULongSubtraction:
1647case BinaryOperatorKind.IntMultiplication:
1649case BinaryOperatorKind.LongMultiplication:
1651case BinaryOperatorKind.UIntMultiplication:
1653case BinaryOperatorKind.ULongMultiplication:
1655case BinaryOperatorKind.IntDivision:
1657case BinaryOperatorKind.LongDivision:
1665internal static TypeSymbol GetEnumType(BinaryOperatorKind kind, BoundExpression left, BoundExpression right)
1669case BinaryOperatorKind.EnumAndUnderlyingAddition:
1670case BinaryOperatorKind.EnumAndUnderlyingSubtraction:
1671case BinaryOperatorKind.EnumAnd:
1672case BinaryOperatorKind.EnumOr:
1673case BinaryOperatorKind.EnumXor:
1674case BinaryOperatorKind.EnumEqual:
1675case BinaryOperatorKind.EnumGreaterThan:
1676case BinaryOperatorKind.EnumGreaterThanOrEqual:
1677case BinaryOperatorKind.EnumLessThan:
1678case BinaryOperatorKind.EnumLessThanOrEqual:
1679case BinaryOperatorKind.EnumNotEqual:
1680case BinaryOperatorKind.EnumSubtraction:
1682case BinaryOperatorKind.UnderlyingAndEnumAddition:
1683case BinaryOperatorKind.UnderlyingAndEnumSubtraction:
1714BinaryOperatorKind kind,
1748BinaryOperatorKind newKind = kind.Operator().WithType(newLeftOperand.Type!.SpecialType);
1752case BinaryOperatorKind.Addition:
1753case BinaryOperatorKind.Subtraction:
1754case BinaryOperatorKind.And:
1755case BinaryOperatorKind.Or:
1756case BinaryOperatorKind.Xor:
1760case BinaryOperatorKind.LessThan:
1761case BinaryOperatorKind.LessThanOrEqual:
1762case BinaryOperatorKind.GreaterThan:
1763case BinaryOperatorKind.GreaterThanOrEqual:
1764case BinaryOperatorKind.Equal:
1765case BinaryOperatorKind.NotEqual:
1777TypeSymbol resultType = kind == BinaryOperatorKind.EnumSubtraction ? underlyingType : enumType;
1789BinaryOperatorKind kind,
1944private static ConstantValue? TryFoldingNullableEquality(BinaryOperatorKind kind, BoundExpression left, BoundExpression right)
1948BinaryOperatorKind op = kind.Operator();
1949if (op == BinaryOperatorKind.Equal || op == BinaryOperatorKind.NotEqual)
1966return (leftIsNull == rightIsNull) == (op == BinaryOperatorKind.Equal) ? ConstantValue.True : ConstantValue.False;
1977private static object? FoldNeverOverflowBinaryOperators(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
1986case BinaryOperatorKind.ObjectEqual:
1990case BinaryOperatorKind.ObjectNotEqual:
1994case BinaryOperatorKind.DoubleAddition:
1996case BinaryOperatorKind.FloatAddition:
1998case BinaryOperatorKind.DoubleSubtraction:
2000case BinaryOperatorKind.FloatSubtraction:
2002case BinaryOperatorKind.DoubleMultiplication:
2004case BinaryOperatorKind.FloatMultiplication:
2006case BinaryOperatorKind.DoubleDivision:
2008case BinaryOperatorKind.FloatDivision:
2010case BinaryOperatorKind.DoubleRemainder:
2012case BinaryOperatorKind.FloatRemainder:
2014case BinaryOperatorKind.IntLeftShift:
2016case BinaryOperatorKind.LongLeftShift:
2018case BinaryOperatorKind.UIntLeftShift:
2020case BinaryOperatorKind.ULongLeftShift:
2022case BinaryOperatorKind.IntRightShift:
2023case BinaryOperatorKind.NIntRightShift:
2025case BinaryOperatorKind.IntUnsignedRightShift:
2027case BinaryOperatorKind.NIntUnsignedRightShift:
2029case BinaryOperatorKind.LongRightShift:
2031case BinaryOperatorKind.LongUnsignedRightShift:
2033case BinaryOperatorKind.UIntRightShift:
2034case BinaryOperatorKind.NUIntRightShift:
2035case BinaryOperatorKind.UIntUnsignedRightShift:
2036case BinaryOperatorKind.NUIntUnsignedRightShift:
2038case BinaryOperatorKind.ULongRightShift:
2039case BinaryOperatorKind.ULongUnsignedRightShift:
2041case BinaryOperatorKind.BoolAnd:
2043case BinaryOperatorKind.IntAnd:
2044case BinaryOperatorKind.NIntAnd:
2046case BinaryOperatorKind.LongAnd:
2048case BinaryOperatorKind.UIntAnd:
2049case BinaryOperatorKind.NUIntAnd:
2051case BinaryOperatorKind.ULongAnd:
2053case BinaryOperatorKind.BoolOr:
2055case BinaryOperatorKind.IntOr:
2056case BinaryOperatorKind.NIntOr:
2058case BinaryOperatorKind.LongOr:
2060case BinaryOperatorKind.UIntOr:
2061case BinaryOperatorKind.NUIntOr:
2063case BinaryOperatorKind.ULongOr:
2065case BinaryOperatorKind.BoolXor:
2067case BinaryOperatorKind.IntXor:
2068case BinaryOperatorKind.NIntXor:
2070case BinaryOperatorKind.LongXor:
2072case BinaryOperatorKind.UIntXor:
2073case BinaryOperatorKind.NUIntXor:
2075case BinaryOperatorKind.ULongXor:
2077case BinaryOperatorKind.LogicalBoolAnd:
2079case BinaryOperatorKind.LogicalBoolOr:
2081case BinaryOperatorKind.BoolEqual:
2083case BinaryOperatorKind.StringEqual:
2085case BinaryOperatorKind.DecimalEqual:
2087case BinaryOperatorKind.FloatEqual:
2089case BinaryOperatorKind.DoubleEqual:
2091case BinaryOperatorKind.IntEqual:
2092case BinaryOperatorKind.NIntEqual:
2094case BinaryOperatorKind.LongEqual:
2096case BinaryOperatorKind.UIntEqual:
2097case BinaryOperatorKind.NUIntEqual:
2099case BinaryOperatorKind.ULongEqual:
2101case BinaryOperatorKind.BoolNotEqual:
2103case BinaryOperatorKind.StringNotEqual:
2105case BinaryOperatorKind.DecimalNotEqual:
2107case BinaryOperatorKind.FloatNotEqual:
2109case BinaryOperatorKind.DoubleNotEqual:
2111case BinaryOperatorKind.IntNotEqual:
2112case BinaryOperatorKind.NIntNotEqual:
2114case BinaryOperatorKind.LongNotEqual:
2116case BinaryOperatorKind.UIntNotEqual:
2117case BinaryOperatorKind.NUIntNotEqual:
2119case BinaryOperatorKind.ULongNotEqual:
2121case BinaryOperatorKind.DecimalLessThan:
2123case BinaryOperatorKind.FloatLessThan:
2125case BinaryOperatorKind.DoubleLessThan:
2127case BinaryOperatorKind.IntLessThan:
2128case BinaryOperatorKind.NIntLessThan:
2130case BinaryOperatorKind.LongLessThan:
2132case BinaryOperatorKind.UIntLessThan:
2133case BinaryOperatorKind.NUIntLessThan:
2135case BinaryOperatorKind.ULongLessThan:
2137case BinaryOperatorKind.DecimalGreaterThan:
2139case BinaryOperatorKind.FloatGreaterThan:
2141case BinaryOperatorKind.DoubleGreaterThan:
2143case BinaryOperatorKind.IntGreaterThan:
2144case BinaryOperatorKind.NIntGreaterThan:
2146case BinaryOperatorKind.LongGreaterThan:
2148case BinaryOperatorKind.UIntGreaterThan:
2149case BinaryOperatorKind.NUIntGreaterThan:
2151case BinaryOperatorKind.ULongGreaterThan:
2153case BinaryOperatorKind.DecimalLessThanOrEqual:
2155case BinaryOperatorKind.FloatLessThanOrEqual:
2157case BinaryOperatorKind.DoubleLessThanOrEqual:
2159case BinaryOperatorKind.IntLessThanOrEqual:
2160case BinaryOperatorKind.NIntLessThanOrEqual:
2162case BinaryOperatorKind.LongLessThanOrEqual:
2164case BinaryOperatorKind.UIntLessThanOrEqual:
2165case BinaryOperatorKind.NUIntLessThanOrEqual:
2167case BinaryOperatorKind.ULongLessThanOrEqual:
2169case BinaryOperatorKind.DecimalGreaterThanOrEqual:
2171case BinaryOperatorKind.FloatGreaterThanOrEqual:
2173case BinaryOperatorKind.DoubleGreaterThanOrEqual:
2175case BinaryOperatorKind.IntGreaterThanOrEqual:
2176case BinaryOperatorKind.NIntGreaterThanOrEqual:
2178case BinaryOperatorKind.LongGreaterThanOrEqual:
2180case BinaryOperatorKind.UIntGreaterThanOrEqual:
2181case BinaryOperatorKind.NUIntGreaterThanOrEqual:
2183case BinaryOperatorKind.ULongGreaterThanOrEqual:
2185case BinaryOperatorKind.UIntDivision:
2186case BinaryOperatorKind.NUIntDivision:
2188case BinaryOperatorKind.ULongDivision:
2192case BinaryOperatorKind.IntRemainder:
2194case BinaryOperatorKind.LongRemainder:
2196case BinaryOperatorKind.UIntRemainder:
2197case BinaryOperatorKind.NUIntRemainder:
2199case BinaryOperatorKind.ULongRemainder:
2209private static ConstantValue? FoldStringConcatenation(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
2214if (kind == BinaryOperatorKind.StringConcatenation)
2227public static BinaryOperatorKind SyntaxKindToBinaryOperatorKind(SyntaxKind kind)
2232case SyntaxKind.MultiplyExpression: return BinaryOperatorKind.Multiplication;
2234case SyntaxKind.DivideExpression: return BinaryOperatorKind.Division;
2236case SyntaxKind.ModuloExpression: return BinaryOperatorKind.Remainder;
2238case SyntaxKind.AddExpression: return BinaryOperatorKind.Addition;
2240case SyntaxKind.SubtractExpression: return BinaryOperatorKind.Subtraction;
2242case SyntaxKind.RightShiftExpression: return BinaryOperatorKind.RightShift;
2244case SyntaxKind.UnsignedRightShiftExpression: return BinaryOperatorKind.UnsignedRightShift;
2246case SyntaxKind.LeftShiftExpression: return BinaryOperatorKind.LeftShift;
2247case SyntaxKind.EqualsExpression: return BinaryOperatorKind.Equal;
2248case SyntaxKind.NotEqualsExpression: return BinaryOperatorKind.NotEqual;
2249case SyntaxKind.GreaterThanExpression: return BinaryOperatorKind.GreaterThan;
2250case SyntaxKind.LessThanExpression: return BinaryOperatorKind.LessThan;
2251case SyntaxKind.GreaterThanOrEqualExpression: return BinaryOperatorKind.GreaterThanOrEqual;
2252case SyntaxKind.LessThanOrEqualExpression: return BinaryOperatorKind.LessThanOrEqual;
2254case SyntaxKind.BitwiseAndExpression: return BinaryOperatorKind.And;
2256case SyntaxKind.BitwiseOrExpression: return BinaryOperatorKind.Or;
2258case SyntaxKind.ExclusiveOrExpression: return BinaryOperatorKind.Xor;
2259case SyntaxKind.LogicalAndExpression: return BinaryOperatorKind.LogicalAnd;
2260case SyntaxKind.LogicalOrExpression: return BinaryOperatorKind.LogicalOr;
3130private static bool IsDivisionByZero(BinaryOperatorKind kind, ConstantValue valueRight)
3136case BinaryOperatorKind.DecimalDivision:
3137case BinaryOperatorKind.DecimalRemainder:
3139case BinaryOperatorKind.IntDivision:
3140case BinaryOperatorKind.IntRemainder:
3141case BinaryOperatorKind.NIntDivision:
3142case BinaryOperatorKind.NIntRemainder:
3144case BinaryOperatorKind.LongDivision:
3145case BinaryOperatorKind.LongRemainder:
3147case BinaryOperatorKind.UIntDivision:
3148case BinaryOperatorKind.UIntRemainder:
3149case BinaryOperatorKind.NUIntDivision:
3150case BinaryOperatorKind.NUIntRemainder:
3152case BinaryOperatorKind.ULongDivision:
3153case BinaryOperatorKind.ULongRemainder:
4439private void CheckNativeIntegerFeatureAvailability(BinaryOperatorKind operatorKind, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
4446switch (operatorKind & BinaryOperatorKind.TypeMask)
4448case BinaryOperatorKind.NInt:
4449case BinaryOperatorKind.NUInt:
Binder\Binder_Patterns.cs (32)
1635BinaryOperatorKind operation = tokenKindToBinaryOperatorKind(node.OperatorToken.Kind());
1636if (operation == BinaryOperatorKind.Equal)
1642BinaryOperatorKind opType = RelationalOperatorType(type.EnumUnderlyingTypeOrSelf());
1645case BinaryOperatorKind.Float:
1646case BinaryOperatorKind.Double:
1653case BinaryOperatorKind.String:
1654case BinaryOperatorKind.Bool:
1655case BinaryOperatorKind.Error:
1679static BinaryOperatorKind tokenKindToBinaryOperatorKind(SyntaxKind kind) => kind switch
1681SyntaxKind.LessThanEqualsToken => BinaryOperatorKind.LessThanOrEqual,
1682SyntaxKind.LessThanToken => BinaryOperatorKind.LessThan,
1683SyntaxKind.GreaterThanToken => BinaryOperatorKind.GreaterThan,
1684SyntaxKind.GreaterThanEqualsToken => BinaryOperatorKind.GreaterThanOrEqual,
1686_ => BinaryOperatorKind.Equal,
1695internal static BinaryOperatorKind RelationalOperatorType(TypeSymbol type) => type.SpecialType switch
1697SpecialType.System_Single => BinaryOperatorKind.Float,
1698SpecialType.System_Double => BinaryOperatorKind.Double,
1699SpecialType.System_Char => BinaryOperatorKind.Char,
1700SpecialType.System_SByte => BinaryOperatorKind.Int, // operands are converted to int
1701SpecialType.System_Byte => BinaryOperatorKind.Int, // operands are converted to int
1702SpecialType.System_UInt16 => BinaryOperatorKind.Int, // operands are converted to int
1703SpecialType.System_Int16 => BinaryOperatorKind.Int, // operands are converted to int
1704SpecialType.System_Int32 => BinaryOperatorKind.Int,
1705SpecialType.System_UInt32 => BinaryOperatorKind.UInt,
1706SpecialType.System_Int64 => BinaryOperatorKind.Long,
1707SpecialType.System_UInt64 => BinaryOperatorKind.ULong,
1708SpecialType.System_Decimal => BinaryOperatorKind.Decimal,
1709SpecialType.System_String => BinaryOperatorKind.String,
1710SpecialType.System_Boolean => BinaryOperatorKind.Bool,
1711SpecialType.System_IntPtr when type.IsNativeIntegerType => BinaryOperatorKind.NInt,
1712SpecialType.System_UIntPtr when type.IsNativeIntegerType => BinaryOperatorKind.NUInt,
1713_ => BinaryOperatorKind.Error,
Binder\Binder_TupleOperators.cs (9)
25private BoundTupleBinaryOperator BindTupleBinaryOperator(BinaryExpressionSyntax node, BinaryOperatorKind kind,
82private TupleBinaryOperatorInfo BindTupleBinaryOperatorInfo(BinaryExpressionSyntax node, BinaryOperatorKind kind,
125private void PrepareBoolConversionAndTruthOperator(TypeSymbol type, BinaryExpressionSyntax node, BinaryOperatorKind binaryOperator, BindingDiagnosticBag diagnostics,
148case BinaryOperatorKind.Equal:
151case BinaryOperatorKind.NotEqual:
179private TupleBinaryOperatorInfo BindTupleDynamicBinaryOperatorSingleInfo(BinaryExpressionSyntax node, BinaryOperatorKind kind,
193BinaryOperatorKind elementOperatorKind = hasError ? kind : kind.WithType(BinaryOperatorKind.Dynamic);
202private TupleBinaryOperatorInfo.Multiple BindTupleBinaryOperatorNestedInfo(BinaryExpressionSyntax node, BinaryOperatorKind kind,
Binder\DecisionDagBuilder.cs (15)
502if (ValueSetFactory.ForInput(input)?.Related(BinaryOperatorKind.Equal, constant.ConstantValue).IsEmpty == true)
1141return resultForRelation(BinaryOperatorKind.Equal, t.Value);
1153resultForRelation(BinaryOperatorKind relation, ConstantValue value)
1353handleRelationWithValue(BinaryOperatorKind.Equal, v2.Value,
1358BinaryOperatorKind relation,
1493if (lengthValues.All(BinaryOperatorKind.Equal, lengthValue))
1499if (!_forLowering && lengthValues.Any(BinaryOperatorKind.Equal, lengthValue))
1755BinaryOperatorKind.LessThan => "<",
1756BinaryOperatorKind.LessThanOrEqual => "<=",
1757BinaryOperatorKind.GreaterThan => ">",
1758BinaryOperatorKind.GreaterThanOrEqual => ">=",
2225Debug.Assert(t.Relation == BinaryOperatorKind.GreaterThanOrEqual);
2240return knownResult(BinaryOperatorKind.Equal, t.Value, offset) ??
2252static Tests? knownResult(BinaryOperatorKind relation, ConstantValue constant, int offset)
2255var possibleValues = fac.Related(BinaryOperatorKind.LessThanOrEqual, int.MaxValue - offset);
Binder\Semantics\Operators\BinaryOperatorEasyOut.cs (78)
14private const BinaryOperatorKind ERR = BinaryOperatorKind.Error;
15private const BinaryOperatorKind OBJ = BinaryOperatorKind.Object;
16private const BinaryOperatorKind STR = BinaryOperatorKind.String;
17private const BinaryOperatorKind OSC = BinaryOperatorKind.ObjectAndString;
18private const BinaryOperatorKind SOC = BinaryOperatorKind.StringAndObject;
19private const BinaryOperatorKind INT = BinaryOperatorKind.Int;
20private const BinaryOperatorKind UIN = BinaryOperatorKind.UInt;
21private const BinaryOperatorKind LNG = BinaryOperatorKind.Long;
22private const BinaryOperatorKind ULG = BinaryOperatorKind.ULong;
23private const BinaryOperatorKind NIN = BinaryOperatorKind.NInt;
24private const BinaryOperatorKind NUI = BinaryOperatorKind.NUInt;
25private const BinaryOperatorKind FLT = BinaryOperatorKind.Float;
26private const BinaryOperatorKind DBL = BinaryOperatorKind.Double;
27private const BinaryOperatorKind DEC = BinaryOperatorKind.Decimal;
28private const BinaryOperatorKind BOL = BinaryOperatorKind.Bool;
29private const BinaryOperatorKind LIN = BinaryOperatorKind.Lifted | BinaryOperatorKind.Int;
30private const BinaryOperatorKind LUN = BinaryOperatorKind.Lifted | BinaryOperatorKind.UInt;
31private const BinaryOperatorKind LLG = BinaryOperatorKind.Lifted | BinaryOperatorKind.Long;
32private const BinaryOperatorKind LUL = BinaryOperatorKind.Lifted | BinaryOperatorKind.ULong;
33private const BinaryOperatorKind LNI = BinaryOperatorKind.Lifted | BinaryOperatorKind.NInt;
34private const BinaryOperatorKind LNU = BinaryOperatorKind.Lifted | BinaryOperatorKind.NUInt;
35private const BinaryOperatorKind LFL = BinaryOperatorKind.Lifted | BinaryOperatorKind.Float;
36private const BinaryOperatorKind LDB = BinaryOperatorKind.Lifted | BinaryOperatorKind.Double;
37private const BinaryOperatorKind LDC = BinaryOperatorKind.Lifted | BinaryOperatorKind.Decimal;
38private const BinaryOperatorKind LBL = BinaryOperatorKind.Lifted | BinaryOperatorKind.Bool;
41private static readonly BinaryOperatorKind[,] s_arithmetic =
79private static readonly BinaryOperatorKind[,] s_addition =
117private static readonly BinaryOperatorKind[,] s_shift =
159private static readonly BinaryOperatorKind[,] s_equality =
197private static readonly BinaryOperatorKind[,] s_logical =
234private static readonly BinaryOperatorKind[][,] s_opkind =
255public static BinaryOperatorKind OpKind(BinaryOperatorKind kind, TypeSymbol left, TypeSymbol right)
260return BinaryOperatorKind.Error;
265return BinaryOperatorKind.Error;
268var result = BinaryOperatorKind.Error;
277if (!kind.IsLogical() || (leftIndex == (int)BinaryOperatorKind.Bool && rightIndex == (int)BinaryOperatorKind.Bool))
282return result == BinaryOperatorKind.Error ? result : result | kind;
286private void BinaryOperatorEasyOut(BinaryOperatorKind kind, BoundExpression left, BoundExpression right, BinaryOperatorOverloadResolutionResult result)
305var easyOut = BinopEasyOut.OpKind(kind, leftType, rightType);
307if (easyOut == BinaryOperatorKind.Error)
Binder\Semantics\Operators\BinaryOperatorOverloadResolution.cs (142)
20public void BinaryOperatorOverloadResolution(BinaryOperatorKind kind, bool isChecked, BoundExpression left, BoundExpression right, BinaryOperatorOverloadResolutionResult result, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
32internal void BinaryOperatorOverloadResolution_EasyOut(BinaryOperatorKind kind, BoundExpression left, BoundExpression right, BinaryOperatorOverloadResolutionResult result)
43BinaryOperatorKind underlyingKind = kind & ~BinaryOperatorKind.Logical;
49BinaryOperatorKind kind,
209private bool GetUserDefinedBinaryOperatorsFromInterfaces(BinaryOperatorKind kind, bool isChecked,
305private void AddDelegateOperation(BinaryOperatorKind kind, TypeSymbol delegateType,
310case BinaryOperatorKind.Equal:
311case BinaryOperatorKind.NotEqual:
312operators.Add(new BinaryOperatorSignature(kind | BinaryOperatorKind.Delegate, delegateType, delegateType, Compilation.GetSpecialType(SpecialType.System_Boolean)));
315case BinaryOperatorKind.Addition:
316case BinaryOperatorKind.Subtraction:
318operators.Add(new BinaryOperatorSignature(kind | BinaryOperatorKind.Delegate, delegateType, delegateType, delegateType));
323private void GetDelegateOperations(BinaryOperatorKind kind, BoundExpression left, BoundExpression right,
332case BinaryOperatorKind.Multiplication:
333case BinaryOperatorKind.Division:
334case BinaryOperatorKind.Remainder:
335case BinaryOperatorKind.RightShift:
336case BinaryOperatorKind.UnsignedRightShift:
337case BinaryOperatorKind.LeftShift:
338case BinaryOperatorKind.And:
339case BinaryOperatorKind.Or:
340case BinaryOperatorKind.Xor:
341case BinaryOperatorKind.GreaterThan:
342case BinaryOperatorKind.LessThan:
343case BinaryOperatorKind.GreaterThanOrEqual:
344case BinaryOperatorKind.LessThanOrEqual:
345case BinaryOperatorKind.LogicalAnd:
346case BinaryOperatorKind.LogicalOr:
349case BinaryOperatorKind.Addition:
350case BinaryOperatorKind.Subtraction:
351case BinaryOperatorKind.Equal:
352case BinaryOperatorKind.NotEqual:
378case BinaryOperatorKind.Equal:
379case BinaryOperatorKind.NotEqual:
441bool useIdentityConversion = kind == BinaryOperatorKind.Equal || kind == BinaryOperatorKind.NotEqual;
455if ((kind == BinaryOperatorKind.Equal || kind == BinaryOperatorKind.NotEqual)
464private void GetEnumOperation(BinaryOperatorKind kind, TypeSymbol enumType, BoundExpression right, ArrayBuilder<BinaryOperatorSignature> operators)
483case BinaryOperatorKind.Addition:
484operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.EnumAndUnderlyingAddition, enumType, underlying, enumType));
485operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.UnderlyingAndEnumAddition, underlying, enumType, enumType));
486operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.LiftedEnumAndUnderlyingAddition, nullableEnum, nullableUnderlying, nullableEnum));
487operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.LiftedUnderlyingAndEnumAddition, nullableUnderlying, nullableEnum, nullableEnum));
489case BinaryOperatorKind.Subtraction:
492operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.EnumSubtraction, enumType, enumType, underlying));
493operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.EnumAndUnderlyingSubtraction, enumType, underlying, enumType));
494operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.LiftedEnumSubtraction, nullableEnum, nullableEnum, nullableUnderlying));
495operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.LiftedEnumAndUnderlyingSubtraction, nullableEnum, nullableUnderlying, nullableEnum));
505operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.EnumSubtraction, enumType, enumType, underlying)
507operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.EnumAndUnderlyingSubtraction, enumType, underlying, enumType)
509operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.LiftedEnumSubtraction, nullableEnum, nullableEnum, nullableUnderlying)
511operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.LiftedEnumAndUnderlyingSubtraction, nullableEnum, nullableUnderlying, nullableEnum)
515operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.UnderlyingAndEnumSubtraction, underlying, enumType, enumType)
517operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.LiftedUnderlyingAndEnumSubtraction, nullableUnderlying, nullableEnum, nullableEnum)
521case BinaryOperatorKind.Equal:
522case BinaryOperatorKind.NotEqual:
523case BinaryOperatorKind.GreaterThan:
524case BinaryOperatorKind.LessThan:
525case BinaryOperatorKind.GreaterThanOrEqual:
526case BinaryOperatorKind.LessThanOrEqual:
528operators.Add(new BinaryOperatorSignature(kind | BinaryOperatorKind.Enum, enumType, enumType, boolean));
529operators.Add(new BinaryOperatorSignature(kind | BinaryOperatorKind.Lifted | BinaryOperatorKind.Enum, nullableEnum, nullableEnum, boolean));
531case BinaryOperatorKind.And:
532case BinaryOperatorKind.Or:
533case BinaryOperatorKind.Xor:
534operators.Add(new BinaryOperatorSignature(kind | BinaryOperatorKind.Enum, enumType, enumType, enumType));
535operators.Add(new BinaryOperatorSignature(kind | BinaryOperatorKind.Lifted | BinaryOperatorKind.Enum, nullableEnum, nullableEnum, nullableEnum));
541BinaryOperatorKind kind,
550case BinaryOperatorKind.Addition:
551operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.PointerAndIntAddition, pointerType, Compilation.GetSpecialType(SpecialType.System_Int32), pointerType));
552operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.PointerAndUIntAddition, pointerType, Compilation.GetSpecialType(SpecialType.System_UInt32), pointerType));
553operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.PointerAndLongAddition, pointerType, Compilation.GetSpecialType(SpecialType.System_Int64), pointerType));
554operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.PointerAndULongAddition, pointerType, Compilation.GetSpecialType(SpecialType.System_UInt64), pointerType));
555operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.IntAndPointerAddition, Compilation.GetSpecialType(SpecialType.System_Int32), pointerType, pointerType));
556operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.UIntAndPointerAddition, Compilation.GetSpecialType(SpecialType.System_UInt32), pointerType, pointerType));
557operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.LongAndPointerAddition, Compilation.GetSpecialType(SpecialType.System_Int64), pointerType, pointerType));
558operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.ULongAndPointerAddition, Compilation.GetSpecialType(SpecialType.System_UInt64), pointerType, pointerType));
560case BinaryOperatorKind.Subtraction:
561operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.PointerAndIntSubtraction, pointerType, Compilation.GetSpecialType(SpecialType.System_Int32), pointerType));
562operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.PointerAndUIntSubtraction, pointerType, Compilation.GetSpecialType(SpecialType.System_UInt32), pointerType));
563operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.PointerAndLongSubtraction, pointerType, Compilation.GetSpecialType(SpecialType.System_Int64), pointerType));
564operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.PointerAndULongSubtraction, pointerType, Compilation.GetSpecialType(SpecialType.System_UInt64), pointerType));
565operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.PointerSubtraction, pointerType, pointerType, Compilation.GetSpecialType(SpecialType.System_Int64)));
571BinaryOperatorKind kind,
576case BinaryOperatorKind.Equal:
577case BinaryOperatorKind.NotEqual:
578case BinaryOperatorKind.GreaterThan:
579case BinaryOperatorKind.LessThan:
580case BinaryOperatorKind.GreaterThanOrEqual:
581case BinaryOperatorKind.LessThanOrEqual:
583operators.Add(new BinaryOperatorSignature(kind | BinaryOperatorKind.Pointer, voidPointerType, voidPointerType, Compilation.GetSpecialType(SpecialType.System_Boolean)));
588private void GetEnumOperations(BinaryOperatorKind kind, BoundExpression left, BoundExpression right, ArrayBuilder<BinaryOperatorSignature> results)
597case BinaryOperatorKind.Multiplication:
598case BinaryOperatorKind.Division:
599case BinaryOperatorKind.Remainder:
600case BinaryOperatorKind.RightShift:
601case BinaryOperatorKind.UnsignedRightShift:
602case BinaryOperatorKind.LeftShift:
603case BinaryOperatorKind.LogicalAnd:
604case BinaryOperatorKind.LogicalOr:
623case BinaryOperatorKind.And:
624case BinaryOperatorKind.Or:
625case BinaryOperatorKind.Xor:
632case BinaryOperatorKind.Addition:
639case BinaryOperatorKind.Subtraction:
646case BinaryOperatorKind.Equal:
647case BinaryOperatorKind.NotEqual:
648case BinaryOperatorKind.GreaterThan:
649case BinaryOperatorKind.LessThan:
650case BinaryOperatorKind.GreaterThanOrEqual:
651case BinaryOperatorKind.LessThanOrEqual:
674BinaryOperatorKind kind,
706private void GetAllBuiltInOperators(BinaryOperatorKind kind, bool isChecked, BoundExpression left, BoundExpression right, ArrayBuilder<BinaryOperatorAnalysisResult> results, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
712bool isEquality = kind == BinaryOperatorKind.Equal || kind == BinaryOperatorKind.NotEqual;
752if (kind.Operator() is BinaryOperatorKind.Addition &&
774return value is BoundUtf8String or BoundBinaryOperator { OperatorKind: BinaryOperatorKind.Utf8Addition };
783private void GetReferenceEquality(BinaryOperatorKind kind, ArrayBuilder<BinaryOperatorSignature> operators)
786operators.Add(new BinaryOperatorSignature(kind | BinaryOperatorKind.Object, @object, @object, Compilation.GetSpecialType(SpecialType.System_Boolean)));
852BinaryOperatorKind kind,
919BinaryOperatorKind kind,
959void getDeclaredOperators(TypeSymbol constrainedToTypeOpt, NamedTypeSymbol type, BinaryOperatorKind kind, string name, ArrayBuilder<BinaryOperatorSignature> operators)
976operators.Add(new BinaryOperatorSignature(BinaryOperatorKind.UserDefined | kind, leftOperandType, rightOperandType, resultType, op, constrainedToTypeOpt));
982void addLiftedOperators(TypeSymbol constrainedToTypeOpt, BinaryOperatorKind kind, ArrayBuilder<BinaryOperatorSignature> operators)
996BinaryOperatorKind.Lifted | BinaryOperatorKind.UserDefined | kind,
1002BinaryOperatorKind.Lifted | BinaryOperatorKind.UserDefined | kind,
1016private static LiftingResult UserDefinedBinaryOperatorCanBeLifted(TypeSymbol left, TypeSymbol right, TypeSymbol result, BinaryOperatorKind kind)
1041case BinaryOperatorKind.Equal:
1042case BinaryOperatorKind.NotEqual:
1046goto case BinaryOperatorKind.GreaterThan;
1047case BinaryOperatorKind.GreaterThan:
1048case BinaryOperatorKind.GreaterThanOrEqual:
1049case BinaryOperatorKind.LessThan:
1050case BinaryOperatorKind.LessThanOrEqual:
1372private static void AssertNotChecked(BinaryOperatorKind kind)
1374Debug.Assert((kind & ~BinaryOperatorKind.Checked) == kind, "Did not expect operator to be checked. Consider using .Operator() to mask.");
Compilation\BuiltInOperators.cs (368)
297builder.Add(GetSignature((BinaryOperatorKind)kind));
303internal void GetSimpleBuiltInOperators(BinaryOperatorKind kind, ArrayBuilder<BinaryOperatorSignature> operators, bool skipNativeIntegerOperators)
322ImmutableArray.Create<BinaryOperatorSignature>(GetSignature(BinaryOperatorKind.LogicalBoolAnd)), //and
324ImmutableArray.Create<BinaryOperatorSignature>(GetSignature(BinaryOperatorKind.LogicalBoolOr)), //or
332(int)BinaryOperatorKind.IntMultiplication,
333(int)BinaryOperatorKind.UIntMultiplication,
334(int)BinaryOperatorKind.LongMultiplication,
335(int)BinaryOperatorKind.ULongMultiplication,
336(int)BinaryOperatorKind.NIntMultiplication,
337(int)BinaryOperatorKind.NUIntMultiplication,
338(int)BinaryOperatorKind.FloatMultiplication,
339(int)BinaryOperatorKind.DoubleMultiplication,
340(int)BinaryOperatorKind.DecimalMultiplication,
341(int)BinaryOperatorKind.LiftedIntMultiplication,
342(int)BinaryOperatorKind.LiftedUIntMultiplication,
343(int)BinaryOperatorKind.LiftedLongMultiplication,
344(int)BinaryOperatorKind.LiftedULongMultiplication,
345(int)BinaryOperatorKind.LiftedNIntMultiplication,
346(int)BinaryOperatorKind.LiftedNUIntMultiplication,
347(int)BinaryOperatorKind.LiftedFloatMultiplication,
348(int)BinaryOperatorKind.LiftedDoubleMultiplication,
349(int)BinaryOperatorKind.LiftedDecimalMultiplication,
353(int)BinaryOperatorKind.IntAddition,
354(int)BinaryOperatorKind.UIntAddition,
355(int)BinaryOperatorKind.LongAddition,
356(int)BinaryOperatorKind.ULongAddition,
357(int)BinaryOperatorKind.NIntAddition,
358(int)BinaryOperatorKind.NUIntAddition,
359(int)BinaryOperatorKind.FloatAddition,
360(int)BinaryOperatorKind.DoubleAddition,
361(int)BinaryOperatorKind.DecimalAddition,
362(int)BinaryOperatorKind.LiftedIntAddition,
363(int)BinaryOperatorKind.LiftedUIntAddition,
364(int)BinaryOperatorKind.LiftedLongAddition,
365(int)BinaryOperatorKind.LiftedULongAddition,
366(int)BinaryOperatorKind.LiftedNIntAddition,
367(int)BinaryOperatorKind.LiftedNUIntAddition,
368(int)BinaryOperatorKind.LiftedFloatAddition,
369(int)BinaryOperatorKind.LiftedDoubleAddition,
370(int)BinaryOperatorKind.LiftedDecimalAddition,
371(int)BinaryOperatorKind.StringConcatenation,
372(int)BinaryOperatorKind.StringAndObjectConcatenation,
373(int)BinaryOperatorKind.ObjectAndStringConcatenation,
377(int)BinaryOperatorKind.IntSubtraction,
378(int)BinaryOperatorKind.UIntSubtraction,
379(int)BinaryOperatorKind.LongSubtraction,
380(int)BinaryOperatorKind.ULongSubtraction,
381(int)BinaryOperatorKind.NIntSubtraction,
382(int)BinaryOperatorKind.NUIntSubtraction,
383(int)BinaryOperatorKind.FloatSubtraction,
384(int)BinaryOperatorKind.DoubleSubtraction,
385(int)BinaryOperatorKind.DecimalSubtraction,
386(int)BinaryOperatorKind.LiftedIntSubtraction,
387(int)BinaryOperatorKind.LiftedUIntSubtraction,
388(int)BinaryOperatorKind.LiftedLongSubtraction,
389(int)BinaryOperatorKind.LiftedULongSubtraction,
390(int)BinaryOperatorKind.LiftedNIntSubtraction,
391(int)BinaryOperatorKind.LiftedNUIntSubtraction,
392(int)BinaryOperatorKind.LiftedFloatSubtraction,
393(int)BinaryOperatorKind.LiftedDoubleSubtraction,
394(int)BinaryOperatorKind.LiftedDecimalSubtraction,
398(int)BinaryOperatorKind.IntDivision,
399(int)BinaryOperatorKind.UIntDivision,
400(int)BinaryOperatorKind.LongDivision,
401(int)BinaryOperatorKind.ULongDivision,
402(int)BinaryOperatorKind.NIntDivision,
403(int)BinaryOperatorKind.NUIntDivision,
404(int)BinaryOperatorKind.FloatDivision,
405(int)BinaryOperatorKind.DoubleDivision,
406(int)BinaryOperatorKind.DecimalDivision,
407(int)BinaryOperatorKind.LiftedIntDivision,
408(int)BinaryOperatorKind.LiftedUIntDivision,
409(int)BinaryOperatorKind.LiftedLongDivision,
410(int)BinaryOperatorKind.LiftedULongDivision,
411(int)BinaryOperatorKind.LiftedNIntDivision,
412(int)BinaryOperatorKind.LiftedNUIntDivision,
413(int)BinaryOperatorKind.LiftedFloatDivision,
414(int)BinaryOperatorKind.LiftedDoubleDivision,
415(int)BinaryOperatorKind.LiftedDecimalDivision,
419(int)BinaryOperatorKind.IntRemainder,
420(int)BinaryOperatorKind.UIntRemainder,
421(int)BinaryOperatorKind.LongRemainder,
422(int)BinaryOperatorKind.ULongRemainder,
423(int)BinaryOperatorKind.NIntRemainder,
424(int)BinaryOperatorKind.NUIntRemainder,
425(int)BinaryOperatorKind.FloatRemainder,
426(int)BinaryOperatorKind.DoubleRemainder,
427(int)BinaryOperatorKind.DecimalRemainder,
428(int)BinaryOperatorKind.LiftedIntRemainder,
429(int)BinaryOperatorKind.LiftedUIntRemainder,
430(int)BinaryOperatorKind.LiftedLongRemainder,
431(int)BinaryOperatorKind.LiftedULongRemainder,
432(int)BinaryOperatorKind.LiftedNIntRemainder,
433(int)BinaryOperatorKind.LiftedNUIntRemainder,
434(int)BinaryOperatorKind.LiftedFloatRemainder,
435(int)BinaryOperatorKind.LiftedDoubleRemainder,
436(int)BinaryOperatorKind.LiftedDecimalRemainder,
440(int)BinaryOperatorKind.IntLeftShift,
441(int)BinaryOperatorKind.UIntLeftShift,
442(int)BinaryOperatorKind.LongLeftShift,
443(int)BinaryOperatorKind.ULongLeftShift,
444(int)BinaryOperatorKind.NIntLeftShift,
445(int)BinaryOperatorKind.NUIntLeftShift,
446(int)BinaryOperatorKind.LiftedIntLeftShift,
447(int)BinaryOperatorKind.LiftedUIntLeftShift,
448(int)BinaryOperatorKind.LiftedLongLeftShift,
449(int)BinaryOperatorKind.LiftedULongLeftShift,
450(int)BinaryOperatorKind.LiftedNIntLeftShift,
451(int)BinaryOperatorKind.LiftedNUIntLeftShift,
455(int)BinaryOperatorKind.IntRightShift,
456(int)BinaryOperatorKind.UIntRightShift,
457(int)BinaryOperatorKind.LongRightShift,
458(int)BinaryOperatorKind.ULongRightShift,
459(int)BinaryOperatorKind.NIntRightShift,
460(int)BinaryOperatorKind.NUIntRightShift,
461(int)BinaryOperatorKind.LiftedIntRightShift,
462(int)BinaryOperatorKind.LiftedUIntRightShift,
463(int)BinaryOperatorKind.LiftedLongRightShift,
464(int)BinaryOperatorKind.LiftedULongRightShift,
465(int)BinaryOperatorKind.LiftedNIntRightShift,
466(int)BinaryOperatorKind.LiftedNUIntRightShift,
470(int)BinaryOperatorKind.IntEqual,
471(int)BinaryOperatorKind.UIntEqual,
472(int)BinaryOperatorKind.LongEqual,
473(int)BinaryOperatorKind.ULongEqual,
474(int)BinaryOperatorKind.NIntEqual,
475(int)BinaryOperatorKind.NUIntEqual,
476(int)BinaryOperatorKind.FloatEqual,
477(int)BinaryOperatorKind.DoubleEqual,
478(int)BinaryOperatorKind.DecimalEqual,
479(int)BinaryOperatorKind.BoolEqual,
480(int)BinaryOperatorKind.LiftedIntEqual,
481(int)BinaryOperatorKind.LiftedUIntEqual,
482(int)BinaryOperatorKind.LiftedLongEqual,
483(int)BinaryOperatorKind.LiftedULongEqual,
484(int)BinaryOperatorKind.LiftedNIntEqual,
485(int)BinaryOperatorKind.LiftedNUIntEqual,
486(int)BinaryOperatorKind.LiftedFloatEqual,
487(int)BinaryOperatorKind.LiftedDoubleEqual,
488(int)BinaryOperatorKind.LiftedDecimalEqual,
489(int)BinaryOperatorKind.LiftedBoolEqual,
490(int)BinaryOperatorKind.ObjectEqual,
491(int)BinaryOperatorKind.StringEqual,
495(int)BinaryOperatorKind.IntNotEqual,
496(int)BinaryOperatorKind.UIntNotEqual,
497(int)BinaryOperatorKind.LongNotEqual,
498(int)BinaryOperatorKind.ULongNotEqual,
499(int)BinaryOperatorKind.NIntNotEqual,
500(int)BinaryOperatorKind.NUIntNotEqual,
501(int)BinaryOperatorKind.FloatNotEqual,
502(int)BinaryOperatorKind.DoubleNotEqual,
503(int)BinaryOperatorKind.DecimalNotEqual,
504(int)BinaryOperatorKind.BoolNotEqual,
505(int)BinaryOperatorKind.LiftedIntNotEqual,
506(int)BinaryOperatorKind.LiftedUIntNotEqual,
507(int)BinaryOperatorKind.LiftedLongNotEqual,
508(int)BinaryOperatorKind.LiftedULongNotEqual,
509(int)BinaryOperatorKind.LiftedNIntNotEqual,
510(int)BinaryOperatorKind.LiftedNUIntNotEqual,
511(int)BinaryOperatorKind.LiftedFloatNotEqual,
512(int)BinaryOperatorKind.LiftedDoubleNotEqual,
513(int)BinaryOperatorKind.LiftedDecimalNotEqual,
514(int)BinaryOperatorKind.LiftedBoolNotEqual,
515(int)BinaryOperatorKind.ObjectNotEqual,
516(int)BinaryOperatorKind.StringNotEqual,
520(int)BinaryOperatorKind.IntGreaterThan,
521(int)BinaryOperatorKind.UIntGreaterThan,
522(int)BinaryOperatorKind.LongGreaterThan,
523(int)BinaryOperatorKind.ULongGreaterThan,
524(int)BinaryOperatorKind.NIntGreaterThan,
525(int)BinaryOperatorKind.NUIntGreaterThan,
526(int)BinaryOperatorKind.FloatGreaterThan,
527(int)BinaryOperatorKind.DoubleGreaterThan,
528(int)BinaryOperatorKind.DecimalGreaterThan,
529(int)BinaryOperatorKind.LiftedIntGreaterThan,
530(int)BinaryOperatorKind.LiftedUIntGreaterThan,
531(int)BinaryOperatorKind.LiftedLongGreaterThan,
532(int)BinaryOperatorKind.LiftedULongGreaterThan,
533(int)BinaryOperatorKind.LiftedNIntGreaterThan,
534(int)BinaryOperatorKind.LiftedNUIntGreaterThan,
535(int)BinaryOperatorKind.LiftedFloatGreaterThan,
536(int)BinaryOperatorKind.LiftedDoubleGreaterThan,
537(int)BinaryOperatorKind.LiftedDecimalGreaterThan,
541(int)BinaryOperatorKind.IntLessThan,
542(int)BinaryOperatorKind.UIntLessThan,
543(int)BinaryOperatorKind.LongLessThan,
544(int)BinaryOperatorKind.ULongLessThan,
545(int)BinaryOperatorKind.NIntLessThan,
546(int)BinaryOperatorKind.NUIntLessThan,
547(int)BinaryOperatorKind.FloatLessThan,
548(int)BinaryOperatorKind.DoubleLessThan,
549(int)BinaryOperatorKind.DecimalLessThan,
550(int)BinaryOperatorKind.LiftedIntLessThan,
551(int)BinaryOperatorKind.LiftedUIntLessThan,
552(int)BinaryOperatorKind.LiftedLongLessThan,
553(int)BinaryOperatorKind.LiftedULongLessThan,
554(int)BinaryOperatorKind.LiftedNIntLessThan,
555(int)BinaryOperatorKind.LiftedNUIntLessThan,
556(int)BinaryOperatorKind.LiftedFloatLessThan,
557(int)BinaryOperatorKind.LiftedDoubleLessThan,
558(int)BinaryOperatorKind.LiftedDecimalLessThan,
562(int)BinaryOperatorKind.IntGreaterThanOrEqual,
563(int)BinaryOperatorKind.UIntGreaterThanOrEqual,
564(int)BinaryOperatorKind.LongGreaterThanOrEqual,
565(int)BinaryOperatorKind.ULongGreaterThanOrEqual,
566(int)BinaryOperatorKind.NIntGreaterThanOrEqual,
567(int)BinaryOperatorKind.NUIntGreaterThanOrEqual,
568(int)BinaryOperatorKind.FloatGreaterThanOrEqual,
569(int)BinaryOperatorKind.DoubleGreaterThanOrEqual,
570(int)BinaryOperatorKind.DecimalGreaterThanOrEqual,
571(int)BinaryOperatorKind.LiftedIntGreaterThanOrEqual,
572(int)BinaryOperatorKind.LiftedUIntGreaterThanOrEqual,
573(int)BinaryOperatorKind.LiftedLongGreaterThanOrEqual,
574(int)BinaryOperatorKind.LiftedULongGreaterThanOrEqual,
575(int)BinaryOperatorKind.LiftedNIntGreaterThanOrEqual,
576(int)BinaryOperatorKind.LiftedNUIntGreaterThanOrEqual,
577(int)BinaryOperatorKind.LiftedFloatGreaterThanOrEqual,
578(int)BinaryOperatorKind.LiftedDoubleGreaterThanOrEqual,
579(int)BinaryOperatorKind.LiftedDecimalGreaterThanOrEqual,
583(int)BinaryOperatorKind.IntLessThanOrEqual,
584(int)BinaryOperatorKind.UIntLessThanOrEqual,
585(int)BinaryOperatorKind.LongLessThanOrEqual,
586(int)BinaryOperatorKind.ULongLessThanOrEqual,
587(int)BinaryOperatorKind.NIntLessThanOrEqual,
588(int)BinaryOperatorKind.NUIntLessThanOrEqual,
589(int)BinaryOperatorKind.FloatLessThanOrEqual,
590(int)BinaryOperatorKind.DoubleLessThanOrEqual,
591(int)BinaryOperatorKind.DecimalLessThanOrEqual,
592(int)BinaryOperatorKind.LiftedIntLessThanOrEqual,
593(int)BinaryOperatorKind.LiftedUIntLessThanOrEqual,
594(int)BinaryOperatorKind.LiftedLongLessThanOrEqual,
595(int)BinaryOperatorKind.LiftedULongLessThanOrEqual,
596(int)BinaryOperatorKind.LiftedNIntLessThanOrEqual,
597(int)BinaryOperatorKind.LiftedNUIntLessThanOrEqual,
598(int)BinaryOperatorKind.LiftedFloatLessThanOrEqual,
599(int)BinaryOperatorKind.LiftedDoubleLessThanOrEqual,
600(int)BinaryOperatorKind.LiftedDecimalLessThanOrEqual,
604(int)BinaryOperatorKind.IntAnd,
605(int)BinaryOperatorKind.UIntAnd,
606(int)BinaryOperatorKind.LongAnd,
607(int)BinaryOperatorKind.ULongAnd,
608(int)BinaryOperatorKind.NIntAnd,
609(int)BinaryOperatorKind.NUIntAnd,
610(int)BinaryOperatorKind.BoolAnd,
611(int)BinaryOperatorKind.LiftedIntAnd,
612(int)BinaryOperatorKind.LiftedUIntAnd,
613(int)BinaryOperatorKind.LiftedLongAnd,
614(int)BinaryOperatorKind.LiftedULongAnd,
615(int)BinaryOperatorKind.LiftedNIntAnd,
616(int)BinaryOperatorKind.LiftedNUIntAnd,
617(int)BinaryOperatorKind.LiftedBoolAnd,
621(int)BinaryOperatorKind.IntXor,
622(int)BinaryOperatorKind.UIntXor,
623(int)BinaryOperatorKind.LongXor,
624(int)BinaryOperatorKind.ULongXor,
625(int)BinaryOperatorKind.NIntXor,
626(int)BinaryOperatorKind.NUIntXor,
627(int)BinaryOperatorKind.BoolXor,
628(int)BinaryOperatorKind.LiftedIntXor,
629(int)BinaryOperatorKind.LiftedUIntXor,
630(int)BinaryOperatorKind.LiftedLongXor,
631(int)BinaryOperatorKind.LiftedULongXor,
632(int)BinaryOperatorKind.LiftedNIntXor,
633(int)BinaryOperatorKind.LiftedNUIntXor,
634(int)BinaryOperatorKind.LiftedBoolXor,
638(int)BinaryOperatorKind.IntOr,
639(int)BinaryOperatorKind.UIntOr,
640(int)BinaryOperatorKind.LongOr,
641(int)BinaryOperatorKind.ULongOr,
642(int)BinaryOperatorKind.NIntOr,
643(int)BinaryOperatorKind.NUIntOr,
644(int)BinaryOperatorKind.BoolOr,
645(int)BinaryOperatorKind.LiftedIntOr,
646(int)BinaryOperatorKind.LiftedUIntOr,
647(int)BinaryOperatorKind.LiftedLongOr,
648(int)BinaryOperatorKind.LiftedULongOr,
649(int)BinaryOperatorKind.LiftedNIntOr,
650(int)BinaryOperatorKind.LiftedNUIntOr,
651(int)BinaryOperatorKind.LiftedBoolOr,
655(int)BinaryOperatorKind.IntUnsignedRightShift,
656(int)BinaryOperatorKind.UIntUnsignedRightShift,
657(int)BinaryOperatorKind.LongUnsignedRightShift,
658(int)BinaryOperatorKind.ULongUnsignedRightShift,
659(int)BinaryOperatorKind.NIntUnsignedRightShift,
660(int)BinaryOperatorKind.NUIntUnsignedRightShift,
661(int)BinaryOperatorKind.LiftedIntUnsignedRightShift,
662(int)BinaryOperatorKind.LiftedUIntUnsignedRightShift,
663(int)BinaryOperatorKind.LiftedLongUnsignedRightShift,
664(int)BinaryOperatorKind.LiftedULongUnsignedRightShift,
665(int)BinaryOperatorKind.LiftedNIntUnsignedRightShift,
666(int)BinaryOperatorKind.LiftedNUIntUnsignedRightShift,
681case BinaryOperatorKind.NInt:
682case BinaryOperatorKind.NUInt:
696static readonlySpanOfByte => new BinaryOperatorSignature(BinaryOperatorKind.Utf8Addition, readonlySpanOfByte, readonlySpanOfByte, readonlySpanOfByte),
702internal BinaryOperatorSignature GetSignature(BinaryOperatorKind kind)
707case BinaryOperatorKind.Multiplication:
708case BinaryOperatorKind.Division:
709case BinaryOperatorKind.Subtraction:
710case BinaryOperatorKind.Remainder:
711case BinaryOperatorKind.And:
712case BinaryOperatorKind.Or:
713case BinaryOperatorKind.Xor:
715case BinaryOperatorKind.Addition:
717case BinaryOperatorKind.LeftShift:
718case BinaryOperatorKind.RightShift:
719case BinaryOperatorKind.UnsignedRightShift:
727case BinaryOperatorKind.Equal:
728case BinaryOperatorKind.NotEqual:
729case BinaryOperatorKind.GreaterThan:
730case BinaryOperatorKind.LessThan:
731case BinaryOperatorKind.GreaterThanOrEqual:
732case BinaryOperatorKind.LessThanOrEqual:
738private TypeSymbol LeftType(BinaryOperatorKind kind)
748case BinaryOperatorKind.Int: return _compilation.GetSpecialType(SpecialType.System_Int32);
749case BinaryOperatorKind.UInt: return _compilation.GetSpecialType(SpecialType.System_UInt32);
750case BinaryOperatorKind.Long: return _compilation.GetSpecialType(SpecialType.System_Int64);
751case BinaryOperatorKind.ULong: return _compilation.GetSpecialType(SpecialType.System_UInt64);
752case BinaryOperatorKind.NInt: return _compilation.CreateNativeIntegerTypeSymbol(signed: true);
753case BinaryOperatorKind.NUInt: return _compilation.CreateNativeIntegerTypeSymbol(signed: false);
754case BinaryOperatorKind.Float: return _compilation.GetSpecialType(SpecialType.System_Single);
755case BinaryOperatorKind.Double: return _compilation.GetSpecialType(SpecialType.System_Double);
756case BinaryOperatorKind.Decimal: return _compilation.GetSpecialType(SpecialType.System_Decimal);
757case BinaryOperatorKind.Bool: return _compilation.GetSpecialType(SpecialType.System_Boolean);
758case BinaryOperatorKind.ObjectAndString:
759case BinaryOperatorKind.Object:
761case BinaryOperatorKind.String:
762case BinaryOperatorKind.StringAndObject:
770private TypeSymbol RightType(BinaryOperatorKind kind)
780case BinaryOperatorKind.Int: return _compilation.GetSpecialType(SpecialType.System_Int32);
781case BinaryOperatorKind.UInt: return _compilation.GetSpecialType(SpecialType.System_UInt32);
782case BinaryOperatorKind.Long: return _compilation.GetSpecialType(SpecialType.System_Int64);
783case BinaryOperatorKind.ULong: return _compilation.GetSpecialType(SpecialType.System_UInt64);
784case BinaryOperatorKind.NInt: return _compilation.CreateNativeIntegerTypeSymbol(signed: true);
785case BinaryOperatorKind.NUInt: return _compilation.CreateNativeIntegerTypeSymbol(signed: false);
786case BinaryOperatorKind.Float: return _compilation.GetSpecialType(SpecialType.System_Single);
787case BinaryOperatorKind.Double: return _compilation.GetSpecialType(SpecialType.System_Double);
788case BinaryOperatorKind.Decimal: return _compilation.GetSpecialType(SpecialType.System_Decimal);
789case BinaryOperatorKind.Bool: return _compilation.GetSpecialType(SpecialType.System_Boolean);
790case BinaryOperatorKind.ObjectAndString:
791case BinaryOperatorKind.String:
793case BinaryOperatorKind.StringAndObject:
794case BinaryOperatorKind.Object:
802private TypeSymbol ReturnType(BinaryOperatorKind kind)
812case BinaryOperatorKind.Int: return _compilation.GetSpecialType(SpecialType.System_Int32);
813case BinaryOperatorKind.UInt: return _compilation.GetSpecialType(SpecialType.System_UInt32);
814case BinaryOperatorKind.Long: return _compilation.GetSpecialType(SpecialType.System_Int64);
815case BinaryOperatorKind.ULong: return _compilation.GetSpecialType(SpecialType.System_UInt64);
816case BinaryOperatorKind.NInt: return _compilation.CreateNativeIntegerTypeSymbol(signed: true);
817case BinaryOperatorKind.NUInt: return _compilation.CreateNativeIntegerTypeSymbol(signed: false);
818case BinaryOperatorKind.Float: return _compilation.GetSpecialType(SpecialType.System_Single);
819case BinaryOperatorKind.Double: return _compilation.GetSpecialType(SpecialType.System_Double);
820case BinaryOperatorKind.Decimal: return _compilation.GetSpecialType(SpecialType.System_Decimal);
821case BinaryOperatorKind.Bool: return _compilation.GetSpecialType(SpecialType.System_Boolean);
822case BinaryOperatorKind.Object: return _compilation.GetSpecialType(SpecialType.System_Object);
823case BinaryOperatorKind.ObjectAndString:
824case BinaryOperatorKind.StringAndObject:
825case BinaryOperatorKind.String:
833private TypeSymbol LiftedType(BinaryOperatorKind kind)
839BinaryOperatorKind.Int => _compilation.GetSpecialType(SpecialType.System_Int32),
840BinaryOperatorKind.UInt => _compilation.GetSpecialType(SpecialType.System_UInt32),
841BinaryOperatorKind.Long => _compilation.GetSpecialType(SpecialType.System_Int64),
842BinaryOperatorKind.ULong => _compilation.GetSpecialType(SpecialType.System_UInt64),
843BinaryOperatorKind.NInt => _compilation.CreateNativeIntegerTypeSymbol(signed: true),
844BinaryOperatorKind.NUInt => _compilation.CreateNativeIntegerTypeSymbol(signed: false),
845BinaryOperatorKind.Float => _compilation.GetSpecialType(SpecialType.System_Single),
846BinaryOperatorKind.Double => _compilation.GetSpecialType(SpecialType.System_Double),
847BinaryOperatorKind.Decimal => _compilation.GetSpecialType(SpecialType.System_Decimal),
848BinaryOperatorKind.Bool => _compilation.GetSpecialType(SpecialType.System_Boolean),
Compiler\MethodBodySynthesizer.Lowered.cs (11)
85F.Binary(BinaryOperatorKind.ObjectNotEqual, F.SpecialType(SpecialType.System_Boolean),
95F.Binary(BinaryOperatorKind.Multiplication, hashCode.Type,
96F.Binary(BinaryOperatorKind.Xor, hashCode.Type,
107F.Binary(BinaryOperatorKind.Addition, i.Type,
112F.Binary(BinaryOperatorKind.LessThan, F.SpecialType(SpecialType.System_Boolean),
182F.Binary(BinaryOperatorKind.Multiplication, hashCode.Type,
183F.Binary(BinaryOperatorKind.Xor, hashCode.Type,
196F.Binary(BinaryOperatorKind.Addition, i.Type,
201F.Binary(BinaryOperatorKind.LessThan, F.SpecialType(SpecialType.System_Boolean),
367currentHashValue = F.Binary(BinaryOperatorKind.IntMultiplication, system_Int32, currentHashValue, boundHashFactor);
370currentHashValue = F.Binary(BinaryOperatorKind.IntAddition,
Generated\BoundNodes.xml.Generated.cs (15)
1661public BoundBinaryOperator(SyntaxNode syntax, BinaryOperatorKind operatorKind, BoundBinaryOperator.UncommonData? data, LookupResultKind resultKind, BoundExpression left, BoundExpression right, TypeSymbol type, bool hasErrors = false)
1674public BinaryOperatorKind OperatorKind { get; }
1681public BoundBinaryOperator Update(BinaryOperatorKind operatorKind, BoundBinaryOperator.UncommonData? data, LookupResultKind resultKind, BoundExpression left, BoundExpression right, TypeSymbol type)
1695public BoundTupleBinaryOperator(SyntaxNode syntax, BoundExpression left, BoundExpression right, BinaryOperatorKind operatorKind, TupleBinaryOperatorInfo.Multiple operators, TypeSymbol type, bool hasErrors = false)
1713public BinaryOperatorKind OperatorKind { get; }
1719public BoundTupleBinaryOperator Update(BoundExpression left, BoundExpression right, BinaryOperatorKind operatorKind, TupleBinaryOperatorInfo.Multiple operators, TypeSymbol type)
1733public BoundUserDefinedConditionalLogicalOperator(SyntaxNode syntax, BinaryOperatorKind operatorKind, MethodSymbol logicalOperator, MethodSymbol trueOperator, MethodSymbol falseOperator, TypeSymbol? constrainedToTypeOpt, LookupResultKind resultKind, ImmutableArray<MethodSymbol> originalUserDefinedOperatorsOpt, BoundExpression left, BoundExpression right, TypeSymbol type, bool hasErrors = false)
1753public BinaryOperatorKind OperatorKind { get; }
1764public BoundUserDefinedConditionalLogicalOperator Update(BinaryOperatorKind operatorKind, MethodSymbol logicalOperator, MethodSymbol trueOperator, MethodSymbol falseOperator, TypeSymbol? constrainedToTypeOpt, LookupResultKind resultKind, ImmutableArray<MethodSymbol> originalUserDefinedOperatorsOpt, BoundExpression left, BoundExpression right, TypeSymbol type)
5342public BoundDagRelationalTest(SyntaxNode syntax, BinaryOperatorKind operatorKind, ConstantValue value, BoundDagTemp input, bool hasErrors = false)
5353public BinaryOperatorKind OperatorKind { get; }
5359public BoundDagRelationalTest Update(BinaryOperatorKind operatorKind, ConstantValue value, BoundDagTemp input)
8525public BoundRelationalPattern(SyntaxNode syntax, BinaryOperatorKind relation, BoundExpression value, ConstantValue constantValue, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
8543public BinaryOperatorKind Relation { get; }
8550public BoundRelationalPattern Update(BinaryOperatorKind relation, BoundExpression value, ConstantValue constantValue, TypeSymbol inputType, TypeSymbol narrowedType)
Lowering\LocalRewriter\LocalRewriter.DecisionDagRewriter.cs (6)
644splitCases(ImmutableArray<(ConstantValue value, LabelSymbol label)> cases, BinaryOperatorKind op, ConstantValue value)
732_fac.Related(BinaryOperatorKind.LessThanOrEqual, x, y) ?
733(_fac.Related(BinaryOperatorKind.LessThanOrEqual, y, x) ? 0 : -1) :
815SpecialType.System_Single => BinaryOperatorKind.FloatLessThanOrEqual,
816SpecialType.System_Double => BinaryOperatorKind.DoubleLessThanOrEqual,
817SpecialType.System_Decimal => BinaryOperatorKind.DecimalLessThanOrEqual,
Lowering\LocalRewriter\LocalRewriter.DecisionDagRewriter.ValueDispatchNode.cs (12)
63/// For <see cref="BinaryOperatorKind.LessThan"/> and <see cref="BinaryOperatorKind.LessThanOrEqual"/>,
65/// is <see cref="Right"/>; for <see cref="BinaryOperatorKind.GreaterThan"/> and
66/// <see cref="BinaryOperatorKind.GreaterThanOrEqual"/> it is reversed.
67/// See <see cref="IsReversed(BinaryOperatorKind)"/> for where that is computed.
81public readonly BinaryOperatorKind Operator;
86private RelationalDispatch(SyntaxNode syntax, ConstantValue value, BinaryOperatorKind op, ValueDispatchNode left, ValueDispatchNode right) : base(syntax)
100private static bool IsReversed(BinaryOperatorKind op) => op.Operator() switch { BinaryOperatorKind.GreaterThan => true, BinaryOperatorKind.GreaterThanOrEqual => true, _ => false };
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_BinaryOperator.cs (223)
72var operatorKind = node.OperatorKind;
89operatorKind.Operator() == BinaryOperatorKind.And ? node.FalseOperator : node.TrueOperator, boundTemp);
92var andOperatorCall = LowerUserDefinedBinaryOperator(syntax, operatorKind & ~BinaryOperatorKind.Logical, boundTemp, loweredRight, type, node.LogicalOperator, node.ConstrainedToTypeOpt);
122if (node.OperatorKind is BinaryOperatorKind.Utf8Addition)
138if (current.InterpolatedStringHandlerData is not null || current.OperatorKind is BinaryOperatorKind.Utf8Addition)
162Debug.Assert(node.OperatorKind == BinaryOperatorKind.StringConcatenation);
176BinaryOperatorKind operatorKind,
192BinaryOperatorKind operatorKind,
208case BinaryOperatorKind.ObjectAndStringConcatenation:
209case BinaryOperatorKind.StringAndObjectConcatenation:
210case BinaryOperatorKind.StringConcatenation:
212case BinaryOperatorKind.DelegateCombination:
214case BinaryOperatorKind.DelegateRemoval:
216case BinaryOperatorKind.DelegateEqual:
218case BinaryOperatorKind.DelegateNotEqual:
252case BinaryOperatorKind.NullableNullEqual:
253case BinaryOperatorKind.NullableNullNotEqual:
256case BinaryOperatorKind.ObjectAndStringConcatenation:
257case BinaryOperatorKind.StringAndObjectConcatenation:
258case BinaryOperatorKind.StringConcatenation:
261case BinaryOperatorKind.StringEqual:
264case BinaryOperatorKind.StringNotEqual:
267case BinaryOperatorKind.DelegateCombination:
270case BinaryOperatorKind.DelegateRemoval:
273case BinaryOperatorKind.DelegateEqual:
276case BinaryOperatorKind.DelegateNotEqual:
279case BinaryOperatorKind.LogicalBoolAnd:
286operatorKind &= ~BinaryOperatorKind.Logical;
291case BinaryOperatorKind.LogicalBoolOr:
298operatorKind &= ~BinaryOperatorKind.Logical;
303case BinaryOperatorKind.BoolAnd:
324case BinaryOperatorKind.BoolOr:
329case BinaryOperatorKind.BoolEqual:
343case BinaryOperatorKind.BoolNotEqual:
357case BinaryOperatorKind.BoolXor:
371case BinaryOperatorKind.IntLeftShift:
372case BinaryOperatorKind.UIntLeftShift:
373case BinaryOperatorKind.IntRightShift:
374case BinaryOperatorKind.UIntRightShift:
375case BinaryOperatorKind.IntUnsignedRightShift:
376case BinaryOperatorKind.UIntUnsignedRightShift:
379case BinaryOperatorKind.LongLeftShift:
380case BinaryOperatorKind.ULongLeftShift:
381case BinaryOperatorKind.LongRightShift:
382case BinaryOperatorKind.ULongRightShift:
383case BinaryOperatorKind.LongUnsignedRightShift:
384case BinaryOperatorKind.ULongUnsignedRightShift:
387case BinaryOperatorKind.NIntRightShift:
388case BinaryOperatorKind.NUIntRightShift:
389case BinaryOperatorKind.NIntUnsignedRightShift:
390case BinaryOperatorKind.NUIntUnsignedRightShift:
391case BinaryOperatorKind.NIntLeftShift:
392case BinaryOperatorKind.NUIntLeftShift:
395case BinaryOperatorKind.DecimalAddition:
396case BinaryOperatorKind.DecimalSubtraction:
397case BinaryOperatorKind.DecimalMultiplication:
398case BinaryOperatorKind.DecimalDivision:
399case BinaryOperatorKind.DecimalRemainder:
400case BinaryOperatorKind.DecimalEqual:
401case BinaryOperatorKind.DecimalNotEqual:
402case BinaryOperatorKind.DecimalLessThan:
403case BinaryOperatorKind.DecimalLessThanOrEqual:
404case BinaryOperatorKind.DecimalGreaterThan:
405case BinaryOperatorKind.DecimalGreaterThanOrEqual:
408case BinaryOperatorKind.PointerAndIntAddition:
409case BinaryOperatorKind.PointerAndUIntAddition:
410case BinaryOperatorKind.PointerAndLongAddition:
411case BinaryOperatorKind.PointerAndULongAddition:
412case BinaryOperatorKind.PointerAndIntSubtraction:
413case BinaryOperatorKind.PointerAndUIntSubtraction:
414case BinaryOperatorKind.PointerAndLongSubtraction:
415case BinaryOperatorKind.PointerAndULongSubtraction:
422case BinaryOperatorKind.IntAndPointerAddition:
423case BinaryOperatorKind.UIntAndPointerAddition:
424case BinaryOperatorKind.LongAndPointerAddition:
425case BinaryOperatorKind.ULongAndPointerAddition:
432case BinaryOperatorKind.PointerSubtraction:
435case BinaryOperatorKind.IntAddition:
436case BinaryOperatorKind.UIntAddition:
437case BinaryOperatorKind.LongAddition:
438case BinaryOperatorKind.ULongAddition:
449case BinaryOperatorKind.IntSubtraction:
450case BinaryOperatorKind.LongSubtraction:
451case BinaryOperatorKind.UIntSubtraction:
452case BinaryOperatorKind.ULongSubtraction:
459case BinaryOperatorKind.IntMultiplication:
460case BinaryOperatorKind.LongMultiplication:
461case BinaryOperatorKind.UIntMultiplication:
462case BinaryOperatorKind.ULongMultiplication:
481case BinaryOperatorKind.IntGreaterThan:
482case BinaryOperatorKind.IntLessThanOrEqual:
486var newOp = operatorKind == BinaryOperatorKind.IntGreaterThan ?
487BinaryOperatorKind.NotEqual :
488BinaryOperatorKind.Equal;
490operatorKind &= ~BinaryOperatorKind.OpMask;
496case BinaryOperatorKind.IntLessThan:
497case BinaryOperatorKind.IntGreaterThanOrEqual:
501var newOp = operatorKind == BinaryOperatorKind.IntLessThan ?
502BinaryOperatorKind.NotEqual :
503BinaryOperatorKind.Equal;
505operatorKind &= ~BinaryOperatorKind.OpMask;
511case BinaryOperatorKind.IntEqual:
512case BinaryOperatorKind.IntNotEqual:
524case BinaryOperatorKind.Utf8Addition:
537private BoundExpression RewriteLiftedBinaryOperator(SyntaxNode syntax, BinaryOperatorKind operatorKind, BoundExpression loweredLeft, BoundExpression loweredRight, TypeSymbol type, MethodSymbol? method, TypeSymbol? constrainedToTypeOpt)
545operatorKind != BinaryOperatorKind.LiftedBoolOr && operatorKind != BinaryOperatorKind.LiftedBoolAnd &&
566if (operatorKind.Operator() == BinaryOperatorKind.NotEqual ||
567operatorKind.Operator() == BinaryOperatorKind.Equal)
597BinaryOperatorKind operatorKind,
606Debug.Assert(operatorKind.Operator() == BinaryOperatorKind.And || operatorKind.Operator() == BinaryOperatorKind.Or);
617bool isAnd = operatorKind.Operator() == BinaryOperatorKind.And;
681result = _factory.Binary(BinaryOperatorKind.LogicalOr, boolean, leftTest, result);
769BinaryOperatorKind operatorKind,
797BinaryOperatorKind kind,
816return MakeLiteral(syntax, ConstantValue.Create(kind.Operator() == BinaryOperatorKind.Equal), boolType);
839BinaryOperatorKind operatorKind = kind.Operator();
843BoundExpression result = MakeLiteral(syntax, ConstantValue.Create(operatorKind == BinaryOperatorKind.NotEqual), boolType);
870if (operatorKind == BinaryOperatorKind.Equal || operatorKind == BinaryOperatorKind.NotEqual)
873BoundExpression result = operatorKind == BinaryOperatorKind.Equal ?
880BoundExpression falseExpr = MakeBooleanConstant(syntax, operatorKind == BinaryOperatorKind.NotEqual);
937BinaryOperatorKind kind,
1000if (kind.Operator() is BinaryOperatorKind.Equal or BinaryOperatorKind.NotEqual)
1037BinaryOperatorKind leftOperator;
1038BinaryOperatorKind rightOperator;
1040BinaryOperatorKind operatorKind = kind.Operator();
1043case BinaryOperatorKind.Equal:
1044case BinaryOperatorKind.NotEqual:
1045leftOperator = BinaryOperatorKind.Equal;
1046rightOperator = BinaryOperatorKind.BoolEqual;
1050rightOperator = BinaryOperatorKind.BoolAnd;
1078operatorKind: BinaryOperatorKind.BoolAnd,
1087if (operatorKind == BinaryOperatorKind.NotEqual)
1127BinaryOperatorKind kind,
1211BinaryOperatorKind conditionOperator;
1212BinaryOperatorKind operatorKind = kind.Operator();
1215case BinaryOperatorKind.Equal:
1216case BinaryOperatorKind.NotEqual:
1217conditionOperator = BinaryOperatorKind.BoolEqual;
1220conditionOperator = BinaryOperatorKind.BoolAnd;
1246if (operatorKind == BinaryOperatorKind.Equal || operatorKind == BinaryOperatorKind.NotEqual)
1261rewrittenAlternative: MakeLiteral(syntax, ConstantValue.Create(operatorKind == BinaryOperatorKind.Equal), boolType),
1274BoundExpression alternative = MakeBooleanConstant(syntax, operatorKind == BinaryOperatorKind.NotEqual);
1295BinaryOperatorKind kind,
1335BinaryOperatorKind kind,
1404BinaryOperatorKind kind,
1458BoundExpression condition = MakeBinaryOperator(syntax, BinaryOperatorKind.BoolAnd, callX_HasValue, callY_HasValue, boolType, method: null, constrainedToTypeOpt: null);
1506BinaryOperatorKind kind,
1520if (kind == BinaryOperatorKind.LiftedBoolAnd || kind == BinaryOperatorKind.LiftedBoolOr)
1657BinaryOperatorKind kind,
1694BoundExpression newNullBool = MakeNewNullableBoolean(syntax, kind == BinaryOperatorKind.LiftedBoolOr);
1699rewrittenConsequence: kind == BinaryOperatorKind.LiftedBoolAnd ? nullBool : newNullBool,
1700rewrittenAlternative: kind == BinaryOperatorKind.LiftedBoolAnd ? newNullBool : nullBool,
1721BoundExpression consequence = kind == BinaryOperatorKind.LiftedBoolAnd ? nullBool : boundTemp;
1722BoundExpression alternative = kind == BinaryOperatorKind.LiftedBoolAnd ? boundTemp : nullBool;
1742BinaryOperatorKind kind,
1782BoundExpression newNullBool = MakeNewNullableBoolean(syntax, kind == BinaryOperatorKind.LiftedBoolOr);
1783BoundExpression consequence = kind == BinaryOperatorKind.LiftedBoolOr ? newNullBool : maybeNullTemp;
1784BoundExpression alternative = kind == BinaryOperatorKind.LiftedBoolOr ? maybeNullTemp : newNullBool;
1803BinaryOperatorKind kind,
1849operatorKind: BinaryOperatorKind.LogicalBoolOr,
1862operatorKind: BinaryOperatorKind.LogicalBoolOr,
1869BoundExpression consequence = kind == BinaryOperatorKind.LiftedBoolAnd ? boundTempY : boundTempX;
1870BoundExpression alternative = kind == BinaryOperatorKind.LiftedBoolAnd ? boundTempX : boundTempY;
1925BinaryOperatorKind kind,
1951return MakeLiteral(syntax, ConstantValue.Create(kind == BinaryOperatorKind.NullableNullEqual), returnType);
1966value: MakeBooleanConstant(syntax, kind == BinaryOperatorKind.NullableNullNotEqual),
1982var whenNull = kind == BinaryOperatorKind.NullableNullEqual ? MakeBooleanConstant(syntax, true) : null;
1988BoundExpression result = kind == BinaryOperatorKind.NullableNullNotEqual ?
1995private BoundExpression RewriteStringEquality(BoundBinaryOperator? oldNode, SyntaxNode syntax, BinaryOperatorKind operatorKind, BoundExpression loweredLeft, BoundExpression loweredRight, TypeSymbol type, SpecialMember member)
2008private BoundExpression RewriteDelegateOperation(SyntaxNode syntax, BinaryOperatorKind operatorKind, BoundExpression loweredLeft, BoundExpression loweredRight, TypeSymbol type, SpecialMember member)
2011if (operatorKind == BinaryOperatorKind.DelegateEqual || operatorKind == BinaryOperatorKind.DelegateNotEqual)
2019operatorKind = (operatorKind & (~BinaryOperatorKind.Delegate)) | BinaryOperatorKind.Object;
2038private BoundExpression RewriteDecimalBinaryOperation(SyntaxNode syntax, BoundExpression loweredLeft, BoundExpression loweredRight, BinaryOperatorKind operatorKind)
2047case BinaryOperatorKind.DecimalAddition: member = SpecialMember.System_Decimal__op_Addition; break;
2048case BinaryOperatorKind.DecimalSubtraction: member = SpecialMember.System_Decimal__op_Subtraction; break;
2049case BinaryOperatorKind.DecimalMultiplication: member = SpecialMember.System_Decimal__op_Multiply; break;
2050case BinaryOperatorKind.DecimalDivision: member = SpecialMember.System_Decimal__op_Division; break;
2051case BinaryOperatorKind.DecimalRemainder: member = SpecialMember.System_Decimal__op_Modulus; break;
2052case BinaryOperatorKind.DecimalEqual: member = SpecialMember.System_Decimal__op_Equality; break;
2053case BinaryOperatorKind.DecimalNotEqual: member = SpecialMember.System_Decimal__op_Inequality; break;
2054case BinaryOperatorKind.DecimalLessThan: member = SpecialMember.System_Decimal__op_LessThan; break;
2055case BinaryOperatorKind.DecimalLessThanOrEqual: member = SpecialMember.System_Decimal__op_LessThanOrEqual; break;
2056case BinaryOperatorKind.DecimalGreaterThan: member = SpecialMember.System_Decimal__op_GreaterThan; break;
2057case BinaryOperatorKind.DecimalGreaterThanOrEqual: member = SpecialMember.System_Decimal__op_GreaterThanOrEqual; break;
2069private BoundExpression MakeNullCheck(SyntaxNode syntax, BoundExpression rewrittenExpr, BinaryOperatorKind operatorKind)
2071Debug.Assert((operatorKind == BinaryOperatorKind.Equal) || (operatorKind == BinaryOperatorKind.NotEqual) ||
2072(operatorKind == BinaryOperatorKind.NullableNullEqual) || (operatorKind == BinaryOperatorKind.NullableNullNotEqual));
2090case BinaryOperatorKind.Equal:
2092case BinaryOperatorKind.NotEqual:
2108operatorKind |= BinaryOperatorKind.NullableNull;
2129BinaryOperatorKind operatorKind,
2153BinaryOperatorKind andOperatorKind = (operatorKind & ~BinaryOperatorKind.OpMask) | BinaryOperatorKind.And;
2191BinaryOperatorKind operatorKind,
2231BinaryOperatorKind andOperatorKind = (operatorKind & ~BinaryOperatorKind.OpMask) | BinaryOperatorKind.And;
2251BinaryOperatorKind kind,
2271Debug.Assert(kind.Operator() == BinaryOperatorKind.Addition);
2276kind = kind & ~BinaryOperatorKind.Checked;
2373BinaryOperatorKind multiplicationKind = BinaryOperatorKind.Multiplication;
2388multiplicationKind |= BinaryOperatorKind.Int; //i.e. signed
2401multiplicationKind |= BinaryOperatorKind.Long;
2413multiplicationKind |= BinaryOperatorKind.Long;
2425multiplicationKind |= BinaryOperatorKind.ULong;
2438multiplicationKind |= BinaryOperatorKind.Checked;
2447BinaryOperatorKind kind,
2465BinaryOperatorKind.Division,
2468kind & ~BinaryOperatorKind.Checked, // For some reason, dev10 never checks for subtraction overflow.
Lowering\LocalRewriter\LocalRewriter_CollectionExpression.cs (4)
810_factory.Binary(BinaryOperatorKind.Addition, indexTemp.Type, indexTemp, _factory.Literal(1)),
1014sideEffects.Add(new BoundAssignmentOperator(rewrittenSpreadOperand.Syntax, indexTemp, _factory.Binary(BinaryOperatorKind.Addition, indexTemp.Type, indexTemp, spreadLength), isRef: false, indexTemp.Type));
1146_factory.Binary(BinaryOperatorKind.Addition, indexTemp.Type, indexTemp, _factory.Literal(1)),
1318_factory.Binary(BinaryOperatorKind.Addition, sum.Type!, sum, value);
Lowering\LocalRewriter\LocalRewriter_FixedStatement.cs (5)
473BoundExpression notNullCheck = _factory.MakeNullCheck(factory.Syntax, factory.Local(localSymbol), BinaryOperatorKind.NotEqual);
486BoundExpression addition = factory.Binary(BinaryOperatorKind.PointerAndIntAddition, localType, factory.Local(localSymbol), helperCall);
527BoundExpression notNullCheck = _factory.MakeNullCheck(factory.Syntax, arrayTempInit, BinaryOperatorKind.NotEqual);
550BoundExpression lengthCheck = factory.Binary(BinaryOperatorKind.IntNotEqual, factory.SpecialType(SpecialType.System_Boolean), lengthCall, factory.Literal(0));
553BoundExpression condition = factory.Binary(BinaryOperatorKind.LogicalBoolAnd, factory.SpecialType(SpecialType.System_Boolean), notNullCheck, lengthCheck);
Lowering\LocalRewriter\LocalRewriter_TupleBinaryOperator.cs (14)
247ArrayBuilder<LocalSymbol> temps, BinaryOperatorKind operatorKind)
259return new BoundLiteral(left.Syntax, ConstantValue.Create(nullnull.Kind == BinaryOperatorKind.Equal), boolType);
267TypeSymbol boolType, ArrayBuilder<LocalSymbol> temps, BinaryOperatorKind operatorKind)
316bool boolValue = operatorKind == BinaryOperatorKind.Equal; // true/false
341_factory.Binary(BinaryOperatorKind.Equal, boolType, leftHasValue, rightHasValue),
486ArrayBuilder<LocalSymbol> temps, BinaryOperatorKind operatorKind)
502var logicalOperator = operatorKind == BinaryOperatorKind.Equal ? BinaryOperatorKind.LogicalBoolAnd : BinaryOperatorKind.LogicalBoolOr;
542BoundExpression left, BoundExpression right, TypeSymbol boolType, BinaryOperatorKind operatorKind)
556if (operatorKind == BinaryOperatorKind.Equal)
569return new BoundLiteral(left.Syntax, ConstantValue.Create(operatorKind == BinaryOperatorKind.Equal), boolType);
586if (operatorKind == BinaryOperatorKind.Equal)
Lowering\SyntheticBoundNodeFactory.cs (26)
629public BoundBinaryOperator Binary(BinaryOperatorKind kind, TypeSymbol type, BoundExpression left, BoundExpression right)
652return Binary(BinaryOperatorKind.LogicalBoolAnd, SpecialType(Microsoft.CodeAnalysis.SpecialType.System_Boolean), left, right);
659return Binary(BinaryOperatorKind.LogicalBoolOr, SpecialType(Microsoft.CodeAnalysis.SpecialType.System_Boolean), left, right);
664return Binary(BinaryOperatorKind.IntEqual, SpecialType(Microsoft.CodeAnalysis.SpecialType.System_Boolean), left, right);
669return Binary(BinaryOperatorKind.ObjectEqual, SpecialType(Microsoft.CodeAnalysis.SpecialType.System_Boolean), left, right);
680return Binary(BinaryOperatorKind.ObjectNotEqual, SpecialType(Microsoft.CodeAnalysis.SpecialType.System_Boolean), left, right);
685return Binary(BinaryOperatorKind.IntNotEqual, SpecialType(Microsoft.CodeAnalysis.SpecialType.System_Boolean), left, right);
690return Binary(BinaryOperatorKind.IntLessThan, SpecialType(Microsoft.CodeAnalysis.SpecialType.System_Boolean), left, right);
695return Binary(BinaryOperatorKind.IntGreaterThanOrEqual, SpecialType(CodeAnalysis.SpecialType.System_Boolean), left, right);
700return Binary(BinaryOperatorKind.IntSubtraction, SpecialType(CodeAnalysis.SpecialType.System_Int32), left, right);
705return Binary(BinaryOperatorKind.IntMultiplication, SpecialType(CodeAnalysis.SpecialType.System_Int32), left, right);
1741internal BoundExpression MakeNullCheck(SyntaxNode syntax, BoundExpression rewrittenExpr, BinaryOperatorKind operatorKind)
1743Debug.Assert((operatorKind == BinaryOperatorKind.Equal) || (operatorKind == BinaryOperatorKind.NotEqual) ||
1744(operatorKind == BinaryOperatorKind.NullableNullEqual) || (operatorKind == BinaryOperatorKind.NullableNullNotEqual));
1762case BinaryOperatorKind.Equal:
1764case BinaryOperatorKind.NotEqual:
1780operatorKind |= BinaryOperatorKind.NullableNull;
1783if (operatorKind == BinaryOperatorKind.NullableNullEqual || operatorKind == BinaryOperatorKind.NullableNullNotEqual)
1805BinaryOperatorKind kind,
1831return Literal(kind == BinaryOperatorKind.NullableNullEqual);
1846value: Literal(kind == BinaryOperatorKind.NullableNullNotEqual),
1862var whenNull = kind == BinaryOperatorKind.NullableNullEqual ? Literal(true) : null;
1868BoundExpression result = kind == BinaryOperatorKind.NullableNullNotEqual ?
Utilities\IValueSet.cs (13)
35/// are <see cref="BinaryOperatorKind.Equal"/> for all supported types, and for numeric types we also support
36/// <see cref="BinaryOperatorKind.LessThan"/>, <see cref="BinaryOperatorKind.LessThanOrEqual"/>, <see cref="BinaryOperatorKind.GreaterThan"/>, and
37/// <see cref="BinaryOperatorKind.GreaterThanOrEqual"/>.
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);
85bool Any(BinaryOperatorKind relation, T value);
89/// Because of that all four combinations of results from <see cref="Any(BinaryOperatorKind, T)"/> and <see cref="All(BinaryOperatorKind, T)"/>
94bool All(BinaryOperatorKind relation, T value);