diff --git a/BeefLibs/corlib/src/DateTimeOffset.bf b/BeefLibs/corlib/src/DateTimeOffset.bf index c3b75d67..4e2617d0 100644 --- a/BeefLibs/corlib/src/DateTimeOffset.bf +++ b/BeefLibs/corlib/src/DateTimeOffset.bf @@ -461,7 +461,7 @@ namespace System { // not equal. // 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 diff --git a/IDE/mintest/minlib/src/System/String.bf b/IDE/mintest/minlib/src/System/String.bf index 3c58a79f..5385f451 100644 --- a/IDE/mintest/minlib/src/System/String.bf +++ b/IDE/mintest/minlib/src/System/String.bf @@ -26,6 +26,7 @@ namespace System char8* mPtr = null; extern const String* sStringLiterals; + public const String Empty = ""; #if BF_LARGE_STRINGS const uint64 SizeFlags = 0x3FFFFFFF'FFFFFFFF; @@ -426,6 +427,16 @@ namespace System 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) { //Contract.Ensures(Contract.Result() != null); diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index 81dc19a7..64b6d77a 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -12092,9 +12092,7 @@ BfTypedValue BfModule::GetThis() return BfTypedValue(); } - - bool preferValue = !IsTargetingBeefBackend(); - + 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 @@ -12104,9 +12102,18 @@ BfTypedValue BfModule::GetThis() auto thisLocal = useMethodState->mLocals[0]; BF_ASSERT(thisLocal->mIsThis); + + bool preferValue = !IsTargetingBeefBackend(); + if (!thisLocal->mAddr) + preferValue = true; + + bool usedVal = false; BfIRValue thisValue; - if ((preferValue) || (!thisLocal->mAddr) /*|| (thisLocal->mIsSplat)*/) + if ((preferValue) && (!thisLocal->mIsLowered)) + { thisValue = thisLocal->mValue; + usedVal = true; + } else if ((thisLocal->mIsSplat) || (thisLocal->mIsLowered)) thisValue = thisLocal->mAddr; else diff --git a/IDEHelper/Tests/src/Structs.bf b/IDEHelper/Tests/src/Structs.bf index 3267aa51..01669590 100644 --- a/IDEHelper/Tests/src/Structs.bf +++ b/IDEHelper/Tests/src/Structs.bf @@ -31,9 +31,25 @@ namespace Tests struct StructC { - int8 mA; - int32 mB; - int8 mC; + public int8 mA; + public int32 mB; + public int8 mC; + + public int A + { + get mut + { + return mA; + } + } + + public int B + { + get + { + return mB; + } + } } [Ordered] @@ -52,6 +68,28 @@ namespace Tests 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 { int8 mD; @@ -134,5 +172,24 @@ namespace Tests Span span = sv; 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); + } } }