in src/Compilers/CSharp/Portable/Compilation/BuiltInOperators.cs [275:568]
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()]);
}