internal Expression ReduceUserdefinedLifted()
{
Debug.Assert(IsLiftedLogical);
ParameterExpression left = Parameter(Left.Type, "left");
ParameterExpression right = Parameter(Right.Type, "right");
string opName = NodeType == ExpressionType.AndAlso ? "op_False" : "op_True";
MethodInfo opTrueFalse = TypeUtils.GetBooleanOperator(Method.DeclaringType, opName);
Debug.Assert(opTrueFalse != null);
return Block(
new TrueReadOnlyCollection<ParameterExpression>(left),
new TrueReadOnlyCollection<Expression>(
Assign(left, Left),
Condition(
Property(left, "HasValue"),
Condition(
Call(opTrueFalse, Call(left, "GetValueOrDefault", null)),
left,
Block(
new TrueReadOnlyCollection<ParameterExpression>(right),
new TrueReadOnlyCollection<Expression>(
Assign(right, Right),
Condition(
Property(right, "HasValue"),
Convert(
Call(
Method,
Call(left, "GetValueOrDefault", null),
Call(right, "GetValueOrDefault", null)
),
Type
),
Constant(null, Type)
)
)
)
),
Constant(null, Type)
)
)
);
}
}