protected override ILConstruct EmitLessThanExpression(TContext context, ILConstruct left, ILConstruct right) { #if DEBUG Contract.Assert(left.ContextType.IsPrimitive && left.ContextType != typeof(string)); #endif var lessThan = left.ContextType.GetMethod("op_LessThan"); return (ILConstruct.BinaryOperator( "<", typeof(bool), left, right, (il, l, r) => { l.LoadValue(il, false); r.LoadValue(il, false); if (lessThan == null) { il.EmitClt(); } else { il.EmitAnyCall(lessThan); } }, (il, l, r, @else) => { l.LoadValue(il, false); r.LoadValue(il, false); if (lessThan == null) { il.EmitClt(); } else { il.EmitAnyCall(lessThan); } il.EmitBrfalse(@else); } )); }
protected override ILConstruct EmitEqualsExpression(TContext context, ILConstruct left, ILConstruct right) { var equality = left.ContextType.GetMethod("op_Equality"); return (ILConstruct.BinaryOperator( "==", typeof(bool), left, right, (il, l, r) => { l.LoadValue(il, false); r.LoadValue(il, false); if (equality == null) { il.EmitCeq(); } else { il.EmitAnyCall(equality); } }, (il, l, r, @else) => { l.LoadValue(il, false); r.LoadValue(il, false); if (equality == null) { il.EmitCeq(); } else { il.EmitAnyCall(equality); } il.EmitBrfalse(@else); } )); }