Microsoft\Scripting\Ast\BinaryExpression.cs (106)
316if (TypeUtils.IsNullableType(_left.Type)) {
319!TypeUtils.AreEquivalent(method.GetParametersCached()[0].ParameterType.GetNonRefType(), _left.Type);
329return IsLifted && TypeUtils.IsNullableType(Type);
342Debug.Assert(method == null && TypeUtils.AreEquivalent(type, left.Type));
346Debug.Assert(method == null && TypeUtils.AreEquivalent(type, right.Type) && nodeType == ExpressionType.Coalesce);
367TypeUtils.AreEquivalent(right, left) &&
368TypeUtils.IsNullableType(left) &&
370TypeUtils.AreEquivalent(method.ReturnType, TypeUtils.GetNonNullableType(left));
421MethodInfo opTrueFalse = TypeUtils.GetBooleanOperator(Method.DeclaringType, opName);
580TypeUtils.ValidateType(left.Type);
581TypeUtils.ValidateType(right.Type);
582if (!TypeUtils.AreReferenceAssignable(left.Type, right.Type)) {
598if (TypeUtils.IsNullableType(left.Type) && TypeUtils.IsNullableType(right.Type)) {
599Type nnLeftType = TypeUtils.GetNonNullableType(left.Type);
600Type nnRightType = TypeUtils.GetNonNullableType(right.Type);
602if (method != null && method.ReturnType.IsValueType && !TypeUtils.IsNullableType(method.ReturnType)) {
604return new MethodBinaryExpression(binaryType, left, right, TypeUtils.GetNullableType(method.ReturnType), method);
627if (TypeUtils.IsNullableType(left.Type) && TypeUtils.IsNullableType(right.Type) &&
628ParameterIsAssignable(pms[0], TypeUtils.GetNonNullableType(left.Type)) &&
629ParameterIsAssignable(pms[1], TypeUtils.GetNonNullableType(right.Type)) &&
630method.ReturnType.IsValueType && !TypeUtils.IsNullableType(method.ReturnType)) {
632return new MethodBinaryExpression(binaryType, left, right, TypeUtils.GetNullableType(method.ReturnType), method);
644if (!TypeUtils.AreReferenceAssignable(left.Type, b.Type)) {
671if (!TypeUtils.AreReferenceAssignable(left.Type, b.Type)) {
687Type nnLeftType = TypeUtils.GetNonNullableType(leftType);
688Type nnRightType = TypeUtils.GetNonNullableType(rightType);
691if (method == null && !TypeUtils.AreEquivalent(leftType, rightType)) {
703return TypeUtils.IsNullableType(right) &&
704TypeUtils.IsNullableType(left) &&
714return TypeUtils.AreReferenceAssignable(pType, argType);
719if (TypeUtils.IsNullableType(paramType) && !TypeUtils.IsNullableType(operandType)) {
748if (IsNullConstant(left) && !IsNullConstant(right) && TypeUtils.IsNullableType(right.Type)) {
751if (IsNullConstant(right) && !IsNullConstant(left) && TypeUtils.IsNullableType(left.Type)) {
775if (!(TypeUtils.IsNullableType(left) && ParameterIsAssignable(pms[0], TypeUtils.GetNonNullableType(left))))
779if (!(TypeUtils.IsNullableType(right) && ParameterIsAssignable(pms[1], TypeUtils.GetNonNullableType(right))))
789left = TypeUtils.GetNonNullableType(left);
790right = TypeUtils.GetNonNullableType(left);
792MethodInfo opTrue = TypeUtils.GetBooleanOperator(method.DeclaringType, "op_True");
793MethodInfo opFalse = TypeUtils.GetBooleanOperator(method.DeclaringType, "op_False");
808if (!(TypeUtils.IsNullableType(left) && ParameterIsAssignable(pmsOpTrue[0], TypeUtils.GetNonNullableType(left))))
814return TypeUtils.AreEquivalent(left, right) &&
815TypeUtils.IsNullableType(right) &&
816TypeUtils.AreEquivalent(pms[1].ParameterType, TypeUtils.GetNonNullableType(right));
985if (TypeUtils.HasReferenceEquality(left.Type, right.Type)) {
1032if (TypeUtils.HasReferenceEquality(left.Type, right.Type)) {
1040if (left.Type == right.Type && (TypeUtils.IsNumeric(left.Type) ||
1042TypeUtils.IsBool(left.Type) ||
1043TypeUtils.GetNonNullableType(left.Type).IsEnum)) {
1044if (TypeUtils.IsNullableType(left.Type) && liftToNull) {
1055if (TypeUtils.HasBuiltInEqualityOperator(left.Type, right.Type) || IsNullComparison(left, right)) {
1056if (TypeUtils.IsNullableType(left.Type) && liftToNull) {
1195if (left.Type == right.Type && TypeUtils.IsNumeric(left.Type)) {
1196if (TypeUtils.IsNullableType(left.Type) && liftToNull) {
1245returnType = (TypeUtils.IsNullableType(left.Type) && TypeUtils.AreEquivalent(method.ReturnType, TypeUtils.GetNonNullableType(left.Type))) ? left.Type : method.ReturnType;
1251returnType = (TypeUtils.IsNullableType(left.Type) && TypeUtils.AreEquivalent(method.ReturnType, TypeUtils.GetNonNullableType(left.Type))) ? left.Type : method.ReturnType;
1291returnType = (TypeUtils.IsNullableType(left.Type) && method.ReturnType == TypeUtils.GetNonNullableType(left.Type)) ? left.Type : method.ReturnType;
1297returnType = (TypeUtils.IsNullableType(left.Type) && method.ReturnType == TypeUtils.GetNonNullableType(left.Type)) ? left.Type : method.ReturnType;
1334if (left.Type.IsValueType && !TypeUtils.IsNullableType(left.Type)) {
1353if (!TypeUtils.AreEquivalent(method.ReturnType, right.Type)) {
1358if (!ParameterIsAssignable(pms[0], TypeUtils.GetNonNullableType(left.Type)) &&
1367Type leftStripped = TypeUtils.GetNonNullableType(left);
1368if (left.IsValueType && !TypeUtils.IsNullableType(left)) {
1370} else if (TypeUtils.IsNullableType(left) && TypeUtils.IsImplicitlyConvertible(right, leftStripped)) {
1372} else if (TypeUtils.IsImplicitlyConvertible(right, left)) {
1374} else if (TypeUtils.IsImplicitlyConvertible(leftStripped, right)) {
1412if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type)) {
1462if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type)) {
1483if (!TypeUtils.AreEquivalent(mi.ReturnType, left.Type)) {
1488if (!TypeUtils.AreEquivalent(pms[0].ParameterType, method.ReturnType)) {
1538if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type)) {
1575if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type)) {
1608if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type)) {
1657if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type)) {
1710if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type)) {
1747if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type)) {
1780if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type)) {
1829if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type)) {
1866if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type)) {
1915if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type)) {
1952if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type)) {
2001if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type)) {
2054if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type)) {
2091if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type)) {
2100return TypeUtils.IsInteger(left)
2101&& TypeUtils.GetNonNullableType(right) == typeof(int);
2313if (left.Type == right.Type && TypeUtils.IsIntegerOrBool(left.Type)) {
2362if (left.Type == right.Type && TypeUtils.IsIntegerOrBool(left.Type)) {
2399if (left.Type == right.Type && TypeUtils.IsIntegerOrBool(left.Type)) {
2448if (left.Type == right.Type && TypeUtils.IsIntegerOrBool(left.Type)) {
2484if (left.Type == right.Type && TypeUtils.IsIntegerOrBool(left.Type)) {
2532if (left.Type == right.Type && TypeUtils.IsIntegerOrBool(left.Type)) {
Microsoft\Scripting\Ast\UnaryExpression.cs (43)
92bool operandIsNullable = TypeUtils.IsNullableType(_operand.Type);
93bool resultIsNullable = TypeUtils.IsNullableType(this.Type);
95return (operandIsNullable && !TypeUtils.AreEquivalent(_method.GetParametersCached()[0].ParameterType, _operand.Type)) ||
96(resultIsNullable && !TypeUtils.AreEquivalent(_method.ReturnType, this.Type));
108return IsLifted && TypeUtils.IsNullableType(this.Type);
376Type nnOperandType = TypeUtils.GetNonNullableType(operandType);
383if (TypeUtils.IsNullableType(operandType)) {
386if (method != null && method.ReturnType.IsValueType && !TypeUtils.IsNullableType(method.ReturnType)) {
387return new UnaryExpression(unaryType, operand, TypeUtils.GetNullableType(method.ReturnType), method);
404if (TypeUtils.IsNullableType(operand.Type) &&
405ParameterIsAssignable(pms[0], TypeUtils.GetNonNullableType(operand.Type)) &&
406method.ReturnType.IsValueType && !TypeUtils.IsNullableType(method.ReturnType)) {
407return new UnaryExpression(unaryType, operand, TypeUtils.GetNullableType(method.ReturnType), method);
422MethodInfo method = TypeUtils.GetUserDefinedCoercionMethod(expression.Type, convertToType, false);
437if (ParameterIsAssignable(pms[0], operand.Type) && TypeUtils.AreEquivalent(method.ReturnType, convertToType)) {
441if ((TypeUtils.IsNullableType(operand.Type) || TypeUtils.IsNullableType(convertToType)) &&
442ParameterIsAssignable(pms[0], TypeUtils.GetNonNullableType(operand.Type)) &&
443TypeUtils.AreEquivalent(method.ReturnType, TypeUtils.GetNonNullableType(convertToType))) {
472if (TypeUtils.IsArithmetic(expression.Type) && !TypeUtils.IsUnsignedInt(expression.Type)) {
503if (TypeUtils.IsArithmetic(expression.Type)) {
534if (TypeUtils.IsArithmetic(expression.Type) && !TypeUtils.IsUnsignedInt(expression.Type)) {
565if (TypeUtils.IsIntegerOrBool(expression.Type)) {
595if (TypeUtils.IsBool(expression.Type)) {
621if (TypeUtils.IsBool(expression.Type)) {
647if (TypeUtils.IsInteger(expression.Type)) {
664TypeUtils.ValidateType(type);
666if (type.IsValueType && !TypeUtils.IsNullableType(type)) {
685TypeUtils.ValidateType(type);
714TypeUtils.ValidateType(type);
717if (TypeUtils.HasIdentityPrimitiveOrNullableConversion(expression.Type, type) ||
718TypeUtils.HasReferenceConversion(expression.Type, type)) {
751TypeUtils.ValidateType(type);
754if (TypeUtils.HasIdentityPrimitiveOrNullableConversion(expression.Type, type)) {
757if (TypeUtils.HasReferenceConversion(expression.Type, type)) {
832TypeUtils.ValidateType(type);
859if (TypeUtils.IsArithmetic(expression.Type)) {
885if (TypeUtils.IsArithmetic(expression.Type)) {
984if (TypeUtils.IsArithmetic(expression.Type)) {
998if (!TypeUtils.AreReferenceAssignable(expression.Type, result.Type)) {
Microsoft\Scripting\Compiler\LambdaCompiler.Binary.cs (39)
58if (ConstantCheck.IsNull(b.Left) && !ConstantCheck.IsNull(b.Right) && TypeUtils.IsNullableType(b.Right.Type)) {
62if (ConstantCheck.IsNull(b.Right) && !ConstantCheck.IsNull(b.Left) && TypeUtils.IsNullableType(b.Left.Type)) {
82Debug.Assert(TypeUtils.IsNullableType(e.Type));
102ParameterExpression p1 = Expression.Variable(TypeUtils.GetNonNullableType(b.Left.Type), null);
103ParameterExpression p2 = Expression.Variable(TypeUtils.GetNonNullableType(b.Right.Type), null);
107resultType = TypeUtils.GetNullableType(mc.Type);
122resultType = TypeUtils.GetNullableType(mc.Type);
137bool leftIsNullable = TypeUtils.IsNullableType(leftType);
138bool rightIsNullable = TypeUtils.IsNullableType(rightType);
162Debug.Assert(!TypeUtils.IsNullableType(leftType));
163Debug.Assert(!TypeUtils.IsNullableType(rightType));
177if (TypeUtils.IsFloatingPoint(leftType)) {
179} else if (TypeUtils.IsUnsigned(leftType)) {
189if (TypeUtils.IsFloatingPoint(leftType)) {
191} else if (TypeUtils.IsUnsigned(leftType)) {
201if (TypeUtils.IsFloatingPoint(leftType)) {
203} else if (TypeUtils.IsUnsigned(leftType)) {
210if (TypeUtils.IsUnsigned(leftType)) {
217if (TypeUtils.IsUnsigned(leftType)) {
232if (TypeUtils.IsUnsigned(leftType)) {
241if (TypeUtils.IsUnsigned(leftType)) {
254if (TypeUtils.IsUnsigned(leftType)) {
263if (TypeUtils.IsUnsigned(leftType)) {
288if (TypeUtils.IsUnsigned(leftType)) {
337Debug.Assert(TypeUtils.IsNullableType(leftType) || TypeUtils.IsNullableType(rightType));
383Debug.Assert(TypeUtils.IsNullableType(leftType));
466TypeUtils.GetNonNullableType(leftType),
467TypeUtils.GetNonNullableType(rightType),
468TypeUtils.GetNonNullableType(resultType),
476if (!TypeUtils.AreEquivalent(resultType, TypeUtils.GetNonNullableType(resultType))) {
477_ilg.EmitConvertToType(TypeUtils.GetNonNullableType(resultType), resultType, true);
493bool leftIsNullable = TypeUtils.IsNullableType(leftType);
494bool rightIsNullable = TypeUtils.IsNullableType(rightType);
540EmitBinaryOperator(op, TypeUtils.GetNonNullableType(leftType), TypeUtils.GetNonNullableType(rightType), TypeUtils.GetNonNullableType(resultType), false);
543ConstructorInfo ci = resultType.GetConstructor(new Type[] { TypeUtils.GetNonNullableType(resultType) });