mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 20:12:21 +02:00
Fixed int-lowered structs with immutable methods in LLVM
This commit is contained in:
parent
7a08e7bf11
commit
5276bd4533
4 changed files with 83 additions and 8 deletions
|
@ -461,7 +461,7 @@ namespace System {
|
||||||
// not equal.
|
// not equal.
|
||||||
//
|
//
|
||||||
public static bool Equals(DateTimeOffset first, DateTimeOffset second) {
|
public static bool Equals(DateTimeOffset first, DateTimeOffset second) {
|
||||||
return DateTime.Equals(first.UtcDateTime, second.UtcDateTime);
|
return first.UtcDateTime == second.UtcDateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a DateTimeOffset from a Windows filetime. A Windows filetime is
|
// Creates a DateTimeOffset from a Windows filetime. A Windows filetime is
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace System
|
||||||
char8* mPtr = null;
|
char8* mPtr = null;
|
||||||
|
|
||||||
extern const String* sStringLiterals;
|
extern const String* sStringLiterals;
|
||||||
|
public const String Empty = "";
|
||||||
|
|
||||||
#if BF_LARGE_STRINGS
|
#if BF_LARGE_STRINGS
|
||||||
const uint64 SizeFlags = 0x3FFFFFFF'FFFFFFFF;
|
const uint64 SizeFlags = 0x3FFFFFFF'FFFFFFFF;
|
||||||
|
@ -426,6 +427,16 @@ namespace System
|
||||||
ptr[mLength] = 0;
|
ptr[mLength] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Append(char8[] arr, int idx, int length)
|
||||||
|
{
|
||||||
|
Append(&arr.getRef(idx), length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Append(StringView arr, int idx, int length)
|
||||||
|
{
|
||||||
|
Append(arr.Ptr + idx, length);
|
||||||
|
}
|
||||||
|
|
||||||
public void Append(StringView value)
|
public void Append(StringView value)
|
||||||
{
|
{
|
||||||
//Contract.Ensures(Contract.Result<String>() != null);
|
//Contract.Ensures(Contract.Result<String>() != null);
|
||||||
|
|
|
@ -12092,9 +12092,7 @@ BfTypedValue BfModule::GetThis()
|
||||||
|
|
||||||
return BfTypedValue();
|
return BfTypedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool preferValue = !IsTargetingBeefBackend();
|
|
||||||
|
|
||||||
if (useMethodState->mLocals.IsEmpty())
|
if (useMethodState->mLocals.IsEmpty())
|
||||||
{
|
{
|
||||||
// This can happen in rare non-capture cases, such as when we need to do a const expression resolve for a sized-array return type on a local method
|
// This can happen in rare non-capture cases, such as when we need to do a const expression resolve for a sized-array return type on a local method
|
||||||
|
@ -12104,9 +12102,18 @@ BfTypedValue BfModule::GetThis()
|
||||||
|
|
||||||
auto thisLocal = useMethodState->mLocals[0];
|
auto thisLocal = useMethodState->mLocals[0];
|
||||||
BF_ASSERT(thisLocal->mIsThis);
|
BF_ASSERT(thisLocal->mIsThis);
|
||||||
|
|
||||||
|
bool preferValue = !IsTargetingBeefBackend();
|
||||||
|
if (!thisLocal->mAddr)
|
||||||
|
preferValue = true;
|
||||||
|
|
||||||
|
bool usedVal = false;
|
||||||
BfIRValue thisValue;
|
BfIRValue thisValue;
|
||||||
if ((preferValue) || (!thisLocal->mAddr) /*|| (thisLocal->mIsSplat)*/)
|
if ((preferValue) && (!thisLocal->mIsLowered))
|
||||||
|
{
|
||||||
thisValue = thisLocal->mValue;
|
thisValue = thisLocal->mValue;
|
||||||
|
usedVal = true;
|
||||||
|
}
|
||||||
else if ((thisLocal->mIsSplat) || (thisLocal->mIsLowered))
|
else if ((thisLocal->mIsSplat) || (thisLocal->mIsLowered))
|
||||||
thisValue = thisLocal->mAddr;
|
thisValue = thisLocal->mAddr;
|
||||||
else
|
else
|
||||||
|
|
|
@ -31,9 +31,25 @@ namespace Tests
|
||||||
|
|
||||||
struct StructC
|
struct StructC
|
||||||
{
|
{
|
||||||
int8 mA;
|
public int8 mA;
|
||||||
int32 mB;
|
public int32 mB;
|
||||||
int8 mC;
|
public int8 mC;
|
||||||
|
|
||||||
|
public int A
|
||||||
|
{
|
||||||
|
get mut
|
||||||
|
{
|
||||||
|
return mA;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int B
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mB;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Ordered]
|
[Ordered]
|
||||||
|
@ -52,6 +68,28 @@ namespace Tests
|
||||||
int8 mC;
|
int8 mC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[CRepr]
|
||||||
|
struct Color
|
||||||
|
{
|
||||||
|
public uint8 mR, mG, mB, mA;
|
||||||
|
|
||||||
|
public uint8 R
|
||||||
|
{
|
||||||
|
get mut
|
||||||
|
{
|
||||||
|
return mR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint8 G
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct StructF : StructC
|
struct StructF : StructC
|
||||||
{
|
{
|
||||||
int8 mD;
|
int8 mD;
|
||||||
|
@ -134,5 +172,24 @@ namespace Tests
|
||||||
Span<char8> span = sv;
|
Span<char8> span = sv;
|
||||||
Test.Assert(Test(sv) == 22);
|
Test.Assert(Test(sv) == 22);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
static void TestProperties()
|
||||||
|
{
|
||||||
|
StructC sc = .();
|
||||||
|
sc.mA = 11;
|
||||||
|
sc.mB = 22;
|
||||||
|
sc.mC = 33;
|
||||||
|
Test.Assert(sc.A == 11);
|
||||||
|
Test.Assert(sc.B == 22);
|
||||||
|
|
||||||
|
Color clr;
|
||||||
|
clr.mR = 10;
|
||||||
|
clr.mG = 20;
|
||||||
|
clr.mB = 30;
|
||||||
|
clr.mA = 40;
|
||||||
|
Test.Assert(clr.R == 10);
|
||||||
|
Test.Assert(clr.G == 20);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue