diff --git a/JSIL/ILBlockTranslator.cs b/JSIL/ILBlockTranslator.cs index 2da7af1b9..2d34a98dd 100644 --- a/JSIL/ILBlockTranslator.cs +++ b/JSIL/ILBlockTranslator.cs @@ -547,23 +547,6 @@ protected JSExpression Translate_BinaryOp (ILExpression node, JSBinaryOperator o AutoCastingState.Pop(); } - if (node.Code.GetName().Contains(".un")) - { - var lType = lhs.GetActualType(TypeSystem); - var lUnsigned = TypeUtil.GetUnsignedType(lType, TypeSystem); - if (lType != lUnsigned) - { - lhs = JSCastExpression.New(lhs, lUnsigned, TypeSystem, isCoercion: true); - } - - var rType = rhs.GetActualType(TypeSystem); - var rUnsigned = TypeUtil.GetUnsignedType(rType, TypeSystem); - if (lType != rUnsigned) - { - rhs = JSCastExpression.New(rhs, rUnsigned, TypeSystem, isCoercion: true); - } - } - if (TypeUtil.IsPointer(lhs.GetActualType(TypeSystem))) arePointersInvolved |= true; else if (TypeUtil.IsPointer(rhs.GetActualType(TypeSystem))) @@ -583,6 +566,22 @@ protected JSExpression Translate_BinaryOp (ILExpression node, JSBinaryOperator o var leftType = lhs.GetActualType(TypeSystem); var rightType = rhs.GetActualType(TypeSystem); + if (node.Code.GetName().Contains(".un")) + { + // We need emulate unsigned comaprison + var leftTypeUnsigned = TypeUtil.GetUnsignedType(leftType, TypeSystem); + if (leftType != leftTypeUnsigned) + { + lhs = JSCastExpression.New(lhs, leftTypeUnsigned, TypeSystem, isCoercion: true); + } + + var rightTypeUnsigned = TypeUtil.GetUnsignedType(rightType, TypeSystem); + if (rightType != rightTypeUnsigned) + { + rhs = JSCastExpression.New(rhs, rightTypeUnsigned, TypeSystem, isCoercion: true); + } + } + if ( TypeUtil.IsIntegral(leftType) && TypeUtil.IsIntegral(rightType) &&