1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Fixed operator precedence issues

This commit is contained in:
Brian Fiete 2020-10-07 07:47:08 -07:00
parent d0c9145655
commit 2ac478509e
7 changed files with 16 additions and 10 deletions

View file

@ -77,7 +77,7 @@ namespace Beefy.gfx
(((((color1 & 0x000000FF) * oma) + ((color2 & 0x000000FF) * a)) >> 8) & 0x000000FF) |
(((((color1 & 0x0000FF00) * oma) + ((color2 & 0x0000FF00) * a)) >> 8) & 0x0000FF00) |
(((((color1 & 0x00FF0000) * oma) + ((color2 & 0x00FF0000) * a)) >> 8) & 0x00FF0000) |
(((((color1 >> 24) & 0xFF) * oma) + (((color2 >> 24) & 0xFF) * a) & 0x0000FF00) << 16);
((((((color1 >> 24) & 0xFF) * oma) + (((color2 >> 24) & 0xFF) * a)) & 0x0000FF00) << 16);
return aColor;
}

View file

@ -897,7 +897,7 @@ namespace Beefy.gfx
{
// This strange-looking construct is so that odd-length lines and even-length lines do not 'jitter'
// relative to each other as we're resizing a window
useX += ((int)(width)&~1 - (int)aWidth) / 2;
useX += (((int)(width)&~1) - (int)aWidth) / 2;
}
else if (justification == 1)
useX += width - aWidth;

View file

@ -284,7 +284,10 @@ namespace System
int32[] days = leapYear ? DaysToMonth366 : DaysToMonth365;
// All months have less than 32 days, so n >> 5 is a good conservative
// estimate for the month
int32 m = n >> 5 + 1;
//BCF- Note, the original read `int32 m = n >> 5 + 1;`, which may have been a bug. Preserving original precedence.
int32 m = n >> (5 + 1);
// m = 1-based month number
while (n >= days[m]) m++;
// If month was requested, return it

View file

@ -220,7 +220,8 @@ namespace System.Globalization {
int[] days = leapYear? DaysToMonth366: DaysToMonth365;
// All months have less than 32 days, so n >> 5 is a good conservative
// estimate for the month
int m = n >> 5 + 1;
//BCF- Note, the original read `int32 m = n >> 5 + 1;`, which may have been a bug. Preserving original precedence.
int m = n >> (5 + 1);
// m = 1-based month number
while (n >= days[m]) m++;
// If month was requested, return it

View file

@ -372,7 +372,7 @@ namespace System.Reflection
}
else if (mMethodData.mVirtualIdx >= 0x100000)
{
void* extAddr = (void*)*((int*)classVData + (mMethodData.mVirtualIdx>>20 - 1));
void* extAddr = (void*)*((int*)classVData + ((mMethodData.mVirtualIdx>>20) - 1));
funcPtr = (void*)*((int*)extAddr + (mMethodData.mVirtualIdx & 0xFFFFF));
}
else
@ -706,7 +706,7 @@ namespace System.Reflection
}
else if (mMethodData.mVirtualIdx >= 0x100000)
{
void* extAddr = (void*)*((int*)classVData + (mMethodData.mVirtualIdx>>20 - 1));
void* extAddr = (void*)*((int*)classVData + ((mMethodData.mVirtualIdx>>20) - 1));
funcPtr = (void*)*((int*)extAddr + (mMethodData.mVirtualIdx & 0xFFFFF) + virtualOffset);
}
else

View file

@ -29,7 +29,7 @@ namespace System.Text
else if ((c >= '\u{DC00}') && (c < '\u{E000}'))
{
char16 utf16lo = c;
c32 = (char32)(0x10000 + ((uint32)(utf16hi - 0xD800) << 10) | (uint32)(utf16lo - 0xDC00));
c32 = (char32)(0x10000 | ((uint32)(utf16hi - 0xD800) << 10) | (uint32)(utf16lo - 0xDC00));
}
outStr.Append(c32);
@ -56,7 +56,7 @@ namespace System.Text
else if ((c >= '\u{DC00}') && (c < '\u{E000}'))
{
char16 utf16lo = c;
c32 = (char32)(0x10000 + ((uint32)(utf16hi - 0xD800) << 10) | (uint32)(utf16lo - 0xDC00));
c32 = (char32)(0x10000 | ((uint32)(utf16hi - 0xD800) << 10) | (uint32)(utf16lo - 0xDC00));
}
outStr.Append(c32);
@ -83,7 +83,7 @@ namespace System.Text
#endif
return ((char32)c, 1);
}
char32 c32 = (char32)(0x10000 + ((uint32)(c - 0xD800) << 10) | (uint32)(utf16lo - 0xDC00));
char32 c32 = (char32)(0x10000 | ((uint32)(c - 0xD800) << 10) | (uint32)(utf16lo - 0xDC00));
return (c32, 2);
}
#if BF_UTF_PEDANTIC

View file

@ -20512,7 +20512,9 @@ void BfExprEvaluator::Visit(BfBinaryOperatorExpression* binOpExpr)
}
}
if ((binOpExpr->mOp == BfBinaryOp_LeftShift) || (binOpExpr->mOp == BfBinaryOp_RightShift))
if ((binOpExpr->mOp == BfBinaryOp_LeftShift) || (binOpExpr->mOp == BfBinaryOp_RightShift) ||
(binOpExpr->mOp == BfBinaryOp_BitwiseAnd) || (binOpExpr->mOp == BfBinaryOp_BitwiseOr) ||
(binOpExpr->mOp == BfBinaryOp_ExclusiveOr))
{
for (int side = 0; side < 2; side++)
{