Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Commit

Permalink
Moved unsigned conversion to proper place (#1037)
Browse files Browse the repository at this point in the history
  • Loading branch information
ikiselev committed Feb 25, 2017
1 parent b66f371 commit 8898c06
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions JSIL/ILBlockTranslator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -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) &&
Expand Down

0 comments on commit 8898c06

Please sign in to comment.