mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-12 21:34:11 +02:00
Defer fix for typed primitive/valueless target
This commit is contained in:
parent
7206038cc5
commit
b9647d2a08
2 changed files with 30 additions and 4 deletions
|
@ -399,10 +399,10 @@ bool BfModule::AddDeferredCallEntry(BfDeferredCallEntry* deferredCallEntry, BfSc
|
||||||
|
|
||||||
int dataIdx = 2;
|
int dataIdx = 2;
|
||||||
int argIdx = 0;
|
int argIdx = 0;
|
||||||
if (!methodDef->mIsStatic)
|
if ((!methodDef->mIsStatic) && (!owningType->IsValuelessType()))
|
||||||
{
|
{
|
||||||
gepInstance = mBfIRBuilder->CreateInBoundsGEP(deferredAlloca, 0, 2);
|
gepInstance = mBfIRBuilder->CreateInBoundsGEP(deferredAlloca, 0, 2);
|
||||||
if (owningType->IsStruct())
|
if (owningType->IsValueType())
|
||||||
{
|
{
|
||||||
if ((!methodDef->mIsMutating) && (owningType->IsSplattable()))
|
if ((!methodDef->mIsMutating) && (owningType->IsSplattable()))
|
||||||
{
|
{
|
||||||
|
@ -1172,7 +1172,7 @@ void BfModule::EmitDeferredCallProcessor(BfScopeData* scopeData, SLIList<BfDefer
|
||||||
if ((argIdx == 0) && (!methodDef->mIsStatic))
|
if ((argIdx == 0) && (!methodDef->mIsStatic))
|
||||||
{
|
{
|
||||||
// 'this'
|
// 'this'
|
||||||
isStruct = methodOwner->IsStruct();
|
isStruct = methodOwner->IsValueType();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Tests
|
namespace Tests
|
||||||
{
|
{
|
||||||
|
@ -43,6 +44,23 @@ namespace Tests
|
||||||
str.Contains('T');
|
str.Contains('T');
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
static int sVal = 123;
|
||||||
|
|
||||||
|
struct DisposableInstance : int32
|
||||||
|
{
|
||||||
|
public void Dispose() mut
|
||||||
|
{
|
||||||
|
sVal++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DisposableInstance sDisposableInstance = (.)123;
|
||||||
|
|
||||||
|
static Result<DisposableInstance> GetDisposable(StringView profileDesc = default, int sampleRate = -1)
|
||||||
|
{
|
||||||
|
return DisposableInstance();
|
||||||
|
}
|
||||||
|
|
||||||
public static void Defer0(ref int val)
|
public static void Defer0(ref int val)
|
||||||
{
|
{
|
||||||
for (int i < 10)
|
for (int i < 10)
|
||||||
|
@ -53,7 +71,14 @@ namespace Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == 2)
|
if (i == 2)
|
||||||
|
{
|
||||||
|
if (GetDisposable() case .Ok(var sampInst))
|
||||||
|
{
|
||||||
|
defer:: sampInst.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
defer::
|
defer::
|
||||||
{
|
{
|
||||||
|
@ -68,6 +93,7 @@ namespace Tests
|
||||||
int a = 0;
|
int a = 0;
|
||||||
Defer0(ref a);
|
Defer0(ref a);
|
||||||
Test.Assert(a == 302);
|
Test.Assert(a == 302);
|
||||||
|
Test.Assert(sVal == 124);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static mixin GetStr()
|
public static mixin GetStr()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue