public BoundUserDefinedConditionalLogicalOperator( CSharpSyntaxNode syntax, BinaryOperatorKind operatorKind, BoundExpression left, BoundExpression right, MethodSymbol logicalOperator, MethodSymbol trueOperator, MethodSymbol falseOperator, LookupResultKind resultKind, ImmutableArray <MethodSymbol> originalUserDefinedOperatorsOpt, TypeSymbol type, bool hasErrors = false) : this( syntax, operatorKind, left, right, logicalOperator, trueOperator, falseOperator, resultKind, type, hasErrors) { Debug.Assert(operatorKind.IsUserDefined() && operatorKind.IsLogical()); this.OriginalUserDefinedOperatorsOpt = originalUserDefinedOperatorsOpt; }
public static BinaryOperatorKind OpKind(BinaryOperatorKind kind, TypeSymbol left, TypeSymbol right) { int leftIndex = left.TypeToIndex(); if (leftIndex < 0) { return(BinaryOperatorKind.Error); } int rightIndex = right.TypeToIndex(); if (rightIndex < 0) { return(BinaryOperatorKind.Error); } var result = BinaryOperatorKind.Error; // kind.OperatorIndex() collapses '&' and '&&' (and '|' and '||'). To correct // this problem, we handle kinds satisfying IsLogical() separately. Fortunately, // such operators only work on boolean types, so there's no need to write out // a whole new table. // // Example: int & int is legal, but int && int is not, so we can't use the same // table for both operators. if (!kind.IsLogical() || (leftIndex == (int)BinaryOperatorKind.Bool && rightIndex == (int)BinaryOperatorKind.Bool)) { result = s_opkind[kind.OperatorIndex()][leftIndex, rightIndex]; } return(result == BinaryOperatorKind.Error ? result : result | kind); }
private static string GetBinaryOperatorName(BinaryOperatorKind opKind, out bool isChecked, out bool isLifted, out bool requiresLifted) { isChecked = opKind.IsChecked(); isLifted = opKind.IsLifted(); requiresLifted = opKind.IsComparison(); switch (opKind.Operator()) { case BinaryOperatorKind.Addition: return(isChecked ? "AddChecked" : "Add"); case BinaryOperatorKind.Multiplication: return(isChecked ? "MultiplyChecked" : "Multiply"); case BinaryOperatorKind.Subtraction: return(isChecked ? "SubtractChecked" : "Subtract"); case BinaryOperatorKind.Division: return("Divide"); case BinaryOperatorKind.Remainder: return("Modulo"); case BinaryOperatorKind.And: return(opKind.IsLogical() ? "AndAlso" : "And"); case BinaryOperatorKind.Xor: return("ExclusiveOr"); case BinaryOperatorKind.Or: return(opKind.IsLogical() ? "OrElse" : "Or"); case BinaryOperatorKind.LeftShift: return("LeftShift"); case BinaryOperatorKind.RightShift: return("RightShift"); case BinaryOperatorKind.Equal: return("Equal"); case BinaryOperatorKind.NotEqual: return("NotEqual"); case BinaryOperatorKind.LessThan: return("LessThan"); case BinaryOperatorKind.LessThanOrEqual: return("LessThanOrEqual"); case BinaryOperatorKind.GreaterThan: return("GreaterThan"); case BinaryOperatorKind.GreaterThanOrEqual: return("GreaterThanOrEqual"); default: throw ExceptionUtilities.UnexpectedValue(opKind.Operator()); } }
internal LoweredDynamicOperation MakeDynamicBinaryOperator( BinaryOperatorKind operatorKind, BoundExpression loweredLeft, BoundExpression loweredRight, bool isCompoundAssignment, TypeSymbol resultType) { Debug.Assert(operatorKind.IsDynamic()); _factory.Syntax = loweredLeft.Syntax; CSharpBinderFlags binderFlags = 0; if (operatorKind.IsChecked()) { binderFlags |= CSharpBinderFlags.CheckedContext; } if (operatorKind.IsLogical()) { binderFlags |= CSharpBinderFlags.BinaryOperationLogical; } var loweredArguments = ImmutableArray.Create <BoundExpression>(loweredLeft, loweredRight); MethodSymbol argumentInfoFactory = GetArgumentInfoFactory(); var binderConstruction = ((object)argumentInfoFactory != null) ? MakeBinderConstruction(WellKnownMember.Microsoft_CSharp_RuntimeBinder_Binder__BinaryOperation, new[] { // flags: _factory.Literal((int)binderFlags), // expression type: _factory.Literal((int)operatorKind.ToExpressionType(isCompoundAssignment)), // context: _factory.TypeofDynamicOperationContextType(), // argument infos: MakeCallSiteArgumentInfos(argumentInfoFactory, loweredArguments) }) : null; return(MakeDynamicOperation(binderConstruction, null, RefKind.None, loweredArguments, default(ImmutableArray <RefKind>), null, resultType)); }
private BoundExpression LowerUserDefinedBinaryOperator( CSharpSyntaxNode syntax, BinaryOperatorKind operatorKind, BoundExpression loweredLeft, BoundExpression loweredRight, TypeSymbol type, MethodSymbol method) { Debug.Assert(!operatorKind.IsLogical()); if (operatorKind.IsLifted()) { return RewriteLiftedBinaryOperator(syntax, operatorKind, loweredLeft, loweredRight, type, method); } // Otherwise, nothing special here. Debug.Assert((object)method != null); Debug.Assert(method.ReturnType == type); return BoundCall.Synthesized(syntax, null, method, loweredLeft, loweredRight); }
private BoundExpression MakeBinaryOperator( BoundBinaryOperator oldNode, CSharpSyntaxNode syntax, BinaryOperatorKind operatorKind, BoundExpression loweredLeft, BoundExpression loweredRight, TypeSymbol type, MethodSymbol method, bool isPointerElementAccess = false, bool isCompoundAssignment = false, BoundUnaryOperator applyParentUnaryOperator = null) { Debug.Assert(oldNode == null || (oldNode.Syntax == syntax)); if (_inExpressionLambda) { switch (operatorKind.Operator() | operatorKind.OperandTypes()) { case BinaryOperatorKind.ObjectAndStringConcatenation: case BinaryOperatorKind.StringAndObjectConcatenation: case BinaryOperatorKind.StringConcatenation: return RewriteStringConcatenation(syntax, operatorKind, loweredLeft, loweredRight, type); case BinaryOperatorKind.DelegateCombination: return RewriteDelegateOperation(syntax, operatorKind, loweredLeft, loweredRight, type, SpecialMember.System_Delegate__Combine); case BinaryOperatorKind.DelegateRemoval: return RewriteDelegateOperation(syntax, operatorKind, loweredLeft, loweredRight, type, SpecialMember.System_Delegate__Remove); case BinaryOperatorKind.DelegateEqual: return RewriteDelegateOperation(syntax, operatorKind, loweredLeft, loweredRight, type, SpecialMember.System_Delegate__op_Equality); case BinaryOperatorKind.DelegateNotEqual: return RewriteDelegateOperation(syntax, operatorKind, loweredLeft, loweredRight, type, SpecialMember.System_Delegate__op_Inequality); } } else // try to lower the expression. { if (operatorKind.IsDynamic()) { Debug.Assert(!isPointerElementAccess); if (operatorKind.IsLogical()) { return MakeDynamicLogicalBinaryOperator(syntax, operatorKind, loweredLeft, loweredRight, method, type, isCompoundAssignment, applyParentUnaryOperator); } else { Debug.Assert((object)method == null); return _dynamicFactory.MakeDynamicBinaryOperator(operatorKind, loweredLeft, loweredRight, isCompoundAssignment, type).ToExpression(); } } if (operatorKind.IsLifted()) { return RewriteLiftedBinaryOperator(syntax, operatorKind, loweredLeft, loweredRight, type, method); } if (operatorKind.IsUserDefined()) { return LowerUserDefinedBinaryOperator(syntax, operatorKind, loweredLeft, loweredRight, type, method); } switch (operatorKind.OperatorWithLogical() | operatorKind.OperandTypes()) { case BinaryOperatorKind.NullableNullEqual: case BinaryOperatorKind.NullableNullNotEqual: return RewriteNullableNullEquality(syntax, operatorKind, loweredLeft, loweredRight, type); case BinaryOperatorKind.ObjectAndStringConcatenation: case BinaryOperatorKind.StringAndObjectConcatenation: case BinaryOperatorKind.StringConcatenation: return RewriteStringConcatenation(syntax, operatorKind, loweredLeft, loweredRight, type); case BinaryOperatorKind.StringEqual: return RewriteStringEquality(oldNode, syntax, operatorKind, loweredLeft, loweredRight, type, SpecialMember.System_String__op_Equality); case BinaryOperatorKind.StringNotEqual: return RewriteStringEquality(oldNode, syntax, operatorKind, loweredLeft, loweredRight, type, SpecialMember.System_String__op_Inequality); case BinaryOperatorKind.DelegateCombination: return RewriteDelegateOperation(syntax, operatorKind, loweredLeft, loweredRight, type, SpecialMember.System_Delegate__Combine); case BinaryOperatorKind.DelegateRemoval: return RewriteDelegateOperation(syntax, operatorKind, loweredLeft, loweredRight, type, SpecialMember.System_Delegate__Remove); case BinaryOperatorKind.DelegateEqual: return RewriteDelegateOperation(syntax, operatorKind, loweredLeft, loweredRight, type, SpecialMember.System_Delegate__op_Equality); case BinaryOperatorKind.DelegateNotEqual: return RewriteDelegateOperation(syntax, operatorKind, loweredLeft, loweredRight, type, SpecialMember.System_Delegate__op_Inequality); case BinaryOperatorKind.LogicalBoolAnd: if (loweredRight.ConstantValue == ConstantValue.True) return loweredLeft; if (loweredLeft.ConstantValue == ConstantValue.True) return loweredRight; if (loweredLeft.ConstantValue == ConstantValue.False) return loweredLeft; if (loweredRight.Kind == BoundKind.Local || loweredRight.Kind == BoundKind.Parameter) { operatorKind &= ~BinaryOperatorKind.Logical; } goto default; case BinaryOperatorKind.LogicalBoolOr: if (loweredRight.ConstantValue == ConstantValue.False) return loweredLeft; if (loweredLeft.ConstantValue == ConstantValue.False) return loweredRight; if (loweredLeft.ConstantValue == ConstantValue.True) return loweredLeft; if (loweredRight.Kind == BoundKind.Local || loweredRight.Kind == BoundKind.Parameter) { operatorKind &= ~BinaryOperatorKind.Logical; } goto default; case BinaryOperatorKind.BoolAnd: if (loweredRight.ConstantValue == ConstantValue.True) return loweredLeft; if (loweredLeft.ConstantValue == ConstantValue.True) return loweredRight; goto default; case BinaryOperatorKind.BoolOr: if (loweredRight.ConstantValue == ConstantValue.False) return loweredLeft; if (loweredLeft.ConstantValue == ConstantValue.False) return loweredRight; goto default; case BinaryOperatorKind.BoolEqual: if (loweredLeft.ConstantValue == ConstantValue.True) return loweredRight; if (loweredRight.ConstantValue == ConstantValue.True) return loweredLeft; if (loweredLeft.ConstantValue == ConstantValue.False) return MakeUnaryOperator(UnaryOperatorKind.BoolLogicalNegation, syntax, null, loweredRight, loweredRight.Type); if (loweredRight.ConstantValue == ConstantValue.False) return MakeUnaryOperator(UnaryOperatorKind.BoolLogicalNegation, syntax, null, loweredLeft, loweredLeft.Type); goto default; case BinaryOperatorKind.BoolNotEqual: if (loweredLeft.ConstantValue == ConstantValue.False) return loweredRight; if (loweredRight.ConstantValue == ConstantValue.False) return loweredLeft; if (loweredLeft.ConstantValue == ConstantValue.True) return MakeUnaryOperator(UnaryOperatorKind.BoolLogicalNegation, syntax, null, loweredRight, loweredRight.Type); if (loweredRight.ConstantValue == ConstantValue.True) return MakeUnaryOperator(UnaryOperatorKind.BoolLogicalNegation, syntax, null, loweredLeft, loweredLeft.Type); goto default; case BinaryOperatorKind.BoolXor: if (loweredLeft.ConstantValue == ConstantValue.False) return loweredRight; if (loweredRight.ConstantValue == ConstantValue.False) return loweredLeft; if (loweredLeft.ConstantValue == ConstantValue.True) return MakeUnaryOperator(UnaryOperatorKind.BoolLogicalNegation, syntax, null, loweredRight, loweredRight.Type); if (loweredRight.ConstantValue == ConstantValue.True) return MakeUnaryOperator(UnaryOperatorKind.BoolLogicalNegation, syntax, null, loweredLeft, loweredLeft.Type); goto default; case BinaryOperatorKind.IntLeftShift: case BinaryOperatorKind.UIntLeftShift: case BinaryOperatorKind.IntRightShift: case BinaryOperatorKind.UIntRightShift: return RewriteBuiltInShiftOperation(oldNode, syntax, operatorKind, loweredLeft, loweredRight, type, 0x1F); case BinaryOperatorKind.LongLeftShift: case BinaryOperatorKind.ULongLeftShift: case BinaryOperatorKind.LongRightShift: case BinaryOperatorKind.ULongRightShift: return RewriteBuiltInShiftOperation(oldNode, syntax, operatorKind, loweredLeft, loweredRight, type, 0x3F); case BinaryOperatorKind.DecimalAddition: case BinaryOperatorKind.DecimalSubtraction: case BinaryOperatorKind.DecimalMultiplication: case BinaryOperatorKind.DecimalDivision: case BinaryOperatorKind.DecimalRemainder: case BinaryOperatorKind.DecimalEqual: case BinaryOperatorKind.DecimalNotEqual: case BinaryOperatorKind.DecimalLessThan: case BinaryOperatorKind.DecimalLessThanOrEqual: case BinaryOperatorKind.DecimalGreaterThan: case BinaryOperatorKind.DecimalGreaterThanOrEqual: return RewriteDecimalBinaryOperation(syntax, loweredLeft, loweredRight, operatorKind); case BinaryOperatorKind.PointerAndIntAddition: case BinaryOperatorKind.PointerAndUIntAddition: case BinaryOperatorKind.PointerAndLongAddition: case BinaryOperatorKind.PointerAndULongAddition: case BinaryOperatorKind.PointerAndIntSubtraction: case BinaryOperatorKind.PointerAndUIntSubtraction: case BinaryOperatorKind.PointerAndLongSubtraction: case BinaryOperatorKind.PointerAndULongSubtraction: if (loweredRight.IsDefaultValue()) { return loweredLeft; } return RewritePointerNumericOperator(syntax, operatorKind, loweredLeft, loweredRight, type, isPointerElementAccess, isLeftPointer: true); case BinaryOperatorKind.IntAndPointerAddition: case BinaryOperatorKind.UIntAndPointerAddition: case BinaryOperatorKind.LongAndPointerAddition: case BinaryOperatorKind.ULongAndPointerAddition: if (loweredLeft.IsDefaultValue()) { return loweredRight; } return RewritePointerNumericOperator(syntax, operatorKind, loweredLeft, loweredRight, type, isPointerElementAccess, isLeftPointer: false); case BinaryOperatorKind.PointerSubtraction: return RewritePointerSubtraction(operatorKind, loweredLeft, loweredRight, type); case BinaryOperatorKind.IntAddition: case BinaryOperatorKind.UIntAddition: case BinaryOperatorKind.LongAddition: case BinaryOperatorKind.ULongAddition: if (loweredLeft.IsDefaultValue()) { return loweredRight; } if (loweredRight.IsDefaultValue()) { return loweredLeft; } goto default; case BinaryOperatorKind.IntSubtraction: case BinaryOperatorKind.LongSubtraction: case BinaryOperatorKind.UIntSubtraction: case BinaryOperatorKind.ULongSubtraction: if (loweredRight.IsDefaultValue()) { return loweredLeft; } goto default; case BinaryOperatorKind.IntMultiplication: case BinaryOperatorKind.LongMultiplication: case BinaryOperatorKind.UIntMultiplication: case BinaryOperatorKind.ULongMultiplication: if (loweredLeft.IsDefaultValue()) { return loweredLeft; } if (loweredRight.IsDefaultValue()) { return loweredRight; } if (loweredLeft.ConstantValue?.UInt64Value == 1) { return loweredRight; } if (loweredRight.ConstantValue?.UInt64Value == 1) { return loweredLeft; } goto default; case BinaryOperatorKind.IntGreaterThan: case BinaryOperatorKind.IntLessThanOrEqual: if (loweredLeft.Kind == BoundKind.ArrayLength && loweredRight.IsDefaultValue()) { //array length is never negative var newOp = operatorKind == BinaryOperatorKind.IntGreaterThan ? BinaryOperatorKind.NotEqual : BinaryOperatorKind.Equal; operatorKind &= ~BinaryOperatorKind.OpMask; operatorKind |= newOp; loweredLeft = UnconvertArrayLength((BoundArrayLength)loweredLeft); } goto default; case BinaryOperatorKind.IntLessThan: case BinaryOperatorKind.IntGreaterThanOrEqual: if (loweredRight.Kind == BoundKind.ArrayLength && loweredLeft.IsDefaultValue()) { //array length is never negative var newOp = operatorKind == BinaryOperatorKind.IntLessThan ? BinaryOperatorKind.NotEqual : BinaryOperatorKind.Equal; operatorKind &= ~BinaryOperatorKind.OpMask; operatorKind |= newOp; loweredRight = UnconvertArrayLength((BoundArrayLength)loweredRight); } goto default; case BinaryOperatorKind.IntEqual: case BinaryOperatorKind.IntNotEqual: if (loweredLeft.Kind == BoundKind.ArrayLength && loweredRight.IsDefaultValue()) { loweredLeft = UnconvertArrayLength((BoundArrayLength)loweredLeft); } else if (loweredRight.Kind == BoundKind.ArrayLength && loweredLeft.IsDefaultValue()) { loweredRight = UnconvertArrayLength((BoundArrayLength)loweredRight); } goto default; default: break; } } return (oldNode != null) ? oldNode.Update(operatorKind, loweredLeft, loweredRight, oldNode.ConstantValueOpt, oldNode.MethodOpt, oldNode.ResultKind, type) : new BoundBinaryOperator(syntax, operatorKind, loweredLeft, loweredRight, null, null, LookupResultKind.Viable, type); }
private string GetBinaryOperatorName(BinaryOperatorKind opKind, out bool isChecked, out bool isLifted, out bool requiresLifted) { isChecked = opKind.IsChecked(); isLifted = opKind.IsLifted(); requiresLifted = opKind.IsComparison(); switch (opKind.Operator()) { case BinaryOperatorKind.Addition: return isChecked ? "AddChecked" : "Add"; case BinaryOperatorKind.Multiplication: return isChecked ? "MultiplyChecked" : "Multiply"; case BinaryOperatorKind.Subtraction: return isChecked ? "SubtractChecked" : "Subtract"; case BinaryOperatorKind.Division: return "Divide"; case BinaryOperatorKind.Remainder: return "Modulo"; case BinaryOperatorKind.And: return opKind.IsLogical() ? "AndAlso" : "And"; case BinaryOperatorKind.Xor: return "ExclusiveOr"; case BinaryOperatorKind.Or: return opKind.IsLogical() ? "OrElse" : "Or"; case BinaryOperatorKind.LeftShift: return "LeftShift"; case BinaryOperatorKind.RightShift: return "RightShift"; case BinaryOperatorKind.Equal: return "Equal"; case BinaryOperatorKind.NotEqual: return "NotEqual"; case BinaryOperatorKind.LessThan: return "LessThan"; case BinaryOperatorKind.LessThanOrEqual: return "LessThanOrEqual"; case BinaryOperatorKind.GreaterThan: return "GreaterThan"; case BinaryOperatorKind.GreaterThanOrEqual: return "GreaterThanOrEqual"; default: throw ExceptionUtilities.UnexpectedValue(opKind.Operator()); } }
private BoundExpression BindDynamicBinaryOperator( BinaryExpressionSyntax node, BinaryOperatorKind kind, BoundExpression left, BoundExpression right, DiagnosticBag diagnostics) { // This method binds binary * / % + - << >> < > <= >= == != & ! ^ && || operators where one or both // of the operands are dynamic. Debug.Assert((object)left.Type != null && left.Type.IsDynamic() || (object)right.Type != null && right.Type.IsDynamic()); bool hasError = false; bool leftValidOperand = IsLegalDynamicOperand(left); bool rightValidOperand = IsLegalDynamicOperand(right); if (!leftValidOperand || !rightValidOperand) { // Operator '{0}' cannot be applied to operands of type '{1}' and '{2}' Error(diagnostics, ErrorCode.ERR_BadBinaryOps, node, node.OperatorToken.Text, left.Display, right.Display); hasError = true; } MethodSymbol userDefinedOperator = null; if (kind.IsLogical() && leftValidOperand) { // We need to make sure left is either implicitly convertible to Boolean or has user defined truth operator. // left && right is lowered to {op_False|op_Implicit}(left) ? left : And(left, right) // left || right is lowered to {op_True|!op_Implicit}(left) ? left : Or(left, right) HashSet<DiagnosticInfo> useSiteDiagnostics = null; if (!IsValidDynamicCondition(left, isNegative: kind == BinaryOperatorKind.LogicalAnd, useSiteDiagnostics: ref useSiteDiagnostics, userDefinedOperator: out userDefinedOperator)) { // Dev11 reports ERR_MustHaveOpTF. The error was shared between this case and user-defined binary Boolean operators. // We report two distinct more specific error messages. Error(diagnostics, ErrorCode.ERR_InvalidDynamicCondition, node.Left, left.Type, kind == BinaryOperatorKind.LogicalAnd ? "false" : "true"); hasError = true; } diagnostics.Add(node, useSiteDiagnostics); } return new BoundBinaryOperator( syntax: node, operatorKind: (hasError ? kind : kind.WithType(BinaryOperatorKind.Dynamic)).WithOverflowChecksIfApplicable(CheckOverflowAtRuntime), left: left, right: right, constantValueOpt: ConstantValue.NotAvailable, methodOpt: userDefinedOperator, resultKind: LookupResultKind.Viable, type: Compilation.DynamicType, hasErrors: hasError); }
internal void GetSimpleBuiltInOperators(BinaryOperatorKind kind, ArrayBuilder <BinaryOperatorSignature> operators) { if (builtInOperators == null) { var logicalOperators = new ImmutableArray <BinaryOperatorSignature>[] { ImmutableArray <BinaryOperatorSignature> .Empty, //multiplication ImmutableArray <BinaryOperatorSignature> .Empty, //addition ImmutableArray <BinaryOperatorSignature> .Empty, //subtraction ImmutableArray <BinaryOperatorSignature> .Empty, //division ImmutableArray <BinaryOperatorSignature> .Empty, //remainder ImmutableArray <BinaryOperatorSignature> .Empty, //left shift ImmutableArray <BinaryOperatorSignature> .Empty, //right shift ImmutableArray <BinaryOperatorSignature> .Empty, //equal ImmutableArray <BinaryOperatorSignature> .Empty, //not equal ImmutableArray <BinaryOperatorSignature> .Empty, //greater than ImmutableArray <BinaryOperatorSignature> .Empty, //less than ImmutableArray <BinaryOperatorSignature> .Empty, //greater than or equal ImmutableArray <BinaryOperatorSignature> .Empty, //less than or equal ImmutableArray.Create <BinaryOperatorSignature>(GetSignature(BinaryOperatorKind.LogicalBoolAnd)), //and ImmutableArray <BinaryOperatorSignature> .Empty, //xor ImmutableArray.Create <BinaryOperatorSignature>(GetSignature(BinaryOperatorKind.LogicalBoolOr)), //or }; var nonLogicalOperators = new ImmutableArray <BinaryOperatorSignature>[] { GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.IntMultiplication, (int)BinaryOperatorKind.UIntMultiplication, (int)BinaryOperatorKind.LongMultiplication, (int)BinaryOperatorKind.ULongMultiplication, (int)BinaryOperatorKind.FloatMultiplication, (int)BinaryOperatorKind.DoubleMultiplication, (int)BinaryOperatorKind.DecimalMultiplication, (int)BinaryOperatorKind.LiftedIntMultiplication, (int)BinaryOperatorKind.LiftedUIntMultiplication, (int)BinaryOperatorKind.LiftedLongMultiplication, (int)BinaryOperatorKind.LiftedULongMultiplication, (int)BinaryOperatorKind.LiftedFloatMultiplication, (int)BinaryOperatorKind.LiftedDoubleMultiplication, (int)BinaryOperatorKind.LiftedDecimalMultiplication, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.IntAddition, (int)BinaryOperatorKind.UIntAddition, (int)BinaryOperatorKind.LongAddition, (int)BinaryOperatorKind.ULongAddition, (int)BinaryOperatorKind.FloatAddition, (int)BinaryOperatorKind.DoubleAddition, (int)BinaryOperatorKind.DecimalAddition, (int)BinaryOperatorKind.LiftedIntAddition, (int)BinaryOperatorKind.LiftedUIntAddition, (int)BinaryOperatorKind.LiftedLongAddition, (int)BinaryOperatorKind.LiftedULongAddition, (int)BinaryOperatorKind.LiftedFloatAddition, (int)BinaryOperatorKind.LiftedDoubleAddition, (int)BinaryOperatorKind.LiftedDecimalAddition, (int)BinaryOperatorKind.StringConcatenation, (int)BinaryOperatorKind.StringAndObjectConcatenation, (int)BinaryOperatorKind.ObjectAndStringConcatenation, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.IntSubtraction, (int)BinaryOperatorKind.UIntSubtraction, (int)BinaryOperatorKind.LongSubtraction, (int)BinaryOperatorKind.ULongSubtraction, (int)BinaryOperatorKind.FloatSubtraction, (int)BinaryOperatorKind.DoubleSubtraction, (int)BinaryOperatorKind.DecimalSubtraction, (int)BinaryOperatorKind.LiftedIntSubtraction, (int)BinaryOperatorKind.LiftedUIntSubtraction, (int)BinaryOperatorKind.LiftedLongSubtraction, (int)BinaryOperatorKind.LiftedULongSubtraction, (int)BinaryOperatorKind.LiftedFloatSubtraction, (int)BinaryOperatorKind.LiftedDoubleSubtraction, (int)BinaryOperatorKind.LiftedDecimalSubtraction, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.IntDivision, (int)BinaryOperatorKind.UIntDivision, (int)BinaryOperatorKind.LongDivision, (int)BinaryOperatorKind.ULongDivision, (int)BinaryOperatorKind.FloatDivision, (int)BinaryOperatorKind.DoubleDivision, (int)BinaryOperatorKind.DecimalDivision, (int)BinaryOperatorKind.LiftedIntDivision, (int)BinaryOperatorKind.LiftedUIntDivision, (int)BinaryOperatorKind.LiftedLongDivision, (int)BinaryOperatorKind.LiftedULongDivision, (int)BinaryOperatorKind.LiftedFloatDivision, (int)BinaryOperatorKind.LiftedDoubleDivision, (int)BinaryOperatorKind.LiftedDecimalDivision, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.IntRemainder, (int)BinaryOperatorKind.UIntRemainder, (int)BinaryOperatorKind.LongRemainder, (int)BinaryOperatorKind.ULongRemainder, (int)BinaryOperatorKind.FloatRemainder, (int)BinaryOperatorKind.DoubleRemainder, (int)BinaryOperatorKind.DecimalRemainder, (int)BinaryOperatorKind.LiftedIntRemainder, (int)BinaryOperatorKind.LiftedUIntRemainder, (int)BinaryOperatorKind.LiftedLongRemainder, (int)BinaryOperatorKind.LiftedULongRemainder, (int)BinaryOperatorKind.LiftedFloatRemainder, (int)BinaryOperatorKind.LiftedDoubleRemainder, (int)BinaryOperatorKind.LiftedDecimalRemainder, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.IntLeftShift, (int)BinaryOperatorKind.UIntLeftShift, (int)BinaryOperatorKind.LongLeftShift, (int)BinaryOperatorKind.ULongLeftShift, (int)BinaryOperatorKind.LiftedIntLeftShift, (int)BinaryOperatorKind.LiftedUIntLeftShift, (int)BinaryOperatorKind.LiftedLongLeftShift, (int)BinaryOperatorKind.LiftedULongLeftShift, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.IntRightShift, (int)BinaryOperatorKind.UIntRightShift, (int)BinaryOperatorKind.LongRightShift, (int)BinaryOperatorKind.ULongRightShift, (int)BinaryOperatorKind.LiftedIntRightShift, (int)BinaryOperatorKind.LiftedUIntRightShift, (int)BinaryOperatorKind.LiftedLongRightShift, (int)BinaryOperatorKind.LiftedULongRightShift, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.IntEqual, (int)BinaryOperatorKind.UIntEqual, (int)BinaryOperatorKind.LongEqual, (int)BinaryOperatorKind.ULongEqual, (int)BinaryOperatorKind.FloatEqual, (int)BinaryOperatorKind.DoubleEqual, (int)BinaryOperatorKind.DecimalEqual, (int)BinaryOperatorKind.BoolEqual, (int)BinaryOperatorKind.LiftedIntEqual, (int)BinaryOperatorKind.LiftedUIntEqual, (int)BinaryOperatorKind.LiftedLongEqual, (int)BinaryOperatorKind.LiftedULongEqual, (int)BinaryOperatorKind.LiftedFloatEqual, (int)BinaryOperatorKind.LiftedDoubleEqual, (int)BinaryOperatorKind.LiftedDecimalEqual, (int)BinaryOperatorKind.LiftedBoolEqual, (int)BinaryOperatorKind.ObjectEqual, (int)BinaryOperatorKind.StringEqual, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.IntNotEqual, (int)BinaryOperatorKind.UIntNotEqual, (int)BinaryOperatorKind.LongNotEqual, (int)BinaryOperatorKind.ULongNotEqual, (int)BinaryOperatorKind.FloatNotEqual, (int)BinaryOperatorKind.DoubleNotEqual, (int)BinaryOperatorKind.DecimalNotEqual, (int)BinaryOperatorKind.BoolNotEqual, (int)BinaryOperatorKind.LiftedIntNotEqual, (int)BinaryOperatorKind.LiftedUIntNotEqual, (int)BinaryOperatorKind.LiftedLongNotEqual, (int)BinaryOperatorKind.LiftedULongNotEqual, (int)BinaryOperatorKind.LiftedFloatNotEqual, (int)BinaryOperatorKind.LiftedDoubleNotEqual, (int)BinaryOperatorKind.LiftedDecimalNotEqual, (int)BinaryOperatorKind.LiftedBoolNotEqual, (int)BinaryOperatorKind.ObjectNotEqual, (int)BinaryOperatorKind.StringNotEqual, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.IntGreaterThan, (int)BinaryOperatorKind.UIntGreaterThan, (int)BinaryOperatorKind.LongGreaterThan, (int)BinaryOperatorKind.ULongGreaterThan, (int)BinaryOperatorKind.FloatGreaterThan, (int)BinaryOperatorKind.DoubleGreaterThan, (int)BinaryOperatorKind.DecimalGreaterThan, (int)BinaryOperatorKind.LiftedIntGreaterThan, (int)BinaryOperatorKind.LiftedUIntGreaterThan, (int)BinaryOperatorKind.LiftedLongGreaterThan, (int)BinaryOperatorKind.LiftedULongGreaterThan, (int)BinaryOperatorKind.LiftedFloatGreaterThan, (int)BinaryOperatorKind.LiftedDoubleGreaterThan, (int)BinaryOperatorKind.LiftedDecimalGreaterThan, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.IntLessThan, (int)BinaryOperatorKind.UIntLessThan, (int)BinaryOperatorKind.LongLessThan, (int)BinaryOperatorKind.ULongLessThan, (int)BinaryOperatorKind.FloatLessThan, (int)BinaryOperatorKind.DoubleLessThan, (int)BinaryOperatorKind.DecimalLessThan, (int)BinaryOperatorKind.LiftedIntLessThan, (int)BinaryOperatorKind.LiftedUIntLessThan, (int)BinaryOperatorKind.LiftedLongLessThan, (int)BinaryOperatorKind.LiftedULongLessThan, (int)BinaryOperatorKind.LiftedFloatLessThan, (int)BinaryOperatorKind.LiftedDoubleLessThan, (int)BinaryOperatorKind.LiftedDecimalLessThan, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.IntGreaterThanOrEqual, (int)BinaryOperatorKind.UIntGreaterThanOrEqual, (int)BinaryOperatorKind.LongGreaterThanOrEqual, (int)BinaryOperatorKind.ULongGreaterThanOrEqual, (int)BinaryOperatorKind.FloatGreaterThanOrEqual, (int)BinaryOperatorKind.DoubleGreaterThanOrEqual, (int)BinaryOperatorKind.DecimalGreaterThanOrEqual, (int)BinaryOperatorKind.LiftedIntGreaterThanOrEqual, (int)BinaryOperatorKind.LiftedUIntGreaterThanOrEqual, (int)BinaryOperatorKind.LiftedLongGreaterThanOrEqual, (int)BinaryOperatorKind.LiftedULongGreaterThanOrEqual, (int)BinaryOperatorKind.LiftedFloatGreaterThanOrEqual, (int)BinaryOperatorKind.LiftedDoubleGreaterThanOrEqual, (int)BinaryOperatorKind.LiftedDecimalGreaterThanOrEqual, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.IntLessThanOrEqual, (int)BinaryOperatorKind.UIntLessThanOrEqual, (int)BinaryOperatorKind.LongLessThanOrEqual, (int)BinaryOperatorKind.ULongLessThanOrEqual, (int)BinaryOperatorKind.FloatLessThanOrEqual, (int)BinaryOperatorKind.DoubleLessThanOrEqual, (int)BinaryOperatorKind.DecimalLessThanOrEqual, (int)BinaryOperatorKind.LiftedIntLessThanOrEqual, (int)BinaryOperatorKind.LiftedUIntLessThanOrEqual, (int)BinaryOperatorKind.LiftedLongLessThanOrEqual, (int)BinaryOperatorKind.LiftedULongLessThanOrEqual, (int)BinaryOperatorKind.LiftedFloatLessThanOrEqual, (int)BinaryOperatorKind.LiftedDoubleLessThanOrEqual, (int)BinaryOperatorKind.LiftedDecimalLessThanOrEqual, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.IntAnd, (int)BinaryOperatorKind.UIntAnd, (int)BinaryOperatorKind.LongAnd, (int)BinaryOperatorKind.ULongAnd, (int)BinaryOperatorKind.BoolAnd, (int)BinaryOperatorKind.LiftedIntAnd, (int)BinaryOperatorKind.LiftedUIntAnd, (int)BinaryOperatorKind.LiftedLongAnd, (int)BinaryOperatorKind.LiftedULongAnd, (int)BinaryOperatorKind.LiftedBoolAnd, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.IntXor, (int)BinaryOperatorKind.UIntXor, (int)BinaryOperatorKind.LongXor, (int)BinaryOperatorKind.ULongXor, (int)BinaryOperatorKind.BoolXor, (int)BinaryOperatorKind.LiftedIntXor, (int)BinaryOperatorKind.LiftedUIntXor, (int)BinaryOperatorKind.LiftedLongXor, (int)BinaryOperatorKind.LiftedULongXor, (int)BinaryOperatorKind.LiftedBoolXor, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.IntOr, (int)BinaryOperatorKind.UIntOr, (int)BinaryOperatorKind.LongOr, (int)BinaryOperatorKind.ULongOr, (int)BinaryOperatorKind.BoolOr, (int)BinaryOperatorKind.LiftedIntOr, (int)BinaryOperatorKind.LiftedUIntOr, (int)BinaryOperatorKind.LiftedLongOr, (int)BinaryOperatorKind.LiftedULongOr, (int)BinaryOperatorKind.LiftedBoolOr, }), }; var allOperators = new[] { nonLogicalOperators, logicalOperators }; Interlocked.CompareExchange(ref builtInOperators, allOperators, null); } operators.AddRange(builtInOperators[kind.IsLogical() ? 1 : 0][kind.OperatorIndex()]); }
public BoundUserDefinedConditionalLogicalOperator( CSharpSyntaxNode syntax, BinaryOperatorKind operatorKind, BoundExpression left, BoundExpression right, MethodSymbol logicalOperator, MethodSymbol trueOperator, MethodSymbol falseOperator, LookupResultKind resultKind, ImmutableArray<MethodSymbol> originalUserDefinedOperatorsOpt, TypeSymbol type, bool hasErrors = false) : this( syntax, operatorKind, left, right, logicalOperator, trueOperator, falseOperator, resultKind, type, hasErrors) { Debug.Assert(operatorKind.IsUserDefined() && operatorKind.IsLogical()); this.OriginalUserDefinedOperatorsOpt = originalUserDefinedOperatorsOpt; }
internal void GetSimpleBuiltInOperators(BinaryOperatorKind kind, ArrayBuilder<BinaryOperatorSignature> operators) { if (builtInOperators == null) { var logicalOperators = new ImmutableArray<BinaryOperatorSignature>[] { ImmutableArray<BinaryOperatorSignature>.Empty, //multiplication ImmutableArray<BinaryOperatorSignature>.Empty, //addition ImmutableArray<BinaryOperatorSignature>.Empty, //subtraction ImmutableArray<BinaryOperatorSignature>.Empty, //division ImmutableArray<BinaryOperatorSignature>.Empty, //remainder ImmutableArray<BinaryOperatorSignature>.Empty, //left shift ImmutableArray<BinaryOperatorSignature>.Empty, //right shift ImmutableArray<BinaryOperatorSignature>.Empty, //equal ImmutableArray<BinaryOperatorSignature>.Empty, //not equal ImmutableArray<BinaryOperatorSignature>.Empty, //greater than ImmutableArray<BinaryOperatorSignature>.Empty, //less than ImmutableArray<BinaryOperatorSignature>.Empty, //greater than or equal ImmutableArray<BinaryOperatorSignature>.Empty, //less than or equal ImmutableArray.Create<BinaryOperatorSignature>(GetSignature(BinaryOperatorKind.LogicalBoolAnd)), //and ImmutableArray<BinaryOperatorSignature>.Empty, //xor ImmutableArray.Create<BinaryOperatorSignature>(GetSignature(BinaryOperatorKind.LogicalBoolOr)), //or }; var nonLogicalOperators = new ImmutableArray<BinaryOperatorSignature>[] { (new [] { GetSignature(BinaryOperatorKind.IntMultiplication), GetSignature(BinaryOperatorKind.UIntMultiplication), GetSignature(BinaryOperatorKind.LongMultiplication), GetSignature(BinaryOperatorKind.ULongMultiplication), GetSignature(BinaryOperatorKind.FloatMultiplication), GetSignature(BinaryOperatorKind.DoubleMultiplication), GetSignature(BinaryOperatorKind.DecimalMultiplication), GetSignature(BinaryOperatorKind.LiftedIntMultiplication), GetSignature(BinaryOperatorKind.LiftedUIntMultiplication), GetSignature(BinaryOperatorKind.LiftedLongMultiplication), GetSignature(BinaryOperatorKind.LiftedULongMultiplication), GetSignature(BinaryOperatorKind.LiftedFloatMultiplication), GetSignature(BinaryOperatorKind.LiftedDoubleMultiplication), GetSignature(BinaryOperatorKind.LiftedDecimalMultiplication), }).AsImmutableOrNull(), (new [] { GetSignature(BinaryOperatorKind.IntAddition), GetSignature(BinaryOperatorKind.UIntAddition), GetSignature(BinaryOperatorKind.LongAddition), GetSignature(BinaryOperatorKind.ULongAddition), GetSignature(BinaryOperatorKind.FloatAddition), GetSignature(BinaryOperatorKind.DoubleAddition), GetSignature(BinaryOperatorKind.DecimalAddition), GetSignature(BinaryOperatorKind.LiftedIntAddition), GetSignature(BinaryOperatorKind.LiftedUIntAddition), GetSignature(BinaryOperatorKind.LiftedLongAddition), GetSignature(BinaryOperatorKind.LiftedULongAddition), GetSignature(BinaryOperatorKind.LiftedFloatAddition), GetSignature(BinaryOperatorKind.LiftedDoubleAddition), GetSignature(BinaryOperatorKind.LiftedDecimalAddition), GetSignature(BinaryOperatorKind.StringConcatenation), GetSignature(BinaryOperatorKind.StringAndObjectConcatenation), GetSignature(BinaryOperatorKind.ObjectAndStringConcatenation), }).AsImmutableOrNull(), (new [] { GetSignature(BinaryOperatorKind.IntSubtraction), GetSignature(BinaryOperatorKind.UIntSubtraction), GetSignature(BinaryOperatorKind.LongSubtraction), GetSignature(BinaryOperatorKind.ULongSubtraction), GetSignature(BinaryOperatorKind.FloatSubtraction), GetSignature(BinaryOperatorKind.DoubleSubtraction), GetSignature(BinaryOperatorKind.DecimalSubtraction), GetSignature(BinaryOperatorKind.LiftedIntSubtraction), GetSignature(BinaryOperatorKind.LiftedUIntSubtraction), GetSignature(BinaryOperatorKind.LiftedLongSubtraction), GetSignature(BinaryOperatorKind.LiftedULongSubtraction), GetSignature(BinaryOperatorKind.LiftedFloatSubtraction), GetSignature(BinaryOperatorKind.LiftedDoubleSubtraction), GetSignature(BinaryOperatorKind.LiftedDecimalSubtraction), }).AsImmutableOrNull(), (new [] { GetSignature(BinaryOperatorKind.IntDivision), GetSignature(BinaryOperatorKind.UIntDivision), GetSignature(BinaryOperatorKind.LongDivision), GetSignature(BinaryOperatorKind.ULongDivision), GetSignature(BinaryOperatorKind.FloatDivision), GetSignature(BinaryOperatorKind.DoubleDivision), GetSignature(BinaryOperatorKind.DecimalDivision), GetSignature(BinaryOperatorKind.LiftedIntDivision), GetSignature(BinaryOperatorKind.LiftedUIntDivision), GetSignature(BinaryOperatorKind.LiftedLongDivision), GetSignature(BinaryOperatorKind.LiftedULongDivision), GetSignature(BinaryOperatorKind.LiftedFloatDivision), GetSignature(BinaryOperatorKind.LiftedDoubleDivision), GetSignature(BinaryOperatorKind.LiftedDecimalDivision), }).AsImmutableOrNull(), (new [] { GetSignature(BinaryOperatorKind.IntRemainder), GetSignature(BinaryOperatorKind.UIntRemainder), GetSignature(BinaryOperatorKind.LongRemainder), GetSignature(BinaryOperatorKind.ULongRemainder), GetSignature(BinaryOperatorKind.FloatRemainder), GetSignature(BinaryOperatorKind.DoubleRemainder), GetSignature(BinaryOperatorKind.DecimalRemainder), GetSignature(BinaryOperatorKind.LiftedIntRemainder), GetSignature(BinaryOperatorKind.LiftedUIntRemainder), GetSignature(BinaryOperatorKind.LiftedLongRemainder), GetSignature(BinaryOperatorKind.LiftedULongRemainder), GetSignature(BinaryOperatorKind.LiftedFloatRemainder), GetSignature(BinaryOperatorKind.LiftedDoubleRemainder), GetSignature(BinaryOperatorKind.LiftedDecimalRemainder), }).AsImmutableOrNull(), (new [] { GetSignature(BinaryOperatorKind.IntLeftShift), GetSignature(BinaryOperatorKind.UIntLeftShift), GetSignature(BinaryOperatorKind.LongLeftShift), GetSignature(BinaryOperatorKind.ULongLeftShift), GetSignature(BinaryOperatorKind.LiftedIntLeftShift), GetSignature(BinaryOperatorKind.LiftedUIntLeftShift), GetSignature(BinaryOperatorKind.LiftedLongLeftShift), GetSignature(BinaryOperatorKind.LiftedULongLeftShift), }).AsImmutableOrNull(), (new [] { GetSignature(BinaryOperatorKind.IntRightShift), GetSignature(BinaryOperatorKind.UIntRightShift), GetSignature(BinaryOperatorKind.LongRightShift), GetSignature(BinaryOperatorKind.ULongRightShift), GetSignature(BinaryOperatorKind.LiftedIntRightShift), GetSignature(BinaryOperatorKind.LiftedUIntRightShift), GetSignature(BinaryOperatorKind.LiftedLongRightShift), GetSignature(BinaryOperatorKind.LiftedULongRightShift), }).AsImmutableOrNull(), (new [] { GetSignature(BinaryOperatorKind.IntEqual), GetSignature(BinaryOperatorKind.UIntEqual), GetSignature(BinaryOperatorKind.LongEqual), GetSignature(BinaryOperatorKind.ULongEqual), GetSignature(BinaryOperatorKind.FloatEqual), GetSignature(BinaryOperatorKind.DoubleEqual), GetSignature(BinaryOperatorKind.DecimalEqual), GetSignature(BinaryOperatorKind.BoolEqual), GetSignature(BinaryOperatorKind.LiftedIntEqual), GetSignature(BinaryOperatorKind.LiftedUIntEqual), GetSignature(BinaryOperatorKind.LiftedLongEqual), GetSignature(BinaryOperatorKind.LiftedULongEqual), GetSignature(BinaryOperatorKind.LiftedFloatEqual), GetSignature(BinaryOperatorKind.LiftedDoubleEqual), GetSignature(BinaryOperatorKind.LiftedDecimalEqual), GetSignature(BinaryOperatorKind.LiftedBoolEqual), GetSignature(BinaryOperatorKind.ObjectEqual), GetSignature(BinaryOperatorKind.StringEqual), }).AsImmutableOrNull(), (new [] { GetSignature(BinaryOperatorKind.IntNotEqual), GetSignature(BinaryOperatorKind.UIntNotEqual), GetSignature(BinaryOperatorKind.LongNotEqual), GetSignature(BinaryOperatorKind.ULongNotEqual), GetSignature(BinaryOperatorKind.FloatNotEqual), GetSignature(BinaryOperatorKind.DoubleNotEqual), GetSignature(BinaryOperatorKind.DecimalNotEqual), GetSignature(BinaryOperatorKind.BoolNotEqual), GetSignature(BinaryOperatorKind.LiftedIntNotEqual), GetSignature(BinaryOperatorKind.LiftedUIntNotEqual), GetSignature(BinaryOperatorKind.LiftedLongNotEqual), GetSignature(BinaryOperatorKind.LiftedULongNotEqual), GetSignature(BinaryOperatorKind.LiftedFloatNotEqual), GetSignature(BinaryOperatorKind.LiftedDoubleNotEqual), GetSignature(BinaryOperatorKind.LiftedDecimalNotEqual), GetSignature(BinaryOperatorKind.LiftedBoolNotEqual), GetSignature(BinaryOperatorKind.ObjectNotEqual), GetSignature(BinaryOperatorKind.StringNotEqual), }).AsImmutableOrNull(), (new [] { GetSignature(BinaryOperatorKind.IntGreaterThan), GetSignature(BinaryOperatorKind.UIntGreaterThan), GetSignature(BinaryOperatorKind.LongGreaterThan), GetSignature(BinaryOperatorKind.ULongGreaterThan), GetSignature(BinaryOperatorKind.FloatGreaterThan), GetSignature(BinaryOperatorKind.DoubleGreaterThan), GetSignature(BinaryOperatorKind.DecimalGreaterThan), GetSignature(BinaryOperatorKind.LiftedIntGreaterThan), GetSignature(BinaryOperatorKind.LiftedUIntGreaterThan), GetSignature(BinaryOperatorKind.LiftedLongGreaterThan), GetSignature(BinaryOperatorKind.LiftedULongGreaterThan), GetSignature(BinaryOperatorKind.LiftedFloatGreaterThan), GetSignature(BinaryOperatorKind.LiftedDoubleGreaterThan), GetSignature(BinaryOperatorKind.LiftedDecimalGreaterThan), }).AsImmutableOrNull(), (new [] { GetSignature(BinaryOperatorKind.IntLessThan), GetSignature(BinaryOperatorKind.UIntLessThan), GetSignature(BinaryOperatorKind.LongLessThan), GetSignature(BinaryOperatorKind.ULongLessThan), GetSignature(BinaryOperatorKind.FloatLessThan), GetSignature(BinaryOperatorKind.DoubleLessThan), GetSignature(BinaryOperatorKind.DecimalLessThan), GetSignature(BinaryOperatorKind.LiftedIntLessThan), GetSignature(BinaryOperatorKind.LiftedUIntLessThan), GetSignature(BinaryOperatorKind.LiftedLongLessThan), GetSignature(BinaryOperatorKind.LiftedULongLessThan), GetSignature(BinaryOperatorKind.LiftedFloatLessThan), GetSignature(BinaryOperatorKind.LiftedDoubleLessThan), GetSignature(BinaryOperatorKind.LiftedDecimalLessThan), }).AsImmutableOrNull(), (new [] { GetSignature(BinaryOperatorKind.IntGreaterThanOrEqual), GetSignature(BinaryOperatorKind.UIntGreaterThanOrEqual), GetSignature(BinaryOperatorKind.LongGreaterThanOrEqual), GetSignature(BinaryOperatorKind.ULongGreaterThanOrEqual), GetSignature(BinaryOperatorKind.FloatGreaterThanOrEqual), GetSignature(BinaryOperatorKind.DoubleGreaterThanOrEqual), GetSignature(BinaryOperatorKind.DecimalGreaterThanOrEqual), GetSignature(BinaryOperatorKind.LiftedIntGreaterThanOrEqual), GetSignature(BinaryOperatorKind.LiftedUIntGreaterThanOrEqual), GetSignature(BinaryOperatorKind.LiftedLongGreaterThanOrEqual), GetSignature(BinaryOperatorKind.LiftedULongGreaterThanOrEqual), GetSignature(BinaryOperatorKind.LiftedFloatGreaterThanOrEqual), GetSignature(BinaryOperatorKind.LiftedDoubleGreaterThanOrEqual), GetSignature(BinaryOperatorKind.LiftedDecimalGreaterThanOrEqual), }).AsImmutableOrNull(), (new [] { GetSignature(BinaryOperatorKind.IntLessThanOrEqual), GetSignature(BinaryOperatorKind.UIntLessThanOrEqual), GetSignature(BinaryOperatorKind.LongLessThanOrEqual), GetSignature(BinaryOperatorKind.ULongLessThanOrEqual), GetSignature(BinaryOperatorKind.FloatLessThanOrEqual), GetSignature(BinaryOperatorKind.DoubleLessThanOrEqual), GetSignature(BinaryOperatorKind.DecimalLessThanOrEqual), GetSignature(BinaryOperatorKind.LiftedIntLessThanOrEqual), GetSignature(BinaryOperatorKind.LiftedUIntLessThanOrEqual), GetSignature(BinaryOperatorKind.LiftedLongLessThanOrEqual), GetSignature(BinaryOperatorKind.LiftedULongLessThanOrEqual), GetSignature(BinaryOperatorKind.LiftedFloatLessThanOrEqual), GetSignature(BinaryOperatorKind.LiftedDoubleLessThanOrEqual), GetSignature(BinaryOperatorKind.LiftedDecimalLessThanOrEqual), }).AsImmutableOrNull(), (new [] { GetSignature(BinaryOperatorKind.IntAnd), GetSignature(BinaryOperatorKind.UIntAnd), GetSignature(BinaryOperatorKind.LongAnd), GetSignature(BinaryOperatorKind.ULongAnd), GetSignature(BinaryOperatorKind.BoolAnd), GetSignature(BinaryOperatorKind.LiftedIntAnd), GetSignature(BinaryOperatorKind.LiftedUIntAnd), GetSignature(BinaryOperatorKind.LiftedLongAnd), GetSignature(BinaryOperatorKind.LiftedULongAnd), GetSignature(BinaryOperatorKind.LiftedBoolAnd), }).AsImmutableOrNull(), (new [] { GetSignature(BinaryOperatorKind.IntXor), GetSignature(BinaryOperatorKind.UIntXor), GetSignature(BinaryOperatorKind.LongXor), GetSignature(BinaryOperatorKind.ULongXor), GetSignature(BinaryOperatorKind.BoolXor), GetSignature(BinaryOperatorKind.LiftedIntXor), GetSignature(BinaryOperatorKind.LiftedUIntXor), GetSignature(BinaryOperatorKind.LiftedLongXor), GetSignature(BinaryOperatorKind.LiftedULongXor), GetSignature(BinaryOperatorKind.LiftedBoolXor), }).AsImmutableOrNull(), (new [] { GetSignature(BinaryOperatorKind.IntOr), GetSignature(BinaryOperatorKind.UIntOr), GetSignature(BinaryOperatorKind.LongOr), GetSignature(BinaryOperatorKind.ULongOr), GetSignature(BinaryOperatorKind.BoolOr), GetSignature(BinaryOperatorKind.LiftedIntOr), GetSignature(BinaryOperatorKind.LiftedUIntOr), GetSignature(BinaryOperatorKind.LiftedLongOr), GetSignature(BinaryOperatorKind.LiftedULongOr), GetSignature(BinaryOperatorKind.LiftedBoolOr), }).AsImmutableOrNull(), }; var allOperators = new[] { nonLogicalOperators, logicalOperators }; Interlocked.CompareExchange(ref builtInOperators, allOperators, null); } operators.AddRange(builtInOperators[kind.IsLogical() ? 1 : 0][kind.OperatorIndex()]); }
public static BinaryOperatorKind OpKind(BinaryOperatorKind kind, TypeSymbol left, TypeSymbol right) { int? leftIndex = TypeToIndex(left); if (leftIndex == null) { return BinaryOperatorKind.Error; } int? rightIndex = TypeToIndex(right); if (rightIndex == null) { return BinaryOperatorKind.Error; } var result = BinaryOperatorKind.Error; // kind.OperatorIndex() collapses '&' and '&&' (and '|' and '||'). To correct // this problem, we handle kinds satisfying IsLogical() separately. Fortunately, // such operators only work on boolean types, so there's no need to write out // a whole new table. // // Example: int & int is legal, but int && int is not, so we can't use the same // table for both operators. if (!kind.IsLogical() || (leftIndex == (int)BinaryOperatorKind.Bool && rightIndex == (int)BinaryOperatorKind.Bool)) { result = opkind[kind.OperatorIndex()][leftIndex.Value, rightIndex.Value]; } return result == BinaryOperatorKind.Error ? result : result | kind; }
internal LoweredDynamicOperation MakeDynamicBinaryOperator( BinaryOperatorKind operatorKind, BoundExpression loweredLeft, BoundExpression loweredRight, bool isCompoundAssignment, TypeSymbol resultType) { Debug.Assert(operatorKind.IsDynamic()); _factory.Syntax = loweredLeft.Syntax; CSharpBinderFlags binderFlags = 0; if (operatorKind.IsChecked()) { binderFlags |= CSharpBinderFlags.CheckedContext; } if (operatorKind.IsLogical()) { binderFlags |= CSharpBinderFlags.BinaryOperationLogical; } var loweredArguments = ImmutableArray.Create<BoundExpression>(loweredLeft, loweredRight); MethodSymbol argumentInfoFactory = GetArgumentInfoFactory(); var binderConstruction = ((object)argumentInfoFactory != null) ? MakeBinderConstruction(WellKnownMember.Microsoft_CSharp_RuntimeBinder_Binder__BinaryOperation, new[] { // flags: _factory.Literal((int)binderFlags), // expression type: _factory.Literal((int)operatorKind.ToExpressionType(isCompoundAssignment)), // context: _factory.TypeofDynamicOperationContextType(), // argument infos: MakeCallSiteArgumentInfos(argumentInfoFactory, loweredArguments) }) : null; return MakeDynamicOperation(binderConstruction, null, RefKind.None, loweredArguments, ImmutableArray<RefKind>.Empty, null, resultType); }
private BoundExpression LowerUserDefinedBinaryOperator( CSharpSyntaxNode syntax, BinaryOperatorKind operatorKind, BoundExpression loweredLeft, BoundExpression loweredRight, TypeSymbol type, MethodSymbol method) { if (operatorKind.IsLogical()) { // Yes, we could have a lifted, logical, user-defined operator: // // struct C { // public static C operator &(C x, C y) {...} // public static bool operator true(C? c) { ... } // public static bool operator false(C? c) { ... } // } // // If we have C? q, r and we say q && r then this gets bound as // C? tempQ = q ; // C.false(tempQ) ? // tempQ : // ( // C? tempR = r ; // tempQ.HasValue & tempR.HasValue ? // new C?(C.&(tempQ.GetValueOrDefault(), tempR.GetValueOrDefault())) : // default C?() // ) // // Note that the native compiler does not allow q && r. However, the native compiler // *does* allow q && r if C is defined as: // // struct C { // public static C? operator &(C? x, C? y) {...} // public static bool operator true(C? c) { ... } // public static bool operator false(C? c) { ... } // } // // It seems unusual and wrong that an & operator should be allowed to become // a && operator if there is a "manually lifted" operator in source, but not // if there is a "synthesized" lifted operator. Roslyn fixes this bug. // // Anyway, in this case we must lower this to its non-logical form, and then // lower the interior of that to its non-lifted form. return LowerUserDefinedLogicalOperator(syntax, operatorKind, loweredLeft, loweredRight, type, method); } else if (operatorKind.IsLifted()) { if (operatorKind.IsComparison()) { return LowerLiftedUserDefinedComparisonOperator(syntax, operatorKind, loweredLeft, loweredRight, method); } else { return LowerLiftedBinaryArithmeticOperator(syntax, operatorKind, loweredLeft, loweredRight, type, method); } } // Otherwise, nothing special here. Debug.Assert((object)method != null); Debug.Assert(method.ReturnType == type); return BoundCall.Synthesized(syntax, null, method, loweredLeft, loweredRight); }
public static bool RequiresNumericTypes(this BinaryOperatorKind op) { return(op.IsArithmetic() || op.IsLogical() || op.IsComparison()); }
internal void GetSimpleBuiltInOperators(BinaryOperatorKind kind, ArrayBuilder <BinaryOperatorSignature> operators) { if (_builtInOperators == null) { var logicalOperators = new ImmutableArray <BinaryOperatorSignature>[] { ImmutableArray <BinaryOperatorSignature> .Empty, //multiplication ImmutableArray <BinaryOperatorSignature> .Empty, //addition ImmutableArray <BinaryOperatorSignature> .Empty, //subtraction ImmutableArray <BinaryOperatorSignature> .Empty, //division ImmutableArray <BinaryOperatorSignature> .Empty, //remainder ImmutableArray <BinaryOperatorSignature> .Empty, //left shift ImmutableArray <BinaryOperatorSignature> .Empty, //right shift ImmutableArray <BinaryOperatorSignature> .Empty, //equal ImmutableArray <BinaryOperatorSignature> .Empty, //not equal ImmutableArray <BinaryOperatorSignature> .Empty, //greater than ImmutableArray <BinaryOperatorSignature> .Empty, //less than ImmutableArray <BinaryOperatorSignature> .Empty, //greater than or equal ImmutableArray <BinaryOperatorSignature> .Empty, //less than or equal ImmutableArray.Create <BinaryOperatorSignature>(GetSignature(BinaryOperatorKind.LogicalBoolAnd)), //and ImmutableArray <BinaryOperatorSignature> .Empty, //xor ImmutableArray.Create <BinaryOperatorSignature>(GetSignature(BinaryOperatorKind.LogicalBoolOr)), //or }; var nonLogicalOperators = new ImmutableArray <BinaryOperatorSignature>[] { GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.Int32Multiplication, (int)BinaryOperatorKind.UInt32Multiplication, (int)BinaryOperatorKind.Int64Multiplication, (int)BinaryOperatorKind.UInt64Multiplication, (int)BinaryOperatorKind.Float32Multiplication, (int)BinaryOperatorKind.Float64Multiplication, (int)BinaryOperatorKind.IntMultiplication, (int)BinaryOperatorKind.UIntMultiplication, (int)BinaryOperatorKind.LiftedInt32Multiplication, (int)BinaryOperatorKind.LiftedUInt32Multiplication, (int)BinaryOperatorKind.LiftedInt64Multiplication, (int)BinaryOperatorKind.LiftedUInt64Multiplication, (int)BinaryOperatorKind.LiftedFloat32Multiplication, (int)BinaryOperatorKind.LiftedFloat64Multiplication, (int)BinaryOperatorKind.LiftedIntMultiplication, (int)BinaryOperatorKind.LiftedUIntMultiplication, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.Int32Addition, (int)BinaryOperatorKind.UInt32Addition, (int)BinaryOperatorKind.Int64Addition, (int)BinaryOperatorKind.UInt64Addition, (int)BinaryOperatorKind.Float32Addition, (int)BinaryOperatorKind.Float64Addition, (int)BinaryOperatorKind.IntAddition, (int)BinaryOperatorKind.UIntAddition, (int)BinaryOperatorKind.LiftedInt32Addition, (int)BinaryOperatorKind.LiftedUInt32Addition, (int)BinaryOperatorKind.LiftedInt64Addition, (int)BinaryOperatorKind.LiftedUInt64Addition, (int)BinaryOperatorKind.LiftedFloat32Addition, (int)BinaryOperatorKind.LiftedFloat64Addition, (int)BinaryOperatorKind.LiftedIntAddition, (int)BinaryOperatorKind.LiftedUIntAddition, (int)BinaryOperatorKind.StringConcatenation, (int)BinaryOperatorKind.StringAndObjectConcatenation, (int)BinaryOperatorKind.ObjectAndStringConcatenation, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.Int32Subtraction, (int)BinaryOperatorKind.UInt32Subtraction, (int)BinaryOperatorKind.Int64Subtraction, (int)BinaryOperatorKind.UInt64Subtraction, (int)BinaryOperatorKind.Float32Subtraction, (int)BinaryOperatorKind.Float64Subtraction, (int)BinaryOperatorKind.IntSubtraction, (int)BinaryOperatorKind.UIntSubtraction, (int)BinaryOperatorKind.Lifted32IntSubtraction, (int)BinaryOperatorKind.LiftedUInt32Subtraction, (int)BinaryOperatorKind.LiftedInt64Subtraction, (int)BinaryOperatorKind.LiftedUInt64Subtraction, (int)BinaryOperatorKind.LiftedFloat32Subtraction, (int)BinaryOperatorKind.LiftedFloat64Subtraction, (int)BinaryOperatorKind.LiftedIntSubtraction, (int)BinaryOperatorKind.LiftedUIntSubtraction, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.Int32Division, (int)BinaryOperatorKind.UInt32Division, (int)BinaryOperatorKind.Int64Division, (int)BinaryOperatorKind.UInt64Division, (int)BinaryOperatorKind.Float32Division, (int)BinaryOperatorKind.Float64Division, (int)BinaryOperatorKind.IntDivision, (int)BinaryOperatorKind.UIntDivision, (int)BinaryOperatorKind.LiftedInt32Division, (int)BinaryOperatorKind.LiftedUInt32Division, (int)BinaryOperatorKind.LiftedInt64Division, (int)BinaryOperatorKind.LiftedUInt64Division, (int)BinaryOperatorKind.LiftedFloat32Division, (int)BinaryOperatorKind.LiftedFloat64Division, (int)BinaryOperatorKind.LiftedIntDivision, (int)BinaryOperatorKind.LiftedUIntDivision, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.Int32Remainder, (int)BinaryOperatorKind.UInt32Remainder, (int)BinaryOperatorKind.Int64Remainder, (int)BinaryOperatorKind.UInt64Remainder, (int)BinaryOperatorKind.Float32Remainder, (int)BinaryOperatorKind.Float64Remainder, (int)BinaryOperatorKind.IntRemainder, (int)BinaryOperatorKind.UIntRemainder, (int)BinaryOperatorKind.LiftedInt32Remainder, (int)BinaryOperatorKind.LiftedUInt32Remainder, (int)BinaryOperatorKind.LiftedInt64Remainder, (int)BinaryOperatorKind.LiftedUInt64Remainder, (int)BinaryOperatorKind.LiftedFloat32Remainder, (int)BinaryOperatorKind.LiftedFloat64Remainder, (int)BinaryOperatorKind.LiftedIntRemainder, (int)BinaryOperatorKind.LiftedUIntRemainder, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.Int32LeftShift, (int)BinaryOperatorKind.UInt32LeftShift, (int)BinaryOperatorKind.Int64LeftShift, (int)BinaryOperatorKind.UInt64LeftShift, (int)BinaryOperatorKind.IntLeftShift, (int)BinaryOperatorKind.UIntLeftShift, (int)BinaryOperatorKind.LiftedInt32LeftShift, (int)BinaryOperatorKind.LiftedUInt32LeftShift, (int)BinaryOperatorKind.LiftedInt64LeftShift, (int)BinaryOperatorKind.LiftedUInt64LeftShift, (int)BinaryOperatorKind.LiftedIntLeftShift, (int)BinaryOperatorKind.LiftedUIntLeftShift, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.Int32RightShift, (int)BinaryOperatorKind.UInt32RightShift, (int)BinaryOperatorKind.Int64RightShift, (int)BinaryOperatorKind.UInt64RightShift, (int)BinaryOperatorKind.IntRightShift, (int)BinaryOperatorKind.UIntRightShift, (int)BinaryOperatorKind.LiftedInt32RightShift, (int)BinaryOperatorKind.LiftedUInt32RightShift, (int)BinaryOperatorKind.LiftedInt64RightShift, (int)BinaryOperatorKind.LiftedUInt64RightShift, (int)BinaryOperatorKind.LiftedIntRightShift, (int)BinaryOperatorKind.LiftedUIntRightShift, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.Int32Equal, (int)BinaryOperatorKind.UInt32Equal, (int)BinaryOperatorKind.Int64Equal, (int)BinaryOperatorKind.UInt64Equal, (int)BinaryOperatorKind.Float32Equal, (int)BinaryOperatorKind.Float64Equal, (int)BinaryOperatorKind.IntEqual, (int)BinaryOperatorKind.UIntEqual, (int)BinaryOperatorKind.BoolEqual, (int)BinaryOperatorKind.LiftedInt32Equal, (int)BinaryOperatorKind.LiftedUInt32Equal, (int)BinaryOperatorKind.LiftedInt64Equal, (int)BinaryOperatorKind.LiftedUInt64Equal, (int)BinaryOperatorKind.LiftedFloat32Equal, (int)BinaryOperatorKind.LiftedFloat64Equal, (int)BinaryOperatorKind.LiftedIntEqual, (int)BinaryOperatorKind.LiftedUIntEqual, (int)BinaryOperatorKind.LiftedBoolEqual, (int)BinaryOperatorKind.ObjectEqual, (int)BinaryOperatorKind.StringEqual, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.Int32NotEqual, (int)BinaryOperatorKind.UInt32NotEqual, (int)BinaryOperatorKind.Int64NotEqual, (int)BinaryOperatorKind.UInt64NotEqual, (int)BinaryOperatorKind.Float32NotEqual, (int)BinaryOperatorKind.Float64NotEqual, (int)BinaryOperatorKind.IntNotEqual, (int)BinaryOperatorKind.UIntNotEqual, (int)BinaryOperatorKind.BoolNotEqual, (int)BinaryOperatorKind.LiftedInt32NotEqual, (int)BinaryOperatorKind.LiftedUInt32NotEqual, (int)BinaryOperatorKind.LiftedInt64NotEqual, (int)BinaryOperatorKind.LiftedUInt64NotEqual, (int)BinaryOperatorKind.LiftedFloat32NotEqual, (int)BinaryOperatorKind.LiftedFloat64NotEqual, (int)BinaryOperatorKind.LiftedIntNotEqual, (int)BinaryOperatorKind.LiftedUIntNotEqual, (int)BinaryOperatorKind.LiftedBoolNotEqual, (int)BinaryOperatorKind.ObjectNotEqual, (int)BinaryOperatorKind.StringNotEqual, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.Int32GreaterThan, (int)BinaryOperatorKind.UInt32GreaterThan, (int)BinaryOperatorKind.Int64GreaterThan, (int)BinaryOperatorKind.UInt64GreaterThan, (int)BinaryOperatorKind.Float32GreaterThan, (int)BinaryOperatorKind.Float64GreaterThan, (int)BinaryOperatorKind.IntGreaterThan, (int)BinaryOperatorKind.UIntGreaterThan, (int)BinaryOperatorKind.Lifted32IntGreaterThan, (int)BinaryOperatorKind.LiftedUInt32GreaterThan, (int)BinaryOperatorKind.LiftedInt64GreaterThan, (int)BinaryOperatorKind.LiftedUInt64GreaterThan, (int)BinaryOperatorKind.LiftedFloat32GreaterThan, (int)BinaryOperatorKind.LiftedFloat64GreaterThan, (int)BinaryOperatorKind.LiftedIntGreaterThan, (int)BinaryOperatorKind.LiftedUIntGreaterThan, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.Int32LessThan, (int)BinaryOperatorKind.UInt32LessThan, (int)BinaryOperatorKind.Int64LessThan, (int)BinaryOperatorKind.UInt64LessThan, (int)BinaryOperatorKind.Float32LessThan, (int)BinaryOperatorKind.Float64LessThan, (int)BinaryOperatorKind.IntLessThan, (int)BinaryOperatorKind.UIntLessThan, (int)BinaryOperatorKind.LiftedInt32LessThan, (int)BinaryOperatorKind.LiftedUInt32LessThan, (int)BinaryOperatorKind.LiftedInt64LessThan, (int)BinaryOperatorKind.LiftedUInt64LessThan, (int)BinaryOperatorKind.LiftedFloat32LessThan, (int)BinaryOperatorKind.LiftedFloat64LessThan, (int)BinaryOperatorKind.LiftedIntLessThan, (int)BinaryOperatorKind.LiftedUIntLessThan, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.Int32GreaterThanOrEqual, (int)BinaryOperatorKind.UInt32GreaterThanOrEqual, (int)BinaryOperatorKind.Int64GreaterThanOrEqual, (int)BinaryOperatorKind.UInt64GreaterThanOrEqual, (int)BinaryOperatorKind.Float32GreaterThanOrEqual, (int)BinaryOperatorKind.Float64GreaterThanOrEqual, (int)BinaryOperatorKind.IntGreaterThanOrEqual, (int)BinaryOperatorKind.UIntGreaterThanOrEqual, (int)BinaryOperatorKind.LiftedInt32GreaterThanOrEqual, (int)BinaryOperatorKind.LiftedUInt32GreaterThanOrEqual, (int)BinaryOperatorKind.LiftedInt64GreaterThanOrEqual, (int)BinaryOperatorKind.LiftedUInt64GreaterThanOrEqual, (int)BinaryOperatorKind.LiftedFloat32GreaterThanOrEqual, (int)BinaryOperatorKind.LiftedFloat64GreaterThanOrEqual, (int)BinaryOperatorKind.LiftedIntGreaterThanOrEqual, (int)BinaryOperatorKind.LiftedUIntGreaterThanOrEqual, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.Int32LessThanOrEqual, (int)BinaryOperatorKind.UInt32LessThanOrEqual, (int)BinaryOperatorKind.Int64LessThanOrEqual, (int)BinaryOperatorKind.UInt64LessThanOrEqual, (int)BinaryOperatorKind.Float32LessThanOrEqual, (int)BinaryOperatorKind.Float64LessThanOrEqual, (int)BinaryOperatorKind.IntLessThanOrEqual, (int)BinaryOperatorKind.UIntLessThanOrEqual, (int)BinaryOperatorKind.LiftedInt32LessThanOrEqual, (int)BinaryOperatorKind.LiftedUInt32LessThanOrEqual, (int)BinaryOperatorKind.LiftedInt64LessThanOrEqual, (int)BinaryOperatorKind.LiftedUInt64LessThanOrEqual, (int)BinaryOperatorKind.LiftedFloat32LessThanOrEqual, (int)BinaryOperatorKind.LiftedFloat64LessThanOrEqual, (int)BinaryOperatorKind.LiftedIntLessThanOrEqual, (int)BinaryOperatorKind.LiftedUIntLessThanOrEqual, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.Int32And, (int)BinaryOperatorKind.UInt32And, (int)BinaryOperatorKind.Int64And, (int)BinaryOperatorKind.UInt64And, (int)BinaryOperatorKind.IntAnd, (int)BinaryOperatorKind.UIntAnd, (int)BinaryOperatorKind.BoolAnd, (int)BinaryOperatorKind.LiftedInt32And, (int)BinaryOperatorKind.LiftedUInt32And, (int)BinaryOperatorKind.LiftedInt64And, (int)BinaryOperatorKind.LiftedUInt64And, (int)BinaryOperatorKind.LiftedIntAnd, (int)BinaryOperatorKind.LiftedUIntAnd, (int)BinaryOperatorKind.LiftedBoolAnd, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.Int32Xor, (int)BinaryOperatorKind.UInt32Xor, (int)BinaryOperatorKind.Int64Xor, (int)BinaryOperatorKind.UInt64Xor, (int)BinaryOperatorKind.IntXor, (int)BinaryOperatorKind.UIntXor, (int)BinaryOperatorKind.BoolXor, (int)BinaryOperatorKind.LiftedInt32Xor, (int)BinaryOperatorKind.LiftedUInt32Xor, (int)BinaryOperatorKind.LiftedInt64Xor, (int)BinaryOperatorKind.LiftedUInt64Xor, (int)BinaryOperatorKind.LiftedIntXor, (int)BinaryOperatorKind.LiftedUIntXor, (int)BinaryOperatorKind.LiftedBoolXor, }), GetSignaturesFromBinaryOperatorKinds(new [] { (int)BinaryOperatorKind.Int32Or, (int)BinaryOperatorKind.UInt32Or, (int)BinaryOperatorKind.Int64Or, (int)BinaryOperatorKind.UInt64Or, (int)BinaryOperatorKind.IntOr, (int)BinaryOperatorKind.UIntOr, (int)BinaryOperatorKind.BoolOr, (int)BinaryOperatorKind.LiftedInt32Or, (int)BinaryOperatorKind.LiftedUInt32Or, (int)BinaryOperatorKind.LiftedInt64Or, (int)BinaryOperatorKind.LiftedUInt64Or, (int)BinaryOperatorKind.LiftedIntOr, (int)BinaryOperatorKind.LiftedUIntOr, (int)BinaryOperatorKind.LiftedBoolOr, }), }; var allOperators = new[] { nonLogicalOperators, logicalOperators }; Interlocked.CompareExchange(ref _builtInOperators, allOperators, null); } operators.AddRange(_builtInOperators[kind.IsLogical() ? 1 : 0][kind.OperatorIndex()]); }